OptionalstrictIf 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
OptionalpropsIf 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
OptionalstringWhether to include normal string props
@default: true
OptionalsymbolWhether to include Symbol props, when we're dealing with a realObject or props: true
@default: false
OptionalownWhether 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
OptionalinheritedIf true, it walks the prototype chain & retrieves all keys of inherited objects.
@default: false
OptionaltopIf 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
OptionalhiddenIf 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
OptionalenumerablesWhether to include enumerable keys
OptionalnonWhether to include enumerable keys
OptionaldataWhen 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.keys