@agile-ts/utils
Advanced tools
Comparing version 0.0.7 to 0.0.8
# @agile-ts/utils | ||
## 0.0.8 | ||
### Patch Changes | ||
- aae6455: #### :rocket: New Feature | ||
- `core`, `event`, `logger`, `multieditor`, `react`, `utils` | ||
- [#188](https://github.com/agile-ts/agile/pull/188) Tree shakeable support ([@bennodev19](https://github.com/bennodev19)) | ||
#### :nail_care: Polish | ||
- `core` | ||
- [#189](https://github.com/agile-ts/agile/pull/189) Optimize collection rebuilds ([@bennodev19](https://github.com/bennodev19)) | ||
- `api`, `core`, `cra-template-agile-typescript`, `cra-template-agile`, `event`, `logger`, `multieditor`, `proxytree`, `react`, `utils`, `vue` | ||
- [#187](https://github.com/agile-ts/agile/pull/187) Tree shakeable support ([@bennodev19](https://github.com/bennodev19)) | ||
#### Committers: 1 | ||
- BennoDev ([@bennodev19](https://github.com/bennodev19)) | ||
## 0.0.7 | ||
@@ -4,0 +24,0 @@ |
/** | ||
* @internal | ||
* Creates a fresh copy of an Array/Object | ||
* Creates a fresh (deep) copy of the specified value. | ||
* https://www.samanthaming.com/tidbits/70-3-ways-to-clone-objects/ | ||
* @param value - Array/Object that gets copied | ||
* | ||
* @public | ||
* @param value - Value to be copied. | ||
*/ | ||
export declare function copy<T = any>(value: T): T; | ||
/** | ||
* @internal | ||
* Checks if passed value is a valid Object | ||
* Checks whether the specified value is a valid object. | ||
* https://stackoverflow.com/questions/12996871/why-does-typeof-array-with-objects-return-object-and-not-array | ||
* @param value - Value that is tested for its correctness | ||
* @param considerArray - Whether Arrays should be considered as object | ||
* | ||
* @public | ||
* @param value - Value | ||
* @param considerArray - Whether to considered an array as an object. | ||
*/ | ||
export declare function isValidObject(value: any, considerArray?: boolean): boolean; | ||
/** | ||
* @internal | ||
* Check if array1 contains all elements of array2 | ||
* Checks whether 'array1' contains all elements of 'array2'. | ||
* | ||
* @public | ||
* @param array1 - Array 1 | ||
@@ -24,5 +27,6 @@ * @param array2 - Array 2 | ||
/** | ||
* @internal | ||
* Transforms Item/s to an Item Array | ||
* @param items - Item/s that gets transformed to an Array | ||
* Transforms Item/s into an array of Items. | ||
* | ||
* @public | ||
* @param items - Item/s to be transformed into an array of Items. | ||
* @param config - Config | ||
@@ -34,67 +38,80 @@ */ | ||
/** | ||
* @internal | ||
* Checks if value is a function | ||
* @param value - Value that gets tested if its a function | ||
* Checks whether the specified function is a function. | ||
* | ||
* @public | ||
* @param value - Value to be checked | ||
*/ | ||
export declare function isFunction(value: any): boolean; | ||
/** | ||
* @internal | ||
* Checks if value is an async function | ||
* @param value - Value that gets tested if its an async function | ||
* Checks whether the specified function is an async function. | ||
* | ||
* @public | ||
* @param value - Value to be checked. | ||
*/ | ||
export declare function isAsyncFunction(value: any): boolean; | ||
/** | ||
* @internal | ||
* Checks if value is valid JsonString | ||
* @param value - Value that gets checked | ||
* Checks whether the specified value is a valid JSON string | ||
* | ||
* @public | ||
* @param value - Value to be checked. | ||
*/ | ||
export declare function isJsonString(value: any): boolean; | ||
/** | ||
* @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 | ||
* Merges the default values object ('defaults') into the configuration object ('config'). | ||
* | ||
* @public | ||
* @param config - Configuration object to merge the default values in. | ||
* @param defaults - Default values object to be merged into the configuration object. | ||
* @param overwriteUndefinedProperties - Whether to overwrite 'undefined' set properties with default values. | ||
*/ | ||
export declare function defineConfig<ConfigInterface = Object>(config: ConfigInterface, defaults: Object, overwriteUndefinedProperties?: boolean): ConfigInterface; | ||
/** | ||
* @internal | ||
* @param addNewProperties - Adds new properties to source Object | ||
*/ | ||
export interface FlatMergeConfigInterface { | ||
/** | ||
* | ||
* Whether to add new properties (properties that doesn't exist in the source object yet) to the source object. | ||
* @default true | ||
*/ | ||
addNewProperties?: boolean; | ||
} | ||
/** | ||
* @internal | ||
* Merges items into object, be aware that the merge will only happen at the top level of the object. | ||
* Initially it adds new properties of the changes object into the source object. | ||
* Merges the 'changes' object into the 'source' object at top level. | ||
* | ||
* @public | ||
* @param source - Source object | ||
* @param changes - Changes that get merged into the source object | ||
* @param config - Config | ||
* @param changes - Changes object to be merged into the source object | ||
* @param config - Configuration object | ||
*/ | ||
export declare function flatMerge<DataType = Object>(source: DataType, changes: Object, config?: FlatMergeConfigInterface): DataType; | ||
/** | ||
* @internal | ||
* Check if two values are equal | ||
* @param value1 - First Value | ||
* @param value2 - Second Value | ||
* Checks whether the two specified values are equivalent. | ||
* | ||
* @public | ||
* @param value1 - First value. | ||
* @param value2 - Second value. | ||
*/ | ||
export declare function equal(value1: any, value2: any): boolean; | ||
/** | ||
* @internal | ||
* Checks if two values aren't equal | ||
* @param value1 - First Value | ||
* @param value2 - Second Value | ||
* Checks whether the two specified values are NOT equivalent. | ||
* | ||
* @public | ||
* @param value1 - First value. | ||
* @param value2 - Second value. | ||
*/ | ||
export declare function notEqual(value1: any, value2: any): boolean; | ||
/** | ||
* @internal | ||
* Generates random Id | ||
* @param length - Length of generated Id | ||
* Generates a randomized id based on alphabetic and numeric characters. | ||
* | ||
* @public | ||
* @param length - Length of the to generate id (default = 5). | ||
* @param characters - Characters to generate the id from (default = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'). | ||
*/ | ||
export declare function generateId(length?: number): string; | ||
export declare function generateId(length?: number, characters?: string): string; | ||
/** | ||
* @internal | ||
* Transforms Object to Array | ||
* @param object - Object that gets transformed | ||
* Transforms the specified object into an array. | ||
* | ||
* Example: | ||
* {"1": 'jeff', 2: 'frank'} -> [{key: "1", instance: 'jeff'}, {key: 2, instance: 'frank'}] | ||
* | ||
* @public | ||
* @param object - Object to be transformed to an array. | ||
*/ | ||
@@ -108,13 +125,15 @@ export declare function createArrayFromObject<P = any>(object: { | ||
/** | ||
* @internal | ||
* Clones a Class | ||
* @param instance - Instance of Class you want to clone | ||
* Clones the specified class. | ||
* | ||
* @public | ||
* @param instance - Class to be cloned. | ||
*/ | ||
export declare function clone<T = any>(instance: T): T; | ||
/** | ||
* @internal | ||
* Removes properties from Object | ||
* @param object - Object from which the properties get removed | ||
* @param properties - Properties that get removed from the object | ||
* Removes specified properties from the defined object. | ||
* | ||
* @public | ||
* @param object - Object to remove the specified properties from. | ||
* @param properties - Property keys to be removed from the specified object. | ||
*/ | ||
export declare function removeProperties<T = Object>(object: T, properties: Array<string>): T; |
@@ -113,8 +113,5 @@ "use strict"; | ||
exports.notEqual = notEqual; | ||
function generateId(length) { | ||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | ||
function generateId(length = 5, characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') { | ||
const charactersLength = characters.length; | ||
let result = ''; | ||
if (!length) | ||
length = 5; | ||
for (let i = 0; i < length; i++) { | ||
@@ -121,0 +118,0 @@ result += characters.charAt(Math.floor(Math.random() * charactersLength)); |
{ | ||
"name": "@agile-ts/utils", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"author": "BennoDev", | ||
@@ -14,6 +14,9 @@ "license": "MIT", | ||
"main": "dist/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc", | ||
"prepare": "tsc && tsc -p ./tsconfig.production.json", | ||
"build": "yarn run build:esm && yarn run build:cjs", | ||
"prepare": "yarn run build", | ||
"build:esm": "tsc -p ./tsconfig.esm.json", | ||
"build:cjs": "tsc -p ./tsconfig.json && tsc -p ./tsconfig.production.json", | ||
"dev:publish": "yalc publish", | ||
@@ -24,3 +27,4 @@ "dev:push": "yalc push", | ||
"release": "yarn run prepare", | ||
"preview": "npm pack", | ||
"release:manual": "yarn run prepare && yarn run release && npm publish", | ||
"pack": "npm pack", | ||
"test": "jest", | ||
@@ -45,3 +49,4 @@ "test:coverage": "jest --coverage", | ||
"CHANGELOG.md" | ||
] | ||
], | ||
"sideEffects": false | ||
} |
22645
7
411