本文整理汇总了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;未经允许,请勿转载。 |
请发表评论