{"name":"gatsby-core-utils","version":"4.16.0","keywords":["gatsby","gatsby-core-utils"],"author":{"name":"Ward Peeters","email":"ward@coding-tech.com"},"license":"MIT","_id":"gatsby-core-utils@4.16.0","maintainers":[{"name":"pieh","email":"misiek.piechowiak@gmail.com"},{"name":"kathmbeck","email":"katherine.beck@netlify.com"},{"name":"serhalp-netlify","email":"philippe.serhal@netlify.com"},{"name":"mlgualtieri-gatsby","email":"mike.gualtieri@netlify.com"},{"name":"wardpeet","email":"ward@coding-tech.com"}],"homepage":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-core-utils#readme","bugs":{"url":"https://github.com/gatsbyjs/gatsby/issues"},"dist":{"shasum":"31ec88ab51272bb8a58535505633a57e8c069899","tarball":"http://registry-npm.ywwl.com/gatsby-core-utils/download/gatsby-core-utils-4.16.0.tgz","fileCount":97,"integrity":"sha512-QCZ9BmQp3YyYxH0Wf4bofayL3vJnayqSvsBUAhKXGh/Os0fn1KMNyAjPLnW+zrGFQaK05Vjdlp99I/Wnc3M33A==","signatures":[{"sig":"MEUCIQCgWIQHoJ4p/lpOuHONEeWCbZfOn0bSPYn+xWZiSbV3dQIgc57dL1NFTANA2T98rDG6eiK5QxRsQMwodloyTCtDbGg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":175409,"size":47036,"noattachment":false,"key":"/gatsby-core-utils/-/gatsby-core-utils-4.16.0.tgz"},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0 <26"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./*":{"types":"./dist/*.d.ts","import":"./dist/*.mjs","require":"./dist/*.js"},"./dist/*":{"types":"./dist/*.d.ts","import":"./dist/*.mjs","require":"./dist/*.js"}},"gitHead":"92d6c67dcf10b641adf5fcc81ebeec5f50b75e40","scripts":{"build":"npm-run-all --npm-path npm -s build:*","clean":"del-cli dist/*","watch":"npm-run-all --npm-path npm -p watch:*","prepare":"cross-env NODE_ENV=production npm-run-all --npm-path npm -s build typegen","typegen":"tsc --emitDeclarationOnly --declaration --declarationDir dist/","prebuild":"npm-run-all --npm-path npm clean","build:cjs":"babel src --out-dir dist/ --ignore \"**/__tests__\" --ignore \"**/__mocks__\" --extensions \".ts\"","build:mjs":"cross-env BABEL_ENV=modern babel src --out-dir dist/ --ignore \"**/__tests__\" --ignore \"**/__mocks__\" --extensions \".ts\" --out-file-extension .mjs","watch:cjs":"babel -w src --out-dir dist/ --ignore \"**/__tests__\" --ignore \"**/__mocks__\" --extensions \".ts\"","watch:mjs":"cross-env BABEL_ENV=modern babel -w src --out-dir dist/ --ignore \"**/__tests__\" --ignore \"**/__mocks__\" --extensions \".ts\" --out-file-extension .mjs"},"_npmUser":{"name":"serhalp-netlify","email":"philippe.serhal@netlify.com"},"repository":{"url":"git+https://github.com/gatsbyjs/gatsby.git","type":"git","directory":"packages/gatsby-core-utils"},"_npmVersion":"lerna/3.22.1/node@v22.19.0+arm64 (darwin)","description":"A collection of gatsby utils used in different gatsby packages","directories":{},"_nodeVersion":"22.19.0","dependencies":{"got":"^11.8.6","tmp":"^0.2.1","lmdb":"2.5.3","lock":"^1.1.0","fastq":"^1.15.0","ci-info":"2.0.0","fs-extra":"^11.2.0","file-type":"^16.5.4","hash-wasm":"^4.11.0","configstore":"^5.0.1","import-from":"^4.0.0","xdg-basedir":"^4.0.0","resolve-from":"^5.0.0","@babel/runtime":"^7.20.13","proper-lockfile":"^4.1.2","node-object-hash":"^2.3.10"},"typesVersions":{"*":{"*":["dist/*.d.ts","dist/index.d.ts"]}},"_hasShrinkwrap":false,"devDependencies":{"msw":"^1.2.2","del-cli":"^5.0.0","is-uuid":"^1.0.2","cross-env":"^7.0.3","@babel/cli":"^7.20.7","typescript":"^5.1.6","@babel/core":"^7.20.12","npm-run-all":"^4.1.5","@types/ci-info":"2.0.0","babel-preset-gatsby-package":"^3.16.0"},"_npmOperationalInternal":{"tmp":"tmp/gatsby-core-utils_4.16.0_1769459232710_0.6540699074528673","host":"s3://npm-registry-packages-npm-production"},"readme":"# `gatsby-core-utils`\n\nUtilities used in multiple Gatsby packages.\n\n## Usage\n\n```shell\nnpm install gatsby-core-utils\n```\n\n### createContentDigest\n\nEncrypts an input using md5 hash of hexadecimal digest.\n\n```js\nconst { createContentDigest } = require(\"gatsby-core-utils\")\n\nconst options = {\n  key: \"value\",\n  foo: \"bar\",\n}\n\nconst digest = createContentDigest(options)\n// ...\n```\n\n### cpuCoreCount\n\nCalculate the number of CPU cores on the current machine\n\nThis function can be controlled by an env variable `GATSBY_CPU_COUNT` setting the first argument to true.\n\n| value           | description                                            |\n| --------------- | ------------------------------------------------------ |\n|                 | Counts amount of real cores by running a shell command |\n| `logical_cores` | `require(\"os\").cpus()` to count all virtual cores      |\n| any number      | Sets cpu count to that specific number                 |\n\n```js\nconst { cpuCoreCount } = require(\"gatsby-core-utils\")\n\nconst coreCount = cpuCoreCount(false)\n// ...\n```\n\n```js\nconst { cpuCoreCount } = require(\"gatsby-core-utils\")\nprocess.env.GATSBY_CPU_COUNT = \"logical_cores\"\n\nconst coreCount = cpuCoreCount()\n// ...\n```\n\n### joinPath\n\nA utility that joins paths with a `/` on windows and unix-type platforms. This can also be used for URL concatenation.\n\n```js\nconst { joinPath } = require(\"gatsby-core-utils\")\n\nconst BASEPATH = \"/mybase/\"\nconst pathname = \"./gatsby/is/awesome\"\nconst url = joinPath(BASEPATH, pathname)\n// ...\n```\n\n### isCI\n\nA utility that enhances `isCI` from 'ci-info` with support for Vercel and Heroku detection\n\n```js\nconst { isCI } = require(\"gatsby-core-utils\")\n\nif (isCI()) {\n  // execute CI-specific code\n}\n// ...\n```\n\n### getCIName\n\nA utility that returns the name of the current CI environment if available, `null` otherwise\n\n```js\nconst { getCIName } = require(\"gatsby-core-utils\")\n\nconst CI_NAME = getCIName()\nconsole.log({ CI_NAME })\n// {CI_NAME: null}, or\n// {CI_NAME: \"Vercel\"}\n// ...\n```\n\n### createRequireFromPath\n\nA cross-version polyfill for Node's [`Module.createRequire`](https://nodejs.org/api/modules.html#modules_module_createrequire_filename).\n\n```js\nconst { createRequireFromPath } = require(\"gatsby-core-utils\")\n\nconst requireUtil = createRequireFromPath(\"../src/utils/\")\n\n// Require `../src/utils/some-tool`\nrequireUtil(\"./some-tool\")\n// ...\n```\n\n### Mutex\n\nWhen 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](https://en.wikipedia.org/wiki/Mutual_exclusion) does.\n\nBy 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.\n\n```js\nconst { createMutex } = require(\"gatsby-core-utils/mutex\")\n\nconst mutex = createMutex(\"my-custom-mutex-key\")\nawait mutex.acquire()\n\nawait fs.writeFile(\"pathToFile\", \"my custom content\")\n\nawait mutex.release()\n```\n\n### Hashing\n\nParts of [`hash-wasm`](https://github.com/Daninet/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.\n\n```js\nconst { md5File, md5, createMD5, sha256, sha1 } = require(\"gatsby-core-utils\")\n\n// For md5, createMD5, sha256, sha1 refer to hash-wasm\nawait md5(`some-string`)\n\n// md5File gives you the MD5 hex hash for a given filepath\nawait md5File(`package.json`)\n```\n","publish_time":1769459232868,"_cnpm_publish_time":1769459232868,"dist-tags":{"alpha-9689ff":"3.23.0-alpha-9689ff.25","alpha-mdx-v2":"3.18.0-alpha-mdx-v2.68","alpha-qe-sm":"2.14.0-alpha-qe-sm.46","alpha-remote-fetch":"2.14.0-alpha-remote-fetch.79","alpha-remote-file":"2.10.0-alpha-remote-file.48","alpha-trailing-slash":"3.5.0-alpha-trailing-slash.71","alpha-transformer-json":"3.14.0-alpha-transformer-json.26","alpha-ts-jit":"3.6.0-alpha-ts-jit.27","alpha-v5":"4.0.0-alpha-v5.d20221012t101120.57","berry-mdx":"1.0.27-berry-mdx.56","coreutils":"2.12.0-coreutils.29","drupal-next":"2.14.0-drupal-next.94","drupal-proxyurl":"4.0.0-alpha-drupal-proxyurl.14","drupal-self-reference":"3.18.0-alpha-drupal-self-reference.18","functions-next":"2.4.0-functions-next.18","image-cdn":"3.9.0-alpha-image-service2.14","image-helpers":"1.5.0-image-helpers.58","image-service":"3.8.0-alpha-image-service.35","incbuild-collections":"1.3.16-incbuild-collections.159","latest":"4.16.0","latest-v3":"2.15.0","latest-v4":"3.25.0","mdxv4-rc":"3.20.0-mdxv4-rc.124","next":"4.17.0-next.0","otp-test":"1.0.7-otp-test.69","preview-gh-api":"3.23.0-alpha-preview-gh-api.26","prompt-restart":"1.1.2-prompt-restart.146","reach-router":"2.0.0-reach-router.13","telemetry-test":"1.5.0-telemetry-test.360","unifiedroutes":"1.1.3-unifiedroutes.76","v3rc":"2.0.0-v3rc.0","wp-image-cdn-auth":"3.15.0-alpha-wp-image-cdn-auth.45"}}