@simplysm/sd-core-common
Advanced tools
Comparing version 12.5.19 to 12.5.20
@@ -70,2 +70,3 @@ import { Type } from "../types/Type"; | ||
remove(selector: (item: T, index: number) => boolean): this; | ||
toggle(item: T): this; | ||
clear(): this; | ||
@@ -72,0 +73,0 @@ } |
@@ -430,2 +430,11 @@ import { NeverEntryError } from "../errors/NeverEntryError"; | ||
}; | ||
prototype.toggle = function (item) { | ||
if (this.includes(item)) { | ||
this.remove(item); | ||
} | ||
else { | ||
this.push(item); | ||
} | ||
return this; | ||
}; | ||
prototype.clear = function () { | ||
@@ -432,0 +441,0 @@ return this.remove(() => true); |
declare interface Map<K, V> { | ||
getOrCreate(key: K, newValue: V): V; | ||
getOrCreate(key: K, newValueFn: () => V): V; | ||
update(key: K, updateFn: (v: V | undefined) => V): void; | ||
} |
"use strict"; | ||
((prototype) => { | ||
prototype.getOrCreate = function (key, newValue) { | ||
if (!this.has(key)) { | ||
if (newValue instanceof Function) { | ||
this.set(key, newValue()); | ||
} | ||
else { | ||
this.set(key, newValue); | ||
} | ||
Map.prototype.getOrCreate = function (key, newValue) { | ||
if (!this.has(key)) { | ||
if (newValue instanceof Function) { | ||
this.set(key, newValue()); | ||
} | ||
return this.get(key); | ||
}; | ||
})(Map.prototype); | ||
else { | ||
this.set(key, newValue); | ||
} | ||
} | ||
return this.get(key); | ||
}; | ||
Map.prototype.update = function (key, updateFn) { | ||
const val = this.get(key); | ||
const res = updateFn(val); | ||
this.set(key, res); | ||
}; | ||
//# sourceMappingURL=MapExtension.js.map |
{ | ||
"name": "@simplysm/sd-core-common", | ||
"version": "12.5.19", | ||
"version": "12.5.20", | ||
"description": "심플리즘 패키지 - 코어 모듈 (common)", | ||
@@ -5,0 +5,0 @@ "author": "김석래", |
@@ -125,2 +125,4 @@ import { Type } from "../types/Type"; | ||
toggle(item: T): this; | ||
clear(): this; | ||
@@ -812,2 +814,11 @@ } | ||
prototype.toggle = function <T>(this: T[], item: T): T[] { | ||
if (this.includes(item)) { | ||
this.remove(item); | ||
} else { | ||
this.push(item); | ||
} | ||
return this; | ||
}; | ||
prototype.clear = function <T>(this: T[]): T[] { | ||
@@ -814,0 +825,0 @@ return this.remove(() => true); |
@@ -5,17 +5,22 @@ declare interface Map<K, V> { | ||
getOrCreate(key: K, newValueFn: () => V): V; | ||
update(key: K, updateFn: (v: V | undefined) => V): void; | ||
} | ||
((prototype) => { | ||
prototype.getOrCreate = function <K, V>(this: Map<K, V>, key: K, newValue: V | (() => V)): V { | ||
if (!this.has(key)) { | ||
if (newValue instanceof Function) { | ||
this.set(key, newValue()); | ||
} | ||
else { | ||
this.set(key, newValue); | ||
} | ||
Map.prototype.getOrCreate = function <K, V>(this: Map<K, V>, key: K, newValue: V | (() => V)): V { | ||
if (!this.has(key)) { | ||
if (newValue instanceof Function) { | ||
this.set(key, newValue()); | ||
} else { | ||
this.set(key, newValue); | ||
} | ||
} | ||
return this.get(key)!; | ||
}; | ||
})(Map.prototype); | ||
return this.get(key)!; | ||
}; | ||
Map.prototype.update = function <K, V>(this: Map<K, V>, key: K, updateFn: (v: V | undefined) => V): void { | ||
const val = this.get(key); | ||
const res = updateFn(val); | ||
this.set(key, res); | ||
}; |
{ | ||
"extends": "../tsconfig.json", | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
@@ -4,0 +4,0 @@ "lib": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
296730
5666