1
0
mirror of https://github.com/dzeiocom/libs.git synced 2025-06-16 04:29:21 +00:00

Add objectOmit function

- also bump deps (not parcel because 2 is not the way I want to continue using it)

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
2021-09-28 11:47:33 +02:00
parent ffaf544d10
commit cb97ded195
5 changed files with 1467 additions and 2407 deletions

View File

@ -1,6 +1,6 @@
/// <reference types="jest" />
import { objectSize, objectMap, objectSort, objectEqual, objectKeys, objectSet, objectLoop, objectClone, objectValues, objectClean, isObject } from '../src/ObjectUtil'
import { objectSize, objectMap, objectSort, objectEqual, objectKeys, objectSet, objectLoop, objectClone, objectValues, objectClean, isObject, objectOmit } from '../src/ObjectUtil'
describe('Throw if parameter is not an object', () => {
it('should works', () => {
@ -252,6 +252,22 @@ describe('Object Clean Tests', () => {
objectClean(obj)
expect(obj).toEqual({a: '', b: null, d: {da: '', db: null}})
})
it('should clean deep when set', () => {
const obj = {a: '', b: null, c: undefined, d: {da: '', db: null, dc: undefined}}
objectClean(obj, {deep: true})
expect(obj).toEqual({a: '', b: null, d: {da: '', db: null}})
})
})
describe('Object Omit Tests', () => {
it('should omit certain elements', () => {
const obj = {a: 'a', b: 'c', c: 'b'}
expect(objectOmit(obj, 'b')).toEqual({a: 'a', c: 'b'})
})
it('should not care when key to omit is not present', () => {
const obj = {a: 'a', b: 'c', c: 'b'}
expect(objectOmit(obj, 'b', 'd')).toEqual({a: 'a', c: 'b'})
})
})
describe('Is Object Tests', () => {