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


TypeScript lodash.mixin函數代碼示例

本文整理匯總了TypeScript中lodash.mixin函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript mixin函數的具體用法?TypeScript mixin怎麽用?TypeScript mixin使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了mixin函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

import _ from 'lodash';

_.mixin({
    move: function (array, fromIndex, toIndex) {
	    array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
	    return array;
    }
});
開發者ID:MikeLarned,項目名稱:sialia,代碼行數:8,代碼來源:lodashmixins.ts

示例2: function

 .run(() => {
     _.mixin({
         arraySwap: function(array, a, b) {
             if (_.isArray(array) && _.size(array) > a && _.size(array) > b) {
                 const temp = array[a];
                 array[a] = array[b];
                 array[b] = temp;
             }
             return array;
         }
     });
     _.mixin({
         zipBy: function(array, kfield, vfield) {
             if (_.isArray(array) && kfield) {
                 if (vfield) {
                     return _.zipObject(_.map(array, kfield), _.map(array, vfield));
                 } else {
                     return _.zipObject(_.map(array, kfield), array);
                 }
             } else {
                 return {};
             }
         }
     });
     _.mixin({
         set: function(obj, field) {
             return function(value) {
                 obj[field] = value;
             };
         }
     });
     _.mixin({
         setWithCallback: function(obj, field, cb) {
             return function(value) {
                 cb = cb || angular.noop;
                 obj[field] = value;
                 cb(value);
             };
         }
     });
     _.mixin({
         flattenTree: function flattenTree(obj, extractChildren) {
             if (!_.isArray(obj) && obj) {
                 obj = [obj];
             }
             if (_.isEmpty(obj)) {
                 return [];
             }
             return _.union(
                 obj,
                 _(obj)
                     .map(function(o) {
                         return flattenTree(extractChildren(o), extractChildren);
                     })
                     .flatten()
                     .value()
             );
         }
     });
     _.mixin({
         reducedIndexOf: function(obj, extractor, combinator) {
             if (!_.isArray(obj) && obj) {
                 obj = [obj];
             }
             let results = {};
             _.each(obj, function(o) {
                 const index = extractor(o);
                 if (results[index]) {
                     results[index] = combinator(results[index], o);
                 } else {
                     results[index] = o;
                 }
             });
             return results;
         }
     });
 })
開發者ID:Opetushallitus,項目名稱:eperusteet,代碼行數:77,代碼來源:app.ts

示例3: require

 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

//--------------------------------------------
// Extend lodash
var _ = require('lodash');
_.mixin(require('lodash-deep'));

//--------------------------------------------

const url = require('url');
const Promise = require('bluebird');
const path = require('path');
const paths = require('../paths');
const config = require('../config');
const getPort = require('get-port');

//---------------------------------------------------
// Look for server certificates
interface ProtocolOptions {
  key?: string;
  cert?: string;
開發者ID:agneta,項目名稱:platform,代碼行數:31,代碼來源:index.ts

示例4:

import _ from 'lodash';

/*
  Mixins :)
*/
_.mixin({
  move: (array, fromIndex, toIndex) => {
    array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);
    return array;
  },
});
開發者ID:ArcticSnowman,項目名稱:grafana,代碼行數:11,代碼來源:lodash_extended.ts


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