本文整理汇总了TypeScript中lodash.set函数的典型用法代码示例。如果您正苦于以下问题:TypeScript set函数的具体用法?TypeScript set怎么用?TypeScript set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: setValue
public async setValue(opts: CommandOptions) {
// get value so we have a type
const splitted = opts.parameters.split(' ');
const pointer = splitted.shift();
let newValue = splitted.join(' ');
if (!pointer) {
return sendMessage(`$sender, settings does not exists`, opts.sender);
}
const currentValue = await get(global, pointer, undefined);
if (typeof currentValue !== 'undefined') {
if (isBoolean(currentValue)) {
newValue = newValue.toLowerCase().trim();
if (['true', 'false'].includes(newValue)) {
set(global, pointer, newValue === 'true');
sendMessage(`$sender, ${pointer} set to ${newValue}`, opts.sender);
} else {
sendMessage('$sender, !set error: bool is expected', opts.sender);
}
} else if (isNumber(currentValue)) {
if (isFinite(Number(newValue))) {
set(global, pointer, Number(newValue));
sendMessage(`$sender, ${pointer} set to ${newValue}`, opts.sender);
} else {
sendMessage('$sender, !set error: number is expected', opts.sender);
}
} else if (isString(currentValue)) {
set(global, pointer, newValue);
sendMessage(`$sender, ${pointer} set to '${newValue}'`, opts.sender);
} else {
sendMessage(`$sender, ${pointer} is not supported settings to change`, opts.sender);
}
} else {
sendMessage(`$sender, ${pointer} settings not exists`, opts.sender);
}
}
开发者ID:sogehige,项目名称:SogeBot,代码行数:35,代码来源:general.ts
示例2: set
groupBy.forEach((grouping: InfraPathInput, index: number) => {
if (isGroupByTerms(grouping)) {
const termsAgg = {
aggs: {},
terms: {
field: grouping.field,
size: 10,
},
};
set(aggs, `path_${index}`, termsAgg);
aggs = termsAgg.aggs;
}
if (grouping && isGroupByFilters(grouping)) {
const filtersAgg = {
aggs: {},
filters: {
filters: grouping.filters!.map(
(filter: InfraPathFilterInput): InfraESQueryStringQuery => {
return {
query_string: {
analyze_wildcard: true,
query: (filter && filter.query) || '*',
},
};
}
),
},
};
set(aggs, `path_${index}`, filtersAgg);
aggs = filtersAgg.aggs;
}
});
开发者ID:gingerwizard,项目名称:kibana,代码行数:33,代码来源:group_by_processor.ts
示例3: return
return (doc: InfraESSearchBody) => {
const result = cloneDeep(doc);
const field = nodeTypeToField(options);
set(result, 'aggs.waffle.aggs.nodes.terms', {
field,
include: {
num_partitions: options.numberOfPartitions,
partition: options.partitionId,
},
order: { _key: 'asc' },
size: NODE_REQUEST_PARTITION_SIZE * NODE_REQUEST_PARTITION_FACTOR,
});
set(result, 'aggs.waffle.aggs.nodes.aggs', {
nodeDetails: {
top_hits: {
size: 1,
_source: { includes: [NAME_FIELDS[options.nodeType]] },
sort: [{ [fields.timestamp]: { order: 'desc' } }],
},
},
});
return result;
};
开发者ID:gingerwizard,项目名称:kibana,代码行数:25,代码来源:nodes_processor.ts
示例4: removeArtifactFromField
public static removeArtifactFromField(field: string, obj: { [key: string]: string | string[] }, artifactId: string) {
const reference = get(obj, field);
if (Array.isArray(reference)) {
set(obj, field, reference.filter((a: string) => a !== artifactId));
} else if (reference === artifactId) {
set(obj, field, null);
}
}
开发者ID:spinnaker,项目名称:deck,代码行数:8,代码来源:ArtifactReferenceService.ts
示例5: it
it("returns UTC when browser support is not there", () => {
const x = get(window, "Intl", undefined);
set(window, "Intl", undefined);
window.alert = jest.fn();
expect(inferTimezone(undefined)).toBe("UTC");
expect(window.alert).toHaveBeenCalledWith(expect.stringContaining("UTC"));
set(window, "Intl", x);
});
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:8,代码来源:guess_timezone_test.ts
示例6: getIndexBoundsForPointData
export function getIndexBoundsForPointData(data: SeriesData, xValueBounds: Interval, xValuePath: string): IndexBounds {
const lowerBound = _.set({}, xValuePath, xValueBounds.min);
const upperBound = _.set({}, xValuePath, xValueBounds.max);
const firstIndex = _.sortedIndexBy(data, lowerBound, xValuePath);
const lastIndex = _.sortedLastIndexBy(data, upperBound, xValuePath);
return adjustBounds(firstIndex, lastIndex, data.length);
}
开发者ID:abe732,项目名称:react-layered-chart,代码行数:9,代码来源:renderUtils.ts
示例7: it
it("Does not crash if process.env.NODE_ENV is undefined", () => {
const old = get(process.env, "NODE_ENV", "development");
set(process.env, "NODE_ENV", "");
const result1 = configureStore();
expect(result1)
.toEqual(expect.objectContaining({ getState: expect.anything() }));
set(process.env, "NODE_ENV", old);
});
开发者ID:FarmBot,项目名称:Farmbot-Web-API,代码行数:9,代码来源:store_tests.ts
示例8: getBoundsForInstantaeousData
export function getBoundsForInstantaeousData(timestampedData: SeriesData, timeRange: Range, timestampPath: string = 'timestamp'): IndexBounds {
const lowerBound = _.set({}, timestampPath, timeRange.min);
const upperBound = _.set({}, timestampPath, timeRange.max);
const firstIndex = _.sortedIndexBy(timestampedData, lowerBound, timestampPath);
const lastIndex = _.sortedLastIndexBy(timestampedData, upperBound, timestampPath);
return adjustBounds(firstIndex, lastIndex, timestampedData.length);
}
开发者ID:briann,项目名称:react-layered-chart,代码行数:9,代码来源:util.ts
示例9:
await Promise.all(tmpl2paths(template).map(async path => {
const val = await _.get(params, path);
if (val) {
if (typeof val === "object") {
const val_ = await val.toString();
_.set(params_, path + ".toString", () => val_);
} else {
_.set(params_, path, val);
}
}
}));
开发者ID:prigaux,项目名称:compte-externe,代码行数:11,代码来源:mail.ts
注:本文中的lodash.set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论