@agile-ts/utils
Advanced tools
Comparing version 0.0.6 to 0.0.7
# @agile-ts/utils | ||
## 0.0.7 | ||
### Patch Changes | ||
- 2f2724f: #### :bug: Bug Fix | ||
- `core` | ||
- [#176](https://github.com/agile-ts/agile/pull/176) Fix persisting dynamically added items ([@bennodev19](https://github.com/bennodev19)) | ||
#### :nail_care: Polish | ||
- `api`, `core`, `event`, `logger`, `multieditor`, `react`, `utils` | ||
- [#177](https://github.com/agile-ts/agile/pull/177) Optimize default configurations ([@bennodev19](https://github.com/bennodev19)) | ||
#### Committers: 1 | ||
- BennoDev ([@bennodev19](https://github.com/bennodev19)) | ||
## 0.0.6 | ||
@@ -4,0 +22,0 @@ |
@@ -52,2 +52,10 @@ /** | ||
* @internal | ||
* Merges default values/properties into config object | ||
* @param config - Config object that receives default values | ||
* @param defaults - Default values object that gets merged into config object | ||
* @param overwriteUndefinedProperties - If undefined Properties in config gets overwritten by the default value | ||
*/ | ||
export declare function defineConfig<ConfigInterface = Object>(config: ConfigInterface, defaults: Object, overwriteUndefinedProperties?: boolean): ConfigInterface; | ||
/** | ||
* @internal | ||
* @param addNewProperties - Adds new properties to source Object | ||
@@ -54,0 +62,0 @@ */ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeProperties = exports.clone = exports.createArrayFromObject = exports.generateId = exports.notEqual = exports.equal = exports.flatMerge = exports.isJsonString = exports.isAsyncFunction = exports.isFunction = exports.normalizeArray = exports.includesArray = exports.isValidObject = exports.copy = void 0; | ||
exports.removeProperties = exports.clone = exports.createArrayFromObject = exports.generateId = exports.notEqual = exports.equal = exports.flatMerge = exports.defineConfig = exports.isJsonString = exports.isAsyncFunction = exports.isFunction = exports.normalizeArray = exports.includesArray = exports.isValidObject = exports.copy = void 0; | ||
function copy(value) { | ||
@@ -42,3 +42,5 @@ if (value == null || typeof value !== 'object') | ||
function normalizeArray(items, config = {}) { | ||
config = Object.assign({ createUndefinedArray: false }, config); | ||
config = defineConfig(config, { | ||
createUndefinedArray: false, | ||
}); | ||
if (items == null && !config.createUndefinedArray) | ||
@@ -72,4 +74,19 @@ return []; | ||
exports.isJsonString = isJsonString; | ||
function defineConfig(config, defaults, overwriteUndefinedProperties) { | ||
if (overwriteUndefinedProperties === undefined) | ||
overwriteUndefinedProperties = true; | ||
const shallowCopiedConfig = Object.assign({}, config); | ||
for (const defaultKey in defaults) { | ||
if (!Object.prototype.hasOwnProperty.call(shallowCopiedConfig, defaultKey) || | ||
(overwriteUndefinedProperties && | ||
shallowCopiedConfig[defaultKey] === undefined)) | ||
shallowCopiedConfig[defaultKey] = defaults[defaultKey]; | ||
} | ||
return shallowCopiedConfig; | ||
} | ||
exports.defineConfig = defineConfig; | ||
function flatMerge(source, changes, config = {}) { | ||
config = Object.assign({ addNewProperties: true }, config); | ||
config = defineConfig(config, { | ||
addNewProperties: true, | ||
}); | ||
const _source = copy(source); | ||
@@ -76,0 +93,0 @@ if (_source == null) |
{ | ||
"name": "@agile-ts/utils", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"author": "BennoDev", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
16808
267