本文整理汇总了TypeScript中lodash._类的典型用法代码示例。如果您正苦于以下问题:TypeScript _类的具体用法?TypeScript _怎么用?TypeScript _使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了_类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor() {
this.name = 'Pete';
console.log(NameList.get());
console.log(_.difference([1, 2, 3], [4, 2]));
}
示例2: reject
var _promise = (resolve:Function, reject:Function):void =>
{
if (!_.isObject(todo))
{
return reject(new TypeError('Todo is not a valid object.'));
}
var _todo = new Todo(todo);
_todo.save((err, saved) =>
{
err ? reject(err)
: resolve(saved);
});
}
示例3: msgCreator
return 2;
}
let randVal = msgCreator("Sam");
// --- External libs
// to use typedefenitions instead of using via node typedefinitions
// we"ll use es6 import
// import * as _ from "lodash";
// let _: Lodash = require("lodash");
import {_} from "lodash"; // use module declaration from my-lodash.d.ts
const colors = ["Red", "Blue", "Green"];
const firstColor = _.first(colors);
console.log(firstColor);
// --- Never and Void
function buildMessage(message: string): never {
throw new Error("Message not available");
}
let neverMessage: never = buildMessage("hello world");
console.log(message);
let counterE: any = 0;
// error -- into `never` we can assign only `never` ( even `any` can"t be assigned to )
// neverMessage = counterE;