1.4.1 • Published 7 months ago

data-lube v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Data Lube

Simplify Data Manipulation in JavaScript

Working with complex data structures and ensuring data integrity can be challenging.
With "data-lube", a powerful JavaScript library, you can simplify the process of deep copying and deep freezing objects, helping you maintain data consistency and avoid unexpected changes.
This library offers easy-to-use functions such as deep copy and deep freeze, allowing you to work with data structures without worrying about unintended modifications.

installation

npm i data-lube
pnpm i data-lube
bun i data-lube

How to use

Easy deep copy

import { deepCopy } from "data-lube"

var origin = {
	a: [ 1, 2 ],
    d: new Date
	n: null,
	o: { k: "v" },
	s: "string",
	u: void 0
}
var clone: typeof origin = deepCopy(origin)

Easy comparison and type evaluation

import { deepEqual } from "data-lube"

var origin = {
	a: [ 1, 2 ],
	n: null,
	o: { k: "v" },
	s: "string"
} as const
var clone: any = JSON.parse(JSON.stringify(origin))
if (deepEqual(origin, clone)) {
    clone.a = [] // Cannot assign to 'a' because it is a read-only property.ts(2540)
}

Easy deep freeze

import { deepFreeze } from "data-lube"

var freezed = deepFreeze({
	a: [ 1, 2 ],
	n: null,
	o: { k: "v" },
	s: "string"
})
freezed.a = [] // Cannot assign to 'a' because it is a read-only property.ts(2540)

// @ts-ignore
freezed.a = [] // TypeError: Cannot assign to read only property 'a' of object '#<Object>'
1.4.1

7 months ago

1.4.0

7 months ago

1.3.0

8 months ago

1.2.0

8 months ago

1.1.2

8 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago