本文整理匯總了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 },