Gathering detailed insights and metrics for gatsby-core-utils
Gathering detailed insights and metrics for gatsby-core-utils
Gathering detailed insights and metrics for gatsby-core-utils
Gathering detailed insights and metrics for gatsby-core-utils
npm install gatsby-core-utils
Typescript
Module System
Min. Node Version
Node Version
NPM Version
67.4
Supply Chain
98
Quality
82
Maintenance
100
Vulnerability
99.3
License
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Latest Version
4.14.0
Package Id
gatsby-core-utils@4.14.0
Unpacked Size
170.42 kB
Size
45.79 kB
File Count
97
NPM Version
lerna/3.22.1/node@v20.11.1+arm64 (darwin)
Node Version
20.11.1
Published on
Nov 06, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
gatsby-core-utils
Utilities used in multiple Gatsby packages.
1npm install gatsby-core-utils
Encrypts an input using md5 hash of hexadecimal digest.
1const { createContentDigest } = require("gatsby-core-utils") 2 3const options = { 4 key: "value", 5 foo: "bar", 6} 7 8const digest = createContentDigest(options) 9// ...
Calculate the number of CPU cores on the current machine
This function can be controlled by an env variable GATSBY_CPU_COUNT
setting the first argument to true.
value | description |
---|---|
Counts amount of real cores by running a shell command | |
logical_cores | require("os").cpus() to count all virtual cores |
any number | Sets cpu count to that specific number |
1const { cpuCoreCount } = require("gatsby-core-utils") 2 3const coreCount = cpuCoreCount(false) 4// ...
1const { cpuCoreCount } = require("gatsby-core-utils") 2process.env.GATSBY_CPU_COUNT = "logical_cores" 3 4const coreCount = cpuCoreCount() 5// ...
A utility that joins paths with a /
on windows and unix-type platforms. This can also be used for URL concatenation.
1const { joinPath } = require("gatsby-core-utils") 2 3const BASEPATH = "/mybase/" 4const pathname = "./gatsby/is/awesome" 5const url = joinPath(BASEPATH, pathname) 6// ...
A utility that enhances isCI
from 'ci-info` with support for Vercel and Heroku detection
1const { isCI } = require("gatsby-core-utils") 2 3if (isCI()) { 4 // execute CI-specific code 5} 6// ...
A utility that returns the name of the current CI environment if available, null
otherwise
1const { getCIName } = require("gatsby-core-utils") 2 3const CI_NAME = getCIName() 4console.log({ CI_NAME }) 5// {CI_NAME: null}, or 6// {CI_NAME: "Vercel"} 7// ...
A cross-version polyfill for Node's Module.createRequire
.
1const { createRequireFromPath } = require("gatsby-core-utils") 2 3const requireUtil = createRequireFromPath("../src/utils/") 4 5// Require `../src/utils/some-tool` 6requireUtil("./some-tool") 7// ...
When working inside workers or async operations you want some kind of concurrency control that a specific work load can only concurrent one at a time. This is what a Mutex does.
By implementing the following code, the code is only executed one at a time and the other threads/async workloads are awaited until the current one is done. This is handy when writing to the same file to disk.
1const { createMutex } = require("gatsby-core-utils/mutex") 2 3const mutex = createMutex("my-custom-mutex-key") 4await mutex.acquire() 5 6await fs.writeFile("pathToFile", "my custom content") 7 8await mutex.release()
Parts of hash-wasm
are re-exported from gatsby-core-utils
or used in custom functions. When working on hashing where you'd normally use crypto
from Node.js, you can use these functions instead. They especially show their advantage on large inputs so don't feel obliged to always use them. Refer to hash-wasm
's documentation for more details on usage for the re-exported functions.
1const { md5File, md5, createMD5, sha256, sha1 } = require("gatsby-core-utils") 2 3// For md5, createMD5, sha256, sha1 refer to hash-wasm 4await md5(`some-string`) 5 6// md5File gives you the MD5 hex hash for a given filepath 7await md5File(`package.json`)
No vulnerabilities found.
No security vulnerabilities found.