Repository navigation
Releases: andreww2012/utilery
Release list
utilery@0.3.0
Minor Changes
-
2ffeb62- Added newpathExists,readJsonFileSafeandreadFilesInDirectorySafeserver utilities: check whether a path exists, and read a JSON file or all files of a directory, gettingnullwhen it does not exist -
07e9ad8- Added new string utilities:levenshteinDistanceandfindClosestString(levenandclosestMatchfromleven)substringBefore,substringAfter,substringBeforeLastandsubstringAfterLastunquoteandstringByteLengthdecodeUriComponentSafe(decodeUriComponentfromdecode-uri-component) andsplitOutsideQuotes(splitfromsplit-string)
-
02db2b7- Added newfindExecutableandfindExecutableSyncutilities (whichfromwhich, givingundefinedinstead of throwing), a newquoteShellArgumentutility (quoteForShellfrompuka) and a newisProcessAliveutility -
1d699b1-colorsreturns plain text when colors are not supported (output that is not a terminal,NO_COLOR,FORCE_COLOR=0), and a newisColorSupportedutility tells whether they are -
5c043e8- Added a newsemvergroup for semantic versions:compareSemver,isSemverInRange,isValidSemverandparseSemver(compare,satisfies,isValidandtryParsefromverkit), and theParsedSemvertype -
14f9bbc- Added a newbitwisegroup for bit flags and other bit manipulation of 32-bit integers. Bit indexes are typed asBitIndex(an integer from 0 to 31), so out-of-range literals and enum members fail at compile time, andisBitIndexchecks dynamic numbers:BitIndex,isBitIndex,isBitSetandindexesOfSetBits- from
@thi.ng/binary:setBit(bitSet, orbitClearwhenfalseis passed)clearBit(bitClear)toggleBit(bitFlip)countSetBits(popCount)countTrailingZeroBits(ctz32)rotateBitsLeft(rotateLeft) androtateBitsRight(rotateRight)toInt32(u32i32) andtoUint32(i32u32)
-
54f7fff- Added a newcreateSeededRandomutility: a seededMath.randomreplacement from a number or a string seed, for reproducible results -
9db3b5c- Added a newglobgroup:globToRegex,isGlobMatchandisGlobPattern(makeRe,isMatchandscanfrompicomatch), andcreatePathFilter, a filter fromincludeandexcludepatterns -
161bee0- Added a newgetBuiltinModuleutility: a typedprocess.getBuiltinModulethat givesundefinedoutside Node.js -
80150d3- Renamed the package from@andreww2012/unutilstoutilery, so install it and import fromutileryinstead -
a6d367d-arrayShuffle,arraySample,random,randomIntInclusiveandrandomIntExclusiveget arandomoption for another generator, like one fromcreateSeededRandom -
d8b0c25- Added a newparseNpmPackageSpecifierutility (parsefromparse-package-name) that splits a specifier like@scope/package@1.2.3/sub/pathinto the name, the version and the path -
2eb3659-createSingletonPromiseno longer keeps a rejection by default, so the next call tries again (pass{cacheRejections: true}for the old behavior), and gets attlMsoption -
8de06c0- Added new utilities:downloadFilein a newbrowsergroup: saves a string, bytes, aBlob, afetchresponse or a stream as a file, like a download link, or through a "Save as" dialog in browsers that support itformatDateForFileName: formats a date and time for file names, like2026-10-25_14-30-05, with a choice of precision, UTC and separators
-
42e7cec- Added newfindUpandfindUpSyncutilities (findUpandfindUpSyncfromfind-up-simple) that find a file or directory in parent directories, and a newisPathInsideutility -
60b94fa- Added a newsleepAbortableutility: likesleep, but rejects with the reason of the aborted signal and has anunrefoption to not keep the Node.js process alive -
83b38c1- Added newgetErrorMessageandinteropDefaultutilities: get a message from a caught value of any type, and resolve a module (or a dynamicimport()) to its default export when it has one -
32e6ccc- Updatedremedafrom v2.51.0 to v2.53.0, which affected:arrayMapWithAccumulator:- BREAKING: the callback now gets the source array as its fourth argument instead of the elements processed so far
-
5951301- Added newstripAnsi,getStringWidthandwrapTextutilities (stripAnsi,stringWidthandwrapAnsifromstrip-ansi,string-widthandwrap-ansi): remove ANSI escape codes, measure the terminal width of a string and wrap styled text -
22b4cae- Added a newMaybeReadonlyArraytype: a value or a readonly array of it.generateMailtoLinknow uses it, so its recipient options also accept readonly arrays -
22b4cae- Added a newisArrayutility fromremeda: unlikeArray.isArray, it also narrows readonly arrays -
23be320-omit: a*deep path segment now matches every element of an array or property of an object, e.g.users.*.passwordremovespasswordfrom every user. Deep paths also no longer mutate the input when they go through an array, e.g.omit(object, ['users.0.password']) -
4d59645- Added a newpathgroup for file paths on any platform, withisSafeRelativePathandparseNodeModulesPath.toForwardSlashesmoved there fromstring, so import it fromutilery/pathinstead ofutilery/string -
03565c6- Added newisPromiseLike,isValidDateandisUnsafeObjectKeyutilities -
5d9e54f- Added a newtopologicalSortutility (toposort.arrayfromtoposort) and theCyclicDependencyErrorit throws for a ...
v0.2.0
Minor Changes
-
47be3d5Thanks @andreww2012! - Narrowed the supported Node.js versions to^22.23.1 || ^24.18.0 || >=26.4.0(was^22.23.1 || >=24) and exportedpackage.jsonas/package.jsonsubpath -
9fe6fdbThanks @andreww2012! - Added the following new utilities fromms-tspackage:ms(miscgroup)Ms(typesgroup)
-
2fecdafThanks @andreww2012! - Added a newmisc/generateMailtoLinkutility -
ca6a52cThanks @andreww2012! - Added a newarray/arrayHasMaxElementsutility - the "at most" counterpart toarray/arrayHasMinElements- together with thetypes/ArrayWithMaxLengthtype powering its narrowing -
280d41eThanks @andreww2012! - Added the following new utilities fromtyped-query-selectorpackage, belonging to the newdomgroup:querySelectorTypedquerySelectorAllTypedclosestTypedElementFromSelector(type)ElementFromSelectorStrict(type)ElementFromTagName(type)
Added two opt-in side-effect entrypoints that type the native DOM lookup methods from the selector:
unutils/dom/query-selector-typed.globalunutils/dom/query-selector-typed-strict.global
You should import at most one of the two.
-
19ad83aThanks @andreww2012! - Added the following new utilities fromnanoidpackage, belonging to the newidgroup:nanoidnanoidFactoryNANOID_URL_ALPHABET(constant)
-
625e1a3Thanks @andreww2012! - Added two newmaputilities that mirror the nativeMap#getOrInsertandMap#getOrInsertComputedmethods, which are not yet widely available:mapGetOrInsert- returns the value stored under a key, inserting an eagerly built default first when the key is missingmapGetOrInsertComputed- the lazy counterpart, building the default only on a miss
Both return a non-optional value, so
mapGetOrInsertComputed(map, key, () => []).push(item)replaces the usual read-check-insert dance. -
2c764a4Thanks @andreww2012! - Updatedtype-festfrom v5.8.0 to v5.10.0:- Added
RenameKeys(as-is) andMaxNumberInUnion(renamed fromUnionMax) utilities
- Added
-
17d62efThanks @andreww2012! - Updatedes-toolkitfrom v1.49.0 to v1.52.0:- Added the following utilities:
objectgroup:freezeDeep(renamed fromdeepFreeze)mapKeysAsync(as-is)mapValuesAsync(as-is)
functiongroup:flowAsync(flowAsyncfromes-toolkit/fp, taking the functions as an array likeflow)toDisposable(consolidatesdeferanddeferAsync)
iterablegroup, from the newes-toolkit/iteratorentrypoint (all of them accept any iterable, not only iterators):generateSequence(renamed fromiterate)iterableCartesianProduct(renamed fromcartesianProduct)iterableChunks(renamed fromchunk)iterableCount(renamed fromcount)iterableDropWhile(renamed fromdropWhile)iterableFirst(renamed fromhead)iterablePartition(renamed frompartition)iterableRange(renamed fromrange)iterableScan(renamed fromscan)iterableTakeWhile(renamed fromtakeWhile)iterableTranspose(renamed fromzip)iterableUnique(renamed fromuniqBy)
mathgroup, from the newes-toolkit/bigintentrypoint:bigintMedian(consolidatesmedianandmedianBy)bigintPercentile(renamed frompercentile)bigintSum(consolidatessumandsumBy)
- The following utilities now also accept bigints, consolidated with their counterparts from the new
es-toolkit/bigintentrypoint: toConstantCaseKeysDeep,toKebabCaseKeysDeepandtoPascalCaseKeysDeepare now based on the newtoConstantCaseKeys,toKebabCaseKeysandtoPascalCaseKeys: non-ASCII letters are no longer treated as word boundaries, and class instances are kept as-is
- Added the following utilities:
-
3c743b5Thanks @andreww2012! - Updateddevaluefrom v5.8.1 to v6.0.2Added the following new utilities from
devaluepackage (jsongroup):structuredStringifyAsync(renamed fromstringifyAsync) - the promise-awaiting counterpart ofstructuredStringifyStructuredStringifyError(renamed fromDevalueError) - thrown bystructuredStringifyandstructuredStringifyAsyncstructuredFilterArrayIndexes(renamed fromfilterArrayIndices) - for customStructuredStringifyOperationsSTRUCTURED_STRINGIFY_DEFAULT_OPERATIONS(constant, renamed fromdefaultStringifyOperations) - defaultoperationsofstructuredStringifyandstructuredStringifyAsyncSTRUCTURED_PARSE_DEFAULT_OPERATIONS(constant, renamed fromdefaultParseOperations) - defaultoperationsofstructuredParseStructuredStringifyOptions(type, renamed fromStringifyOptions) - options ofstructuredStringifyandstructuredStringifyAsyncStructuredStringifyOperations(type, renamed fromStringifyOperations) -operationsoption ofstructuredStringifyandstructuredStringifyAsyncStructuredParseOptions(type, renamed fromParseOptions) - options ofstructuredParseStructuredParseOperations(type, renamed fromParseOperations) -operationsoption ofstructuredParse
Patch Changes
-
4154dfdThanks @andreww2012! - Updatednanoidfrom v6.0.1 to v6.0.2 -
36aec3bThanks @andreww2012! - Updatedarkregexfrom v0.0.8 to v0.0.12 -
9de1274Thanks @andreww2012! - FixedjsonParseAsyncandjsonStringifyAsync:jsonParseAsyncno longer rejects every input withReferenceError: chunk is not definedjsonStringifyAsyncnow matchesJSON.stringifyin more cases:- nested objects and arrays are indented correctly with
space spaceis limited like inJSON.stringify: strings are cut to 10 characters, and numbers are truncated- values with
toJSON(likeDate) no longer get extra whitespace, and the replacer gets them aftertoJSONis called - the replacer gets array indexes as strings, and a replacer array accepts numbers and skips duplicates
- control characters are escaped
- nested objects and arrays are indented correctly with
jsonStringifyAsyncnow respectsintensityinstead of always using1- Concurrent
jsonStringifyAsynccalls no longer mix up long strings or fail with "Circular Structure Detected"
v0.1.0
Minor Changes
-
68b46d2:
Nullable: new type utility that wides the given type withnullandundefined -
b16aa66: Updated
es-toolkitfrom v1.47.1 to v1.49.0:arrayChunksnow accepts a function as the second parameter, usingchunkByfromes-toolkit/fpin this case
-
6afcd0e: Updated
ts-extrasfrom v1.0.0 to v1.2.0:- Added
object/object{Assign,Update}utilities as-is
- Added
-
df7f800: Updated
type-festfrom v5.7.0 to v5.8.0:- Added
ExtractExactly,StringLength,StringToArrayandStringToNumberutilities as-is
- Added
-
fb67815:
Falsy,Truthy: new type utilities to represent "falsy" and "truthy" runtime values respectively, to the degree TypeScript allows that -
8ef2d03: Added a new group of object traversing utilities (called
traverse) fromneotraversepackage:traverse{Every,Filter,Find,ForEach,Map,Nodes,Paths,Reduce,Some}
Patch Changes
v0.0.1
Patch Changes
- 901b105: Initial release.