本文整理汇总了TypeScript中lodash.repeat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript repeat函数的具体用法?TypeScript repeat怎么用?TypeScript repeat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了repeat函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
() => {
const aHashtag = _.repeat( 'a', 139 );
const bHashtag = _.repeat( 'b', 140 ); // too long - don't link
const result = autolinker.link( `#${aHashtag} and #${bHashtag}` );
expect( result ).toBe( `<a href="${urlPrefix}/${aHashtag}">#${aHashtag}</a> and #${bHashtag}` );
} );
开发者ID:gregjacobs,项目名称:Autolinker.js,代码行数:7,代码来源:autolinker-hashtag.spec.ts
示例2: it
it( 'should link an instagram mention that is up to 30 characters long', () => {
const aUsername = _.repeat( 'a', 30 );
const bUsername = _.repeat( 'b', 31 ); // too long - don't link
const result = instagramAutolinker.link( `@${aUsername} and @${bUsername}` );
expect( result ).toBe( `<a href="https://instagram.com/${aUsername}">@${aUsername}</a> and @${bUsername}` );
} );
开发者ID:gregjacobs,项目名称:Autolinker.js,代码行数:7,代码来源:autolinker-mention.spec.ts
示例3: it
it("should validate Id format", () => {
//tslint:disable-next-line
interface Material extends ValidatableMixin {
}
class Material implements ValidatableMixin {
id: Stream<string>;
constructor(id: string) {
ValidatableMixin.call(this);
this.id = stream(id);
this.validateIdFormat("id");
}
}
applyMixins(Material, ValidatableMixin);
const badStrings = ["shaky salamander", ".hello", _.repeat("a", 256)];
badStrings.forEach((badString) => {
const material = new Material(badString);
material.validate();
expect(material.errors().hasErrors()).toBe(true);
expect(material.errors().errors("id"))
.toEqual(["Invalid id. This must be alphanumeric and can contain hyphens, underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."]);
});
});
开发者ID:GaneshSPatil,项目名称:gocd,代码行数:27,代码来源:new_validatable_mixin_spec.ts
示例4:
lines.forEach((line: string, index: number) => {
let newLine: string = (index < lines.length - 1) ? "\n" : "";
if (line && (index > 0 || !noIndentFirstLine))
result += _.repeat(" ", unitIndent * numIndent) + line + newLine;
else
result += line + newLine;
});
开发者ID:nashika,项目名称:spreadsheet-code-generator,代码行数:7,代码来源:source-utils.ts
示例5: memoize
export const stringifyTreeNodeToXML = memoize((node: TreeNode, level: number = 0) => {
const tabs = repeat(" ", level * 2);
let buffer = `${tabs}<${node.name}`;
for (const namespace in node.attributes) {
const nsa = node.attributes[namespace];
for (const name in nsa) {
let value = nsa[name];
if (name === "style") {
value = stringifyStyle(value);
}
let attrName = name;
if (namespace !== DEFAULT_NAMESPACE) {
attrName = namespace + ":" + attrName;
}
buffer += ` ${attrName}=${JSON.stringify(value)}`
}
}
buffer += `>`;
if (node.children.length) {
buffer += `\n`;
}
buffer += node.children.map(child => stringifyTreeNodeToXML(child, level + 1)).join("");
buffer += `${node.children.length ? tabs : ""}</${node.name}>\n`;
return buffer;
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:35,代码来源:xml.ts
示例6: Promise
return new Promise((resolve, reject) => {
this.error = false;
let customWordList = _.map(this.customWords, 'word');
if (!_.isEqual(this.mnemonicWords, customWordList)) {
return reject('Mnemonic string mismatch');
}
if (this.mnemonicHasPassphrase) {
let walletClient = this.bwcProvider.getClient();
let separator = this.useIdeograms ? '\u3000' : ' ';
let customSentence = customWordList.join(separator);
let password = this.password || '';
try {
walletClient.seedFromMnemonic(customSentence, {
network: this.wallet.credentials.network,
password,
account: this.wallet.credentials.account
});
} catch (err) {
walletClient.credentials.xPrivKey = _.repeat('x', 64);
return reject(err);
}
if (walletClient.credentials.xPrivKey.substr(walletClient.credentials.xPrivKey) != this.keys.xPrivKey) {
delete walletClient.credentials;
return reject('Private key mismatch');
}
}
this.profileProvider.setBackupFlag(this.wallet.credentials.walletId);
return resolve();
});
开发者ID:bitjson,项目名称:copay,代码行数:35,代码来源:backup-game.ts
示例7: transform
transform(value: number) : string {
let numDigits = Math.max(Math.floor(Math.log(Math.abs(value)) / Math.LN10), 0) + 1;
let numZeroes = 3 - numDigits;
return `${_.repeat('0', numZeroes)}${value}`;
}
开发者ID:icbmike,项目名称:typesweeper,代码行数:7,代码来源:timer-formatter.pipe.ts
示例8: if
const transpileInferredProps = ({ type, properties }: Inference, path: string[] = []) => {
if (type === InferenceType.ANY) {
return `any`;
} else if (properties.$$each) {
let content = transpileInferredProps(properties.$$each, [...path, "$$each"]);
const buffer = [];
if (type & InferenceType.ARRAY) {
buffer.push(`Array<${content}>`);
}
if (type & InferenceType.OBJECT) {
buffer.push(`{ [identifier: string]:${content} }`);
}
return buffer.join(" | ");
} else if (type & InferenceType.OBJECT) {
let content = `{\n`;
for (const key in properties) {
content += repeat(" ", path.length * 2) + `${ATTRIBUTE_MAP[key] || key}: ${transpileInferredProps(properties[key], [...path, key])};\n`
}
// allow for any props for now. Will eventuall want to request for template
content += repeat(" ", (path.length) * 2) + "[identifier: string]: any;\n"
content += repeat(" ", (path.length - 1) * 2) + `}`;
return content;
} else {
let content = ``;
const buffer = [];
if (type & InferenceType.STRING) {
buffer.push("string");
}
if (type & InferenceType.NUMBER) {
buffer.push("number");
}
if (type & InferenceType.BOOLEAN) {
buffer.push("boolean");
}
return buffer.join(" | ");
}
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:47,代码来源:typescript-def.ts
示例9:
this.classes.filter(x => x.export).forEach(x => {
var name = x.name;
if (name === this.displayName) {
name = '_' + this.displayName;
}
lines.push(_.repeat(' ', indent + 4) + `class ${name} extends ${this.displayName}.${x.name} {}`);
});
开发者ID:david-driscoll,项目名称:atom-typescript-generator,代码行数:8,代码来源:Project.ts
注:本文中的lodash.repeat函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论