当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript bluebird-lst-c.map函数代码示例

本文整理汇总了TypeScript中bluebird-lst-c.map函数的典型用法代码示例。如果您正苦于以下问题:TypeScript map函数的具体用法?TypeScript map怎么用?TypeScript map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了map函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: readScopedDir

async function readScopedDir(dir: string) {
  let files: Array<string>
  try {
    files = (await readdir(dir)).filter(it => !it.startsWith("."))
  }
  catch (e) {
    // error indicates that nothing is installed here
    return []
  }

  files.sort()

  const scopes = files.filter(it => it.startsWith("@"))
  if (scopes.length === 0) {
    return files
  }

  const result = files.filter(it => !it.startsWith("@"))
  const scopeFileList = await BluebirdPromise.map(scopes, it => readdir(path.join(dir, it)))
  for (let i = 0; i < scopes.length; i++) {
    for (const file of scopeFileList[i]) {
      if (!file.startsWith(".")) {
        result.push(`${scopes[i]}/${file}`)
      }
    }
  }

  result.sort()
  return result
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:30,代码来源:readInstalled.ts

示例2: main

async function main(): Promise<void> {
  const packages = (await readdir(packageDir)).filter(it => !it.includes(".")).sort()
  const devPackageData = await readJson(path.join(rootDir, "package.json"))
  if ((await BluebirdPromise.map(packages, it => check(path.join(packageDir, it), devPackageData))).includes(false)) {
    process.exit(1)
  }
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:7,代码来源:checkDeps.ts

示例3: setPackageVersions

async function setPackageVersions(packages: Array<string>, packageData: Array<any>) {
  const versions = await BluebirdPromise.map(packages, it => exec("node", [path.join(rootDir, "test", "vendor", "yarn.js"), "info", "--json", it, "dist-tags"])
    .then((it: string) => {
      if (it === "") {
        // {"type":"error","data":"Received invalid response from npm."}
        // not yet published to npm
        return "0.0.1"
      }

      try {
        return JSON.parse(it).data
      }
      catch (e) {
        throw new Error(`Cannot parse ${it}: ${e.stack || e}`)
      }
    }))
  for (let i = 0; i < packages.length; i++) {
    const packageName = packages[i]
    const packageJson = packageData[i]
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (packageJson.version == latestVersion) {
      continue
    }

    packageJson.version = latestVersion
    console.log(`Set ${packageName} version to ${latestVersion}`)
    await writeJson(path.join(packageDir, packageName, "package.json"), packageJson, {spaces: 2})
  }
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:30,代码来源:setVersions.ts

示例4: main

async function main(): Promise<void> {
  const packages = (await readdir(packageDir)).filter(it => !it.includes(".")).sort()

  const packageData = await BluebirdPromise.map(packages, it => readJson(path.join(packageDir, it, "package.json")))
  const args = process.argv.slice(2)
  if (args.length > 0 && args[0] === "p") {
    await setPackageVersions(packages, packageData)
  }
  else {
    await setDepVersions(packages, packageData)
  }
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:12,代码来源:setVersions.ts

示例5: _readInstalled

async function _readInstalled(folder: string, parent: any | null, name: string | null, depth: number, opts: any, realpathSeen: Map<string, Dependency>, findUnmetSeen: Set<any>): Promise<any> {
  const realDir = await realpath(folder)

  const processed = realpathSeen.get(realDir)
  if (processed != null) {
    return processed
  }

  const obj = await readJson(path.resolve(folder, "package.json"))
  obj.realPath = realDir
  obj.path = obj.path || folder
  //noinspection ES6MissingAwait
  if ((await lstat(folder)).isSymbolicLink()) {
    obj.link = realDir
  }

  obj.realName = name || obj.name
  obj.dependencyNames = obj.dependencies == null ? null : new Set(Object.keys(obj.dependencies))

  // Mark as extraneous at this point.
  // This will be un-marked in unmarkExtraneous, where we mark as not-extraneous everything that is required in some way from the root object.
  obj.extraneous = true
  obj.optional = true

  if (parent != null && obj.link == null) {
    obj.parent = parent
  }

  realpathSeen.set(realDir, obj)

  if (depth > opts.depth) {
    return obj
  }

  const deps = await BluebirdPromise.map(await readScopedDir(path.join(folder, "node_modules")), pkg => _readInstalled(path.join(folder, "node_modules", pkg), obj, pkg, depth + 1, opts, realpathSeen, findUnmetSeen), {concurrency: 8})
  if (obj.dependencies != null) {
    for (const dep of deps) {
      obj.dependencies[dep.realName] = dep
    }

    // any strings in the obj.dependencies are unmet deps. However, if it's optional, then that's fine, so just delete it.
    if (obj.optionalDependencies != null) {
      for (const dep of Object.keys(obj.optionalDependencies)) {
        if (typeof obj.dependencies[dep] === "string") {
          delete obj.dependencies[dep]
        }
      }
    }
  }

  return obj
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:52,代码来源:readInstalled.ts

示例6: downloadAllRequiredElectronVersions

function downloadAllRequiredElectronVersions(): Promise<any> {
  const platforms = process.platform === "win32" ? ["win32"] : ["darwin", "linux", "win32"]
  if (process.platform === "darwin") {
    platforms.push("mas")
  }

  const versions: Array<any> = []
  for (const platform of platforms) {
    const archs = (platform === "mas" || platform === "darwin") ? ["x64"] : (platform === "win32" ? ["ia32", "x64"] : ["ia32", "x64", "armv7l"])
    for (const arch of archs) {
      versions.push({
        version: ELECTRON_VERSION,
        arch: arch,
        platform: platform,
      })
    }
  }
  return BluebirdPromise.map(versions, it => downloadElectron(it), {concurrency: 3})
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:19,代码来源:runTests.ts

示例7: main

async function main(): Promise<void> {
  const packages = (await readdir(packageDir)).filter(it => !it.includes(".")).sort()
  await BluebirdPromise.map(packages, it => spawn(process.env.npm_node_execpath || process.env.NODE_EXE || "node", [path.join(packageDir, "lint.js"), path.join(packageDir, it)], {
    stdio: ["ignore", "inherit", "pipe"],
  }), {concurrency: cpus().length})
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:6,代码来源:lint.ts


注:本文中的bluebird-lst-c.map函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。