@jest/create-cache-key-function
Advanced tools
Comparing version 29.4.3 to 29.5.0
@@ -9,5 +9,14 @@ /** | ||
/** | ||
* Returns a function that can be used to generate cache keys based on source code of provided files and provided values. | ||
* | ||
* @param files - Array of absolute paths to files whose code should be accounted for when generating cache key | ||
* @param values - Array of string values that should be accounted for when generating cache key | ||
* @param length - Length of the resulting key. The default is `32`, or `16` on Windows. | ||
* @returns A function that can be used to generate cache keys. | ||
*/ | ||
declare function createCacheKey( | ||
files?: Array<string>, | ||
values?: Array<string>, | ||
length?: number, | ||
): GetCacheKeyFunction; | ||
@@ -14,0 +23,0 @@ export default createCacheKey; |
@@ -38,3 +38,3 @@ 'use strict'; | ||
function getGlobalCacheKey(files, values) { | ||
function getGlobalCacheKey(files, values, length) { | ||
return [ | ||
@@ -51,5 +51,5 @@ process.env.NODE_ENV, | ||
.digest('hex') | ||
.substring(0, 32); | ||
.substring(0, length); | ||
} | ||
function getCacheKeyFunction(globalCacheKey) { | ||
function getCacheKeyFunction(globalCacheKey, length) { | ||
return (sourceText, sourcePath, configString, options) => { | ||
@@ -71,7 +71,20 @@ // Jest 27 passes a single options bag which contains `configString` rather than as a separate argument. | ||
.digest('hex') | ||
.substring(0, 32); | ||
.substring(0, length); | ||
}; | ||
} | ||
function createCacheKey(files = [], values = []) { | ||
return getCacheKeyFunction(getGlobalCacheKey(files, values)); | ||
/** | ||
* Returns a function that can be used to generate cache keys based on source code of provided files and provided values. | ||
* | ||
* @param files - Array of absolute paths to files whose code should be accounted for when generating cache key | ||
* @param values - Array of string values that should be accounted for when generating cache key | ||
* @param length - Length of the resulting key. The default is `32`, or `16` on Windows. | ||
* @returns A function that can be used to generate cache keys. | ||
*/ | ||
function createCacheKey( | ||
files = [], | ||
values = [], | ||
length = process.platform === 'win32' ? 16 : 32 | ||
) { | ||
return getCacheKeyFunction(getGlobalCacheKey(files, values, length), length); | ||
} |
{ | ||
"name": "@jest/create-cache-key-function", | ||
"version": "29.4.3", | ||
"version": "29.5.0", | ||
"repository": { | ||
@@ -10,7 +10,7 @@ "type": "git", | ||
"dependencies": { | ||
"@jest/types": "^29.4.3" | ||
"@jest/types": "^29.5.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "*", | ||
"jest-util": "^29.4.3" | ||
"jest-util": "^29.5.0" | ||
}, | ||
@@ -33,3 +33,3 @@ "engines": { | ||
}, | ||
"gitHead": "a49c88610e49a3242576160740a32a2fe11161e1" | ||
"gitHead": "39f3beda6b396665bebffab94e8d7c45be30454c" | ||
} |
@@ -13,5 +13,5 @@ # jest-create-cache-key-function | ||
### `createCacheKey(files?: Array<string>, values?: Array<String>): GetCacheKeyFunction` | ||
### `createCacheKey(files?: Array<string>, values?: Array<String>, length?: number): GetCacheKeyFunction` | ||
Get a function that can generate cache keys using source code, provided files and provided values. | ||
Returns a function that can be used to generate cache keys based on source code of provided files and provided values. | ||
@@ -22,2 +22,3 @@ #### Parameters | ||
- `values`: [Optional] Array of string values that should be accounted for when generating cache key | ||
- `length`: [Optional] Length of the resulting key. The default is `32`, or `16` on Windows. | ||
@@ -24,0 +25,0 @@ **Note:** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7438
128
47
Updated@jest/types@^29.5.0