• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

TypeScript bluebird-lst.filter函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: readProjectMetadata

async function readProjectMetadata(packageDir: string) {
  const packageDirs = BluebirdPromise.filter((await readdir(packageDir)).filter(it => !it.includes(".")).sort(), it => {
    return stat(path.join(packageDir, it, "package.json"))
      .then(it => it.isFile())
      .catch(() => false)
  })
  return await BluebirdPromise.map(packageDirs, it => readJson(path.join(packageDir, it, "package.json")), {concurrency: 8})
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:8,代码来源:setVersions.ts


示例2: rebuild

export async function rebuild(appDir: string, options: RebuildOptions) {
  const nativeDeps = await BluebirdPromise.filter(await options.productionDeps!.value, it => exists(path.join(it.path, "binding.gyp")), {concurrency: 8})
  if (nativeDeps.length === 0) {
    log(`No native production dependencies`)
    return
  }

  const platform = options.platform || process.platform
  const arch = options.arch || process.arch
  const additionalArgs = options.additionalArgs

  log(`Rebuilding native production dependencies for ${platform}:${arch}`)

  let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS
  const isYarn = isYarnPath(execPath)
  const execArgs: Array<string> = []
  if (execPath == null) {
    execPath = getPackageToolPath()
  }
  else {
    execArgs.push(execPath)
    execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
  }

  const env = getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true)
  if (isYarn) {
    execArgs.push("run", "install", "--")
    if (additionalArgs != null) {
      execArgs.push(...additionalArgs)
    }
    await BluebirdPromise.map(nativeDeps, dep => {
      log(`Rebuilding native dependency ${dep.name}`)
      return spawn(execPath!, execArgs, {
        cwd: dep.path,
        env,
      })
        .catch(error => {
          if (dep.optional) {
            warn(`Cannot build optional native dep ${dep.name}`)
          }
          else {
            throw error
          }
        })
    }, {concurrency: process.platform === "win32" ? 1 : 2})
  }
  else {
    execArgs.push("rebuild")
    if (additionalArgs != null) {
      execArgs.push(...additionalArgs)
    }
    execArgs.push(...nativeDeps.map(it => it.name))
    await spawn(execPath, execArgs, {
      cwd: appDir,
      env,
    })
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:58,代码来源:yarn.ts


示例3: rebuild

export async function rebuild(appDir: string, frameworkInfo: DesktopFrameworkInfo, platform: string = process.platform, arch: string = process.arch, additionalArgs: Array<string>, buildFromSource: boolean) {
  const pathToDep = await readInstalled(appDir)
  const nativeDeps = await BluebirdPromise.filter(pathToDep.values(), it => it.extraneous ? false : exists(path.join(it.path, "binding.gyp")), {concurrency: 8})
  if (nativeDeps.length === 0) {
    log(`No native production dependencies`)
    return
  }

  log(`Rebuilding native production dependencies for ${platform}:${arch}`)

  let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS
  const isYarn = isYarnPath(execPath)
  const execArgs: Array<string> = []
  if (execPath == null) {
    execPath = getPackageToolPath()
  }
  else {
    execArgs.push(execPath)
    execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
  }

  const env = getGypEnv(frameworkInfo, platform, arch, buildFromSource)
  if (isYarn) {
    execArgs.push("run", "install", "--")
    execArgs.push(...additionalArgs)
    await BluebirdPromise.each(nativeDeps, dep => {
      log(`Rebuilding native dependency ${dep.name}`)
      return spawn(execPath, execArgs, {
        cwd: dep.path,
        env: env,
      })
        .catch(error => {
          if (dep.optional) {
            warn(`Cannot build optional native dep ${dep.name}`)
          }
          else {
            throw error
          }
        })
    })
  }
  else {
    execArgs.push("rebuild")
    execArgs.push(...additionalArgs)
    execArgs.push(...nativeDeps.map(it => it.name))
    await spawn(execPath, execArgs, {
      cwd: appDir,
      env: env,
    })
  }
}
开发者ID:djpereira,项目名称:electron-builder,代码行数:51,代码来源:yarn.ts


示例4: transformFiles

export async function transformFiles(transformer: FileTransformer, fileSet: ResolvedFileSet): Promise<void> {
  if (transformer == null) {
    return
  }

  let transformedFiles = fileSet.transformedFiles
  if (fileSet.transformedFiles == null) {
    transformedFiles = new Map()
    fileSet.transformedFiles = transformedFiles
  }

  const metadata = fileSet.metadata
  await BluebirdPromise.filter(fileSet.files, (it, index) => {
    const fileStat = metadata.get(it)
    if (fileStat == null || !fileStat.isFile()) {
      return false
    }

    const transformedValue = transformer(it)
    if (transformedValue == null) {
      return false
    }

    if (typeof transformedValue === "object" && "then" in transformedValue) {
      return (transformedValue as Promise<any>)
        .then(it => {
          if (it != null) {
            transformedFiles!!.set(index, it)
          }
          return false
        })
    }
    transformedFiles!!.set(index, transformedValue as string | Buffer)
    return false
  }, CONCURRENCY)
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:36,代码来源:appFileCopier.ts


示例5: computeFileSets

export async function computeFileSets(matchers: Array<FileMatcher>, transformer: FileTransformer, packager: Packager, isElectronCompile: boolean): Promise<Array<ResolvedFileSet>> {
  const fileSets: Array<ResolvedFileSet> = []
  let hoistedNodeModuleFileSets: Array<ResolvedFileSet> | null = null
  let isHoistedNodeModuleChecked = false
  for (const matcher of matchers) {
    const fileWalker = new AppFileWalker(matcher, packager)

    const fromStat = await statOrNull(matcher.from)
    if (fromStat == null) {
      log.debug({directory: matcher.from, reason: "doesn't exist"}, `skipped copying`)
      continue
    }

    const files = await walk(matcher.from, fileWalker.filter, fileWalker)
    const metadata = fileWalker.metadata

    // https://github.com/electron-userland/electron-builder/issues/2205 Support for hoisted node_modules (lerna + yarn workspaces)
    // if no node_modules in the app dir, it means that probably dependencies are hoisted
    // check that main node_modules doesn't exist in addition to isNodeModulesHandled because isNodeModulesHandled will be false if node_modules dir is ignored by filter
    // here isNodeModulesHandled is required only because of performance reasons (avoid stat call)
    if (!isHoistedNodeModuleChecked && matcher.from === packager.appDir && !fileWalker.isNodeModulesHandled) {
      isHoistedNodeModuleChecked = true
      if ((await statOrNull(path.join(packager.appDir, "node_modules"))) == null) {
        // in the prepacked mode no package.json
        const packageJsonStat = await statOrNull(path.join(packager.appDir, "package.json"))
        if (packageJsonStat != null && packageJsonStat.isFile()) {
          hoistedNodeModuleFileSets = await copyHoistedNodeModules(packager, matcher)
        }
      }
    }

    const transformedFiles = new Map<number, string | Buffer>()
    await BluebirdPromise.filter(files, (it, index) => {
      const fileStat = metadata.get(it)
      if (fileStat == null || !fileStat.isFile()) {
        return false
      }

      const transformedValue = transformer(it)
      if (transformedValue == null) {
        return false
      }

      if (typeof transformedValue === "object" && "then" in transformedValue) {
        return (transformedValue as BluebirdPromise<any>)
          .then(it => {
            if (it != null) {
              transformedFiles.set(index, it)
            }
            return false
          })
      }
      transformedFiles.set(index, transformedValue as string | Buffer)
      return false
    }, CONCURRENCY)

    fileSets.push({src: matcher.from, files, metadata, transformedFiles, destination: matcher.to})
  }

  if (isElectronCompile) {
    // cache files should be first (better IO)
    fileSets.unshift(await compileUsingElectronCompile(fileSets[0], packager))
  }
  if (hoistedNodeModuleFileSets != null) {
    return fileSets.concat(hoistedNodeModuleFileSets)
  }
  return fileSets
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:68,代码来源:AppFileCopierHelper.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript bluebird-lst.map函数代码示例发布时间:2022-05-25
下一篇:
TypeScript bluebird-lst.all函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap