How to use the cacache/lib/memoization.js.put function in cacache

To help you get started, we’ve selected a few cacache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github npm / tink / lib / ensure-package.js View on Github external
}
        if (parsed.name === 'resolve') {
          this.isResolvePkg = true
        }
        if (parsed.name === 'enhanced-resolve') {
          this.isEnhancedResolvePkg = true
        }
      }
      if (entry.path.match(/\.gyp$/)) {
        this.metadata.hasInstallScripts = true
        this.metadata.hasNativeBuild = true
      }
      const { integrity } = await cacacheWrite(this.cache, data, {
        algorithms: ['sha256']
      })
      cacacheMemo.put.byDigest(this.cache, integrity, data)
      entry.path.split(/[/\\]+/g).reduce((acc, next, i, sections) => {
        if (next === '.') { return acc }
        if (i === sections.length - 1) {
          acc[next] = integrity.toString()
        } else {
          acc[next] = acc[next] || {}
        }
        return acc[next]
      }, this.metadata.files)
      this[UNPEND]()
    } catch (err) {
      this[ONERROR](err, entry)
    }
  }