本文整理汇总了TypeScript中underscore.partial函数的典型用法代码示例。如果您正苦于以下问题:TypeScript partial函数的具体用法?TypeScript partial怎么用?TypeScript partial使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了partial函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: readFromFile
export function readFromFile(fileName: string, callback: (inst: Instruction) => void) {
var consumeInstructionPartial = _.partial<InstructionConsumer[], InstructionConsumerArgs, void>(
consumeInstruction,
[consumeNil, consumeDelay, consumeCommand]
);
highland([fileName])
.flatMap(highland.wrapCallback(fs.readFile) as any)
.split()
.filter((line: string) => {
return line !== '';
})
.map((line: string) => {
return line.split(' ');
})
.map<Instruction | undefined | Highland.Nil>(
_.partial<InstructionParser[], string[], Instruction | undefined>(parseInstruction, [parseSleep, parseMotion])
)
.consume((err: Error, instruction: Instruction | Highland.Nil, push: Function, next: Function) => {
consumeInstructionPartial({
err: err,
instruction: instruction,
push: push,
next: next
});
})
.each((val: any) => {
callback(val);
});
}
示例2: isAllEqual
private isAllEqual(array: string[]) {
return _.all(array.slice(1), _.partial(_.isEqual, array[0]));
}
示例3: function
(result1 === result2); // true
}
// arrays
{
var a = [1];
a = i.push(a, 2); // [1, 2];
a = i.unshift(a, 0); // [0, 1, 2];
a = i.pop(a); // [0, 1];
a = i.shift(a); // [1];
}
{
i.map(function(v) { return v * 2 }, [1, 2, 3]); // [2, 4, 6]
var removeEvens = _.partial(i.filter, function(v: number) { return v % 2; });
removeEvens([1, 2, 3]); // [1, 3]
}
{
var arr = i.freeze([{ a: 1 }, { b: 2 }]);
//ECMAScript 2015
//arr.find(function(item) { return item.b != null; }); // {b: 2}
}
// chain(coll) - not defined
{
let o = {
a: [1, 2, 3],
b: { c: 1 },