@ts-common/property-set
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -11,3 +11,11 @@ export declare type MapFunc<T, R> = <K extends keyof T>(v: T[K], k: K) => R; | ||
}; | ||
export declare const setMutableProperty: <T, K extends keyof T>(result: MutableOptional<T>, k: K, v: T[K] | undefined) => void; | ||
/** | ||
* Use this functions to assign optional properties. | ||
* The function will delete the property `k` if the given value is `undefined`. | ||
* | ||
* @param mutable an object | ||
* @param k a name of property | ||
* @param v a property value | ||
*/ | ||
export declare const setMutableProperty: <T, K extends keyof T>(mutable: MutableOptional<T>, k: K, v: T[K] | undefined) => void; | ||
export declare const create: <T>(factory: Factory<T>) => T; | ||
@@ -14,0 +22,0 @@ export declare type PartialFactory<T> = { |
14
index.js
@@ -11,9 +11,17 @@ "use strict"; | ||
const fromMutableOptional = (v) => v; | ||
exports.setMutableProperty = (result, k, v) => { | ||
/** | ||
* Use this functions to assign optional properties. | ||
* The function will delete the property `k` if the given value is `undefined`. | ||
* | ||
* @param mutable an object | ||
* @param k a name of property | ||
* @param v a property value | ||
*/ | ||
exports.setMutableProperty = (mutable, k, v) => { | ||
if (v !== undefined) { | ||
result[k] = v; | ||
mutable[k] = v; | ||
} | ||
else { | ||
// tslint:disable-next-line:no-dynamic-delete | ||
delete result[k]; | ||
delete mutable[k]; | ||
} | ||
@@ -20,0 +28,0 @@ }; |
{ | ||
"name": "@ts-common/property-set", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "A set of properties", | ||
@@ -35,11 +35,11 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@types/chai": "^4.1.5", | ||
"@types/chai": "^4.1.7", | ||
"@types/mocha": "^5.2.5", | ||
"chai": "^4.2.0", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.0.1", | ||
"nyc": "^13.1.0", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.1" | ||
"typescript": "^3.1.6" | ||
}, | ||
"dependencies": {} | ||
} |
# property-set | ||
A set of properties |
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
15085
75