@eslint-react/eff
Advanced tools
Comparing version
@@ -14,2 +14,4 @@ type Pretty<T> = { | ||
declare function getOrUpdate<K, V>(map: Map<K, V>, key: K, callback: () => V): V; | ||
declare function tryAddToSet<T>(set: Set<T>, value: T): boolean; | ||
type Reverse<T extends Record<any, any>> = { | ||
@@ -282,2 +284,2 @@ [U in keyof T as T[U]]: U; | ||
export { BiRecord, type NarrowedTo, type Pretty, _, birecord, dual, entries, flip, flow, fromEntries, identity, isArray, isObject, isTruthy, not, or, pipe, returnFalse, returnTrue, returnVoid }; | ||
export { BiRecord, type NarrowedTo, type Pretty, _, birecord, dual, entries, flip, flow, fromEntries, getOrUpdate, identity, isArray, isObject, isTruthy, not, or, pipe, returnFalse, returnTrue, returnVoid, tryAddToSet }; |
'use strict'; | ||
// src/collection.ts | ||
function getOrUpdate(map, key, callback) { | ||
if (map.has(key)) { | ||
return map.get(key); | ||
} | ||
const value = callback(); | ||
map.set(key, value); | ||
return value; | ||
} | ||
function tryAddToSet(set, value) { | ||
if (!set.has(value)) { | ||
set.add(value); | ||
return true; | ||
} | ||
return false; | ||
} | ||
function reverse(record) { | ||
@@ -201,2 +216,3 @@ return Object.fromEntries( | ||
exports.fromEntries = fromEntries; | ||
exports.getOrUpdate = getOrUpdate; | ||
exports.identity = identity; | ||
@@ -212,1 +228,2 @@ exports.isArray = isArray; | ||
exports.returnVoid = returnVoid; | ||
exports.tryAddToSet = tryAddToSet; |
{ | ||
"name": "@eslint-react/eff", | ||
"version": "1.24.0-next.2", | ||
"version": "1.24.0-next.3", | ||
"description": "JavaScript and TypeScript utilities (previously some re-exports of the effect library).", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Rel1cx/eslint-react", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
49984
2.05%714
5%