Optional
isIf true, it will use isEqual
method of the objects (if they have one) for the ultimate decision of equality.
Optional
inheritedIf true, examine all (inherited) properties, not just own
Optional
exactIf true, then all VALUES that are refs must point to the same objects (i.e strict === equality), not lookalike clones! It checks only root items, no reason to go deeper!
Effectively, it checks for a shallow clone, rather than a deep one (note: _.isEquals
does deep only). You can have a clone oof the outer array/object/Set etc, but the values must be non-clones!
Optional
exactIf true
, then all KEY refs must point to the same objects (i.e strict === equality), not lookalike clones!
It is like exact
, but for KEYS:
Set
type has entries that are keys-only (i.e not values) and these can be object refs.Map
has keys that can be objects/references.The exactKeys
options applies only to these keys, not to the values or object symbol props
Note: default behavior is adopted from lodash:
_.isEqual(new Map([[{a:1}, 'one']]), new Map([[{a:1}, 'one'],])) // true
Optional
likeIf true, check only if all of the 1st arg's props are isEqual with the 2nd's, even if the 2nd arg has more properties.
For example, if a
is {a: 1}
and b
is {a: 1, b: 2}
, it will return true
.
Optional
pathIf you pass an array, it will become populated with the keys/indexes while objects/arrays are traversed. Useful for debugging (to see which prop path was the reason for non-equality)!
@todo: not working with ArrayBuffer & Error types
Optional
excludeIf you pass an array of Tany
, it will exclude those keys from the comparison.
@todo: if it is a Function, called with (key, val, ??), excludes key if true is returned (NOT IMPLEMENTED YET)
Optional
unboxAllows unboxing of Boxed Primitives (eg new Number(1)
& 1
are equal).
Optional
realIf true
, it will treat all objects as realObjects, even if they are not: Instances of any class & POJSOs are equal, if they have the same prop/values.
Optional
customizerThe customizer
function can be optionally passed as an options property.
If undefined
or if the function call returns undefined
, comparisons are handled by z.isEqual
.
The customizer can be the 3rd parameter (to maintain compatibility with lodash _.isEqualWith) and options can be the 5th, but you can pass customizer
and ctx
as properties of the options
object being the 3rd arg. But if you pass them in both places, it throws an Error.
The customizer type is TisEqualcustomizer
.
Optional
ctxThe this
binding (aka context) of customizer
. If undefined
, this
is bound to the global object. If ctx
is passed both as a property of the options
object, an as the 4rth arg, it will throw.
Optional
strictIf true, keys()
only allows values passing _.isObject()
/ (i.e non Primitives
), throws otherwise.
Note: in loop()
and map()
and other projection functions, strict
only allows isMany()
types, but in keys()
it is allowed for all Object types.
default: false
Optional
propsIf true
, consider ONLY the props, instead of Nested Keys for special objects (Arrays, TypedArrays, Maps & Sets) - mimics Object.keys()
/ _.keys()
if so.
By default, z.keys()
returns the "natural keys" for special objects with nested values:
Array
& TypedArray
(eg [0, 1, 2, 3, ...]
)Map
& Set
(eg ['someMapKey', {anObjectUsedAsKey: true}, Symbol('aSymbolKey')]
instead of their Object props.Similarly, all other functions like loop()
& map()
(that extend these options), iterate on those "natural keys" for all of these special objects.
For all other objects (including realObject
, all Iterators & Generators, Boxed Primitives etc),
string
/symbol
props are returned in keys()
loop()
and family, also depending on their other function-specific options.If props: true
then the keys()
& iterations are only against props, even for special objects, instead of Nested Keys.
This only affects the special objects: it makes no difference to non-special values, if props
is true
/false
, as their props are always considered anyway.
Note that Object.keys()
always returns props for ALL objects (i.e props: true
always), and there is no way to grab natural keys (or symbol props for that matter). This is a special feature of z.keys()
, and much more useful: why would you want the props of Map
or an Array
anyway, 99% of the time? But if you subclassed Array
or Map
and want to get the props of that instance (instead of their natural keys), then you use props: true
.
Finally, if props: 'all'
, you get both the props (first), followed by Nested Keys. Useful for print/debugging, comparisons etc.
@default: false / undefined
Optional
stringWhether to include normal string props
@default: true
Optional
symbolWhether to include Symbol props, when we're dealing with a realObject
or props: true
@default: false
Optional
ownWhether to include own object props.
Note: It refers to props only, not Nested Keys, for arrays specifically. We include naturalKeys (i.e array Indexes) even when { own: false, props: 'all' }
, to keep consistent with other Inspectable Nested Keys holders (Map & Set). But in realObjects, { own: false, props: any }
will return no own props, as it should.
@default: true
Optional
topIf true (and nonEnumerables
is also true), it includes top-level (i.e Object
) props like 'constructor', 'toString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString'
etc.
It also retrieves these hidden props (that have no types definitions): `'defineGetter', 'defineSetter', lookupGetter_', 'lookupSetter', 'proto'.
@default: false
Optional
hiddenIf hidden: true
(and nonEnumerables
& top
are also true), it includes top-level (i.e Object
) hidden props like `'defineGetter', 'defineSetter', lookupGetter_', 'lookupSetter', 'proto'. Note that these are hidden props, thus have no TypeScript definitions.
Also, if hidden: true
, it un-hides user/custom props that start & end with __
, eg __myHiddenProp__
(which are hidden otherwise by default) @todo(363): filter user/custom __hidden__
props in KeysT/Values types in typescript
Note: hidden
is a.k.a as private
in the JS/TS world, but we use hidden
to avoid confusion with the private
keyword in TS and possible different semantics. Will revisit in future versions.
@default: false
Optional
enumerablesWhether to include enumerable keys
Optional
nonWhether to include enumerable keys
Optional
dataWhen you loop()
over an ArrayBuffer
(or request keys()
or values()
), you must provide the dataViewType
option (eg Int16
, Float32
etc). The type of the items in the ArrayBuffer
is required by the internal DataView
that reads/writes to the ArrayBuffer.
Throws if dataViewType
is missing and z.type(input) === 'ArrayBuffer'
Options interface for
z.isEqual