本文整理汇总了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;