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