本文整理汇总了TypeScript中underscore.string类的典型用法代码示例。如果您正苦于以下问题:TypeScript string类的具体用法?TypeScript string怎么用?TypeScript string使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了string类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: findFormatter
export function findFormatter(name: string | Function, formattersDirectory?: string) {
if (isFunction(name)) {
return name;
} else if (isString(name)) {
const camelizedName = camelize(`${name}Formatter`);
// first check for core formatters
let Formatter = loadFormatter(CORE_FORMATTERS_DIRECTORY, camelizedName);
if (Formatter != null) {
return Formatter;
}
// then check for rules within the first level of rulesDirectory
if (formattersDirectory) {
Formatter = loadFormatter(formattersDirectory, camelizedName);
if (Formatter) {
return Formatter;
}
}
// else try to resolve as module
return loadFormatterModule(name);
} else {
// If an something else is passed as a name (e.g. object)
throw new Error(`Name of type ${typeof name} is not supported.`);
}
}
开发者ID:ScottSWu,项目名称:tslint,代码行数:27,代码来源:formatterLoader.ts
示例2: transformName
function transformName(name: string) {
// camelize strips out leading and trailing underscores and dashes, so make sure they aren't passed to camelize
// the regex matches the groups (leading underscores and dashes)(other characters)(trailing underscores and dashes)
const nameMatch = name.match(/^([-_]*)(.*?)([-_]*)$/);
if (nameMatch == null) {
return name + "Rule";
}
return nameMatch[1] + camelize(nameMatch[2]) + nameMatch[3] + "Rule";
}
开发者ID:DD94800,项目名称:tslint,代码行数:9,代码来源:ruleLoader.ts
示例3: require
_.forEach(models, (model, modelName: string) => {
let fileName: string,
resource,
router,
route;
if (!_.includes(['sequelize', 'Sequelize'], modelName)) {
fileName = _str.sprintf('./%s-rt', modelName.toLowerCase());
route = require (fileName);
resource = epilogue.resource({
model: model,
endpoints: [
_str.sprintf('/%ss', modelName.toLowerCase()),
_str.sprintf('/%ss/:id', modelName.toLowerCase())
]
});
router = route(model, resource);
app.use(_str.sprintf('/api/%ss', modelName.toLowerCase()), router);
}
});
开发者ID:RELATO,项目名称:nestea,代码行数:20,代码来源:index.ts
示例4: return
return (dispatch, getState) => {
const {
edit: { article },
} = getState()
const newArticle = cloneDeep(article)
const activeSection = newArticle.sections[sectionIndex]
const isText = activeSection.type === "text"
if (!isText) {
// No action necessary if section is not text
return
} else {
const isEmptyHtml = !clean(stripTags(activeSection.body)).length
const isEmptyH1 = isEmptyHtml && activeSection.body.includes("<h1>")
if (!isEmptyHtml) {
// No action necessary if text is present
return
} else if (isEmptyH1) {
// Preserve empty H1 as section divider
newArticle.sections[sectionIndex].body = "<h1></h1>"
dispatch(onChangeArticle("sections", newArticle.sections))
} else {
// Remove text sections with empty body
dispatch(removeSection(sectionIndex))
}
}
}
开发者ID:joeyAghion,项目名称:positron,代码行数:28,代码来源:sectionActions.ts
示例5:
meta.extras.forEach((extra: any) => {
var extraUri = extraBaseIri + _s.dasherize(extra.key.toLowerCase());
this.addTriple(datasetUri, extraUri, `"${extra.value}"`);
this.addTriple(extraUri, ns.rdfs + 'label', `"${extra.key}"`);
if (extra.key === 'Rujukan' && _s.startsWith(extra.value, 'http')) {
this.addTriple(datasetUri, ns.rdfs + 'seeAlso', extra.value);
}
});
开发者ID:benangmerah,项目名称:benangmerah,代码行数:9,代码来源:IdGovCkanDatasetFetcher.ts
示例6: if
preProcessRow(rowObject: CsvRow, observationMap: ObservationMap): CsvRow {
const processedRow = {...rowObject};
this.heuristicFields.forEach(ignoredField => {
delete processedRow[ignoredField];
});
// Handle refArea
if (rowObject.kode_kabkota) {
observationMap.set(ns.bm + 'refArea', ns.bps + rowObject.kode_kabkota);
}
else if (rowObject.kode_provinsi) {
observationMap.set(ns.bm + 'refArea', ns.bps + rowObject.kode_provinsi);
}
// Handle refPeriod
if (rowObject.tahun && rowObject.bulan) {
var period = rowObject.tahun + '-' + _s.pad(rowObject.bulan, 2, '0');
observationMap.set(ns.bm + 'refPeriod', `"${period}"^^<${ns.xsd}gYearMonth>`);
}
else if (rowObject.tahun) {
if (yearRegex.test(rowObject.tahun)) {
observationMap.set(ns.bm + 'refPeriod', `"${rowObject.tahun}"^^<${ns.xsd}gYear>`);
}
else {
observationMap.set(ns.bm + 'refPeriod', `"${rowObject.tahun}"`);
}
}
return processedRow;
}
开发者ID:benangmerah,项目名称:benangmerah,代码行数:31,代码来源:IdGovCsvDatacubeFetcher.ts
示例7: fetch
async fetch(): Promise<void> {
if (!this.fetcherParams.datasetId) {
this.error('No dataset was specified.');
return;
}
let datasetMetadata = await this.fetchCkanMetadata();
let csvUrl;
for (const resource of datasetMetadata.resources) {
if (_s.endsWith(resource.url, '.csv')) {
csvUrl = resource.url;
break;
}
}
if (csvUrl) {
this.addMetadataTriples(datasetMetadata);
let csvFetcher = this.addDependentFetcher({
name: 'csv',
fetcherClassName: 'DataGoIdCsvDatacubeFetcher',
fetcherParams: {
csvUrl: csvUrl,
datasetIri: this.datasetIri
}
});
await csvFetcher.fetch();
}
}
开发者ID:benangmerah,项目名称:benangmerah,代码行数:29,代码来源:IdGovCkanDatasetFetcher.ts
示例8: resetToOriginal
resetToOriginal() {
if (s.isBlank(this._originalValue())) {
this.edit();
} else {
this._value(this._originalValue());
this._canEdit(false);
}
}
开发者ID:GaneshSPatil,项目名称:gocd,代码行数:8,代码来源:encrypted_value.ts
示例9: return
return (_dispatch, _getState) => {
let blockquote = html
const beforeHtml = _s(html).strLeft("<blockquote>")._wrapped
const afterHtml = _s(html).strRight("</blockquote>")._wrapped
if (beforeHtml) {
// add text before blockquote to new text section
blockquote = blockquote.replace(beforeHtml, "")
}
if (afterHtml) {
// add text after blockquote to new text section
blockquote = blockquote.replace(afterHtml, "")
}
const newBlocks = {
blockquote,
beforeHtml,
afterHtml,
}
return newBlocks
}
开发者ID:artsy,项目名称:positron,代码行数:20,代码来源:textSectionActions.ts
示例10: slackFieldify
var result = _.map(_.keys(inputObj), function(key){
if (!_.isObject(inputObj[key])) {
return {
title: s(prefix + key).humanize().titleize().value(),
value: inputObj[key],
short: short
}
} else {
return slackFieldify(inputObj[key], short, prefix + key)
}
})
开发者ID:brettneese,项目名称:slack-fieldify,代码行数:11,代码来源:index.ts
注:本文中的underscore.string类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论