@ukon1990/js-utilities
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -8,4 +8,4 @@ import { Difference } from "../models/difference.model"; | ||
private static cloneField; | ||
static isEqual(object1: Object, object2: Object): boolean; | ||
static isEqual(object1: object, object2: object): boolean; | ||
static getDifference(object1: object | any, object2: object | any, ignoreFields?: any): Array<Difference>; | ||
} |
@@ -48,11 +48,11 @@ "use strict"; | ||
} | ||
static cloneField(object, key, obj) { | ||
static cloneField(object, key, targetObject) { | ||
if (array_util_1.ArrayUtil.isArray(object[key])) { | ||
obj[key] = array_util_1.ArrayUtil.clone(object[key]); | ||
targetObject[key] = array_util_1.ArrayUtil.clone(object[key]); | ||
} | ||
else if (ObjectUtil.isObject(object[key])) { | ||
obj[key] = ObjectUtil.clone(object[key]); | ||
targetObject[key] = ObjectUtil.clone(object[key]); | ||
} | ||
else { | ||
obj[key] = object[key]; | ||
targetObject[key] = object[key]; | ||
} | ||
@@ -59,0 +59,0 @@ } |
{ | ||
"name": "@ukon1990/js-utilities", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A light weight package for object and array manipulation. As well as some utilities for matching text.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# Javascript utilities | ||
This is a small package with some utilities. | ||
More description inc later. | ||
## ObjectUtil | ||
* `isObject(value)` - Checks if a value is an object and not array | ||
* `overwrite(fromObject, toObject)` - Replaces all the values of one objects with another object | ||
* `clone(object)` - Returns a cloned version of an object. Removing all child object references. | ||
* `isEqual(object1, object2)` - Checks if two objects are equal regardless of object reference. | ||
* `getDifference(object1, object2)` - Returns an array of object differences as `Difference` objects. | ||
## ArrayUtil | ||
* `isObject(value)` - Checks if a value is an object and not array | ||
* `overwrite(fromArray, toArray)` - Replaces all the values of one array with another array | ||
* `clone(array)` - Returns a cloned version of an array. Removing all child object references. | ||
* `isEqual(array1, array2)` - Checks if two arrays are equal regardless of object reference. | ||
* `getDifference(array1, array2)` - Returns an array of differences as `Difference` objects. | ||
## TextUtil | ||
* `getMatchingParts(string, stringToFind)` - | ||
Returns a Match object. The Match object for `getMatchingParts('Chicken', 'ck')` | ||
looks like this `{start: 'Chi', match: 'ck', end: 'en'}`. | ||
* `getIndexOf(sourceString, targetString)` - Is basically `sourceString.toLowerCase().indexOf(targetString.toLowerCase)` | ||
* `contains(sourceString, targetString)` - Checks if a string exists within another. This is case-insensitive. | ||
* `isLowerCase(string)` - Checks if a string is upper or lowercase. |
@@ -51,13 +51,13 @@ import {EmptyUtil} from "./empty.util"; | ||
private static cloneField(object: any, key: string, obj: any) { | ||
private static cloneField(object: any, key: string, targetObject: any) { | ||
if (ArrayUtil.isArray(object[key])) { | ||
obj[key] = ArrayUtil.clone(object[key]); | ||
targetObject[key] = ArrayUtil.clone(object[key]); | ||
} else if (ObjectUtil.isObject(object[key])) { | ||
obj[key] = ObjectUtil.clone(object[key]); | ||
targetObject[key] = ObjectUtil.clone(object[key]); | ||
} else { | ||
obj[key] = object[key]; | ||
targetObject[key] = object[key]; | ||
} | ||
} | ||
public static isEqual(object1: Object, object2: Object): boolean { | ||
public static isEqual(object1: object, object2: object): boolean { | ||
return ObjectUtil.getDifference(object1, object2).length === 0; | ||
@@ -64,0 +64,0 @@ } |
65627
15
25