當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lodash._類代碼示例

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

    }
開發者ID:peteringram0,項目名稱:Angular2-Plate,代碼行數:8,代碼來源:app.ts

示例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);
      });
    }
開發者ID:trainerbill,項目名稱:generator-ng-fullstack,代碼行數:15,代碼來源:todo.dao.ts

示例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;
開發者ID:vvscode,項目名稱:code-notes,代碼行數:31,代碼來源:learning-types.ts


注:本文中的lodash._類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。