當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript underscore.string類代碼示例

本文整理匯總了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;未經允許,請勿轉載。