Closed ariesshrimp closed 7 years ago
I feel like setDeep
would make more sense if its checks were reversed.
For example, if it worked like so:
if (not a valid collection) return fromArray()
return IndexedCollection.logic()
but I couldn't see a nice way of writing that. In other words, I think this is a case where the conditions should represent positive guards against the non-collection path, rather than confirming the happy path.
Also, I took this non-primitive-check trick from here: https://stackoverflow.com/questions/31538010/test-if-a-variable-is-a-primitive-rather-than-an-object
Is there a better way to do this using Typescript powers?
In @frptools/core
, there are the types concrete
and defined
, which are examples of how you'd do it in TypeScript.
You could write a function like this:
type Primitive = null|undefined|string|number|boolean|symbol;
function isConcrete(value: any): value is Primitive {
return value == Object(value); // tslint:disable-line
}
Thanks for the pull request, the code looks good to me!
New packages published.