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