Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (19 sloc) 547 Bytes
import isArray from "../isArray";
import isObject from "../isObject";
import objectCreate from "../objectCreate";
import ObjectFreezeFunction from "./ObjectFreezeFunction";
/**
* Object.freeze wrapper (returns a frozen copy of the object).
*
* @param target - Object to be frozen.
* @returns Frozen object.
*/
export const objectFreeze: ObjectFreezeFunction = target =>
isObject(target)
? Object.freeze(
isArray(target)
? ([...target] as typeof target)
: objectCreate(target)
)
: target;
export default objectFreeze;
You can’t perform that action at this time.