lodash#tap TypeScript Examples

The following examples show how to use lodash#tap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: generateMetadata.ts    From nft-maker-js with Do What The F*ck You Want To Public License 6 votes vote down vote up
export default async function (
  task: null | {
    output: string
    title: string
  }
): Promise<void> {
  const manifest = resolveManifest()
  const config = resolveConfiguration()

  // Generate assets folder...
  if (task) {
    task.output = 'Generating assets folder...'
  }

  if (!fs.existsSync('./assets')) {
    fs.mkdirSync('./assets')
  }

  // Generate asset metadata...
  for (const item of manifest) {
    const { tokenId } = item as any
    const fileNumber = tokenId - 1
    let filePath = `./assets/${fileNumber}.json`

    tap(createToken(tokenId, item, config), token => {
      if (task) {
        task.output = `Generating asset metadata '${filePath}'`
      }
      fs.writeFileSync(filePath, JSON.stringify(token, null, 2), { flag: 'w' })
    })

    await delay(10)
  }
}