New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

getorset-anything

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

getorset-anything - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

16

dist/index.d.ts

@@ -11,2 +11,3 @@ type KeyOfMap<M extends Map<unknown, unknown>> = M extends Map<infer K, unknown> ? K : never;

* const arr = mapGetOrSet(map, '123', () => [])
* // ↳ []
*

@@ -25,2 +26,3 @@ * arr.push('xyz')

* const arr = objGetOrSet(obj, '123', () => [])
* // ↳ []
*

@@ -31,3 +33,15 @@ * arr.push('xyz')

declare function objGetOrSet<O extends Record<string | number | symbol, unknown>, T extends () => O[keyof O]>(obj: O, key: keyof O, initialValue: T): ReturnType<T>;
/**
* Retrieve the value in an array, or if it wasn't found, set an initial value and return that.
*
* @example
* ```js
* const arr: number[] = []
*
* const val = arrGetOrSet(arr, 0, () => 123)
* // ↳ 123
* ```
*/
declare function arrGetOrSet<A extends unknown[], T extends () => A[number]>(arr: A, index: number, initialValue: T): ReturnType<T>;
export { mapGetOrSet, objGetOrSet };
export { arrGetOrSet, mapGetOrSet, objGetOrSet };

@@ -17,3 +17,11 @@ function mapGetOrSet(map, key, initialValue) {

}
function arrGetOrSet(arr, index, initialValue) {
let val = arr[index];
if (val === void 0) {
val = initialValue();
arr[index] = val;
}
return val;
}
export { mapGetOrSet, objGetOrSet };
export { arrGetOrSet, mapGetOrSet, objGetOrSet };

5

package.json
{
"name": "getorset-anything",
"version": "0.0.5",
"version": "0.1.0",
"description": "Gets a value from a Map/Obj or sets an initial value when not found and returns that. TypeScript supported.",

@@ -61,5 +61,2 @@ "type": "module",

"license": "MIT",
"bugs": {
"url": "https://github.com/mesqueeb/getorset-anything/issues"
},
"homepage": "https://github.com/mesqueeb/getorset-anything#readme",

@@ -66,0 +63,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc