本文整理匯總了TypeScript中src/lib/number.numberParser函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript numberParser函數的具體用法?TypeScript numberParser怎麽用?TypeScript numberParser使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了numberParser函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: isNumber
constant: ({ F, H }, params, branch) => {
const param = params[0];
const val = isNumber(param) ? param : numberParser(param);
F.set(branch, branch, -1);
H.set(branch, branch, val);
},
示例2: test
test('numberParser(), 數字編譯', () => {
expect(numberParser('123x')).toBe(NaN);
expect(numberParser('1234')).toBe(1234);
expect(numberParser('2e3')).toBe(2000);
expect(numberParser('2e-3')).toBe(0.002);
expect(numberParser('0.02M')).toBe(2e4);
expect(numberParser('0.02m')).toBe(2e-5);
expect(numberParser('200u')).toBe(2e-4);
});
示例3: constant
},
{
name: 'path',
attribute: {
d: 'M0,-40V-20M0,20V40M0,-12V12',
},
},
{
name: 'polygon',
attribute: {
points: '0,-14 -5,-4 0,-8 5,-4', class: 'fill-black', // fill: '#3B4449', 'stroke-width': '0.5', 'stroke-linecap': 'square'
},
},
{
name: 'rect',
attribute: {
x: '-20', y: '-30', width: '40', height: '60', class: 'focus-transparent',
},
},
],
constant({ H, S }, params, branch) {
const param = params[0];
const val = isNumber(param) ? param : numberParser(param);
H.set(branch, branch, 1);
S.set(branch, 0, val);
},
};
export default part;
示例4: createIterator
return [mark + 1];
},
},
],
connect: [
['R1-1', 'VD1-1'],
],
interface: [
['R1-0'],
['VD1-0'],
],
},
iterative: {
createIterator({ Factor, Source, getVoltageMatrixByPin }, part: PartData, mark) {
/** 導通電壓 */
const onVol = numberParser(part.params[0]);
/** 導通電阻 */
const onRes = numberParser(part.params[1]);
/** 關斷電阻 */
const offRes = numberParser(part.params[2]);
/** 電阻值標記位置 */
const resPosition = Factor.filterPostion(mark);
/** 導通電壓標記位置 */
const volPosition = Source.filterPostion(mark + 1);
/** 電壓計算矩陣 */
const volMatrix = (
getVoltageMatrixByPin(`${part.id}-0`)
.add(getVoltageMatrixByPin(`${part.id}-1`).factor(-1))
);
// 緩存上一次的計算值
示例5: markInMatrix
{
name: 'rect',
attribute: {
x: '-30', y: '-15', width: '60', height: '30', class: 'focus-transparent',
},
},
],
// 這裏是把電容看作是隨電流積分而變得電壓源
iterative: {
markInMatrix({ F, S }, mark, branch) {
F.set(branch, branch, 1);
S.set(branch, 0, mark);
},
createIterator({ Source, getCurrentMatrixByBranch }, part: PartData, mark) {
/** 電容值 */
const valueCap = numberParser(part.params[0]);
/** 需要更新的數值位置 */
const position = Source.filterPostion(mark);
/** 當前器件的電流計算矩陣 */
const currentMatix = getCurrentMatrixByBranch(part.id);
/** 積分的中間變量 */
const save = {
last: 0,
integral: 0,
};
return ({ Current, interval }) => {
/** 當前電流 */
const current = currentMatix.mul(Current).get(0, 0);
// 電流積分,一階近似累加
示例6: markInMatrix
},
{
name: 'rect',
attribute: {
x: '-20', y: '-30', width: '40', height: '60', class: 'focus-transparent',
},
},
],
iterative: {
markInMatrix({ F, S }, mark, branch) {
F.set(branch, branch, 1);
S.set(branch, 0, mark);
},
createIterator({ Source }, data: PartData, mark) {
/** 峰值電壓 */
const factor = numberParser(data.params[0]);
/** 頻率 */
const frequency = numberParser(data.params[1]);
/** 偏置電壓 */
const bias = numberParser(data.params[2]);
/** 初始相角 */
const phase = numberParser(data.params[3]);
/** 需要更新的數值位置 */
const position = Source.filterPostion(mark);
const Pi2 = frequency * Math.PI * 2;
const Degree = phase / 180 * Math.PI;
return ({ time }) => {
// 當前輸出電壓
const volt = factor * Math.sin(time * Pi2 + Degree) + bias;