本文整理汇总了TypeScript中underscore.rest函数的典型用法代码示例。如果您正苦于以下问题:TypeScript rest函数的具体用法?TypeScript rest怎么用?TypeScript rest使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rest函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: shellExecuteNpmInstall
/**
* Executes the 'npm install' command for the packages specified in the registry package map.
*
* @param packagePath The folder of the package that is to be installed.
* @param registryMap The map of registry and packages that should be installed.
*/
public shellExecuteNpmInstall(packagePath: string, registryMap: IDictionary<Array<string>>): void {
const INSTALLABLE_PACKAGE_CHUNKSIZE: number = 50;
for (let registry in registryMap) {
let packages = registryMap[registry];
if (!packages || packages.length === 0) continue;
// Install packages in bundles because command line lengths aren't infinite. Windows for example has
// a command line limit of 8192 characters. It's variable on *nix and OSX but will in the 100,000s
let installablePackages = _.first(packages, INSTALLABLE_PACKAGE_CHUNKSIZE);
packages = _.rest(packages, INSTALLABLE_PACKAGE_CHUNKSIZE);
while (installablePackages && installablePackages.length > 0) {
var installArgs = ["install"].concat(installablePackages);
if (packagePath === process.cwd()) {
installArgs.push("--ignore-scripts");
}
if (registry !== "*") {
installArgs.push("--registry");
installArgs.push(registry);
}
this.shellExecuteNpm(packagePath, installArgs);
installablePackages = _.first(packages, INSTALLABLE_PACKAGE_CHUNKSIZE);
packages = _.rest(packages, INSTALLABLE_PACKAGE_CHUNKSIZE);
}
}
}
示例2: setExpandedAndCollapsed
private setExpandedAndCollapsed() {
if (this.facetValues.length > this.facet.options.numberOfValuesInBreadcrumb) {
this.collapsed = _.rest(this.facetValues, this.facet.options.numberOfValuesInBreadcrumb - 1);
this.expanded = _.first(this.facetValues, this.facet.options.numberOfValuesInBreadcrumb - 1);
} else {
this.collapsed = [];
this.expanded = this.facetValues;
}
}
示例3: encodeKeyValuePair
private static encodeKeyValuePair(pair: string) {
const split = pair.split('=');
if (split.length == 0) {
return pair;
}
let key = split[0];
let value = rest(split, 1).join('');
if (!key) {
return pair;
}
if (!value) {
return pair;
}
key = this.removeProblematicChars(key);
if (!this.isEncoded(value)) {
value = Utils.safeEncodeURIComponent(value);
}
return `${key}=${value}`;
}
示例4: on
on(actions.dismissStatusMessage, (state, action) => {
return {
...state,
messages: rest(state.messages),
};
});
示例5: parseSleep
export function parseSleep(tokens: string[]): Instruction | undefined {
if (_.first(tokens) === 'SLEEP') {
return new Instruction('DELAY', _.rest(tokens));
}
}
示例6: parseMotion
export function parseMotion(tokens: string[]): Instruction | undefined {
var commands = ['FORWARD', 'REVERSE', 'TURN_LEFT', 'TURN_RIGHT', 'STOP'];
if (_.indexOf(commands, _.first(tokens)) !== -1) {
return new MotionInstruction(_.first(tokens), _.rest(tokens));
}
}