evilsoft / crocks

A collection of well known Algebraic Data Types for your utter enjoyment.
https://crocks.dev
ISC License
1.59k stars 102 forks source link

Adding support for Symbol properties #463

Open dalefrancis88 opened 4 years ago

dalefrancis88 commented 4 years ago

Describe the bug Symbols are valid keys for 'names' of properties on JavaScript objects. We should support it

Symbol Documentation

To Reproduce Steps to reproduce the behavior:

  1. Use hasProp with a Symbol property
  2. Pass in an object with a Symbol property on it
  3. Wait....
  4. See error

Expected behavior Should allow property accessors to be symbols

benhormann commented 4 years ago

I have made a start at implementing this.

There are many files to update.

So far:
Maybe/getPath.js
Maybe/getPath.spec.js
Maybe/getProp.js
Maybe/getProp.spec.js
Maybe/prop.spec.js
Maybe/propPath.spec.js
helpers/assoc.spec.js
helpers/dissoc.spec.js
helpers/getPathOr.js
helpers/getPathOr.spec.js
helpers/getPropOr.js
helpers/getPropOr.spec.js
helpers/propOr.spec.js
helpers/propPathOr.spec.js
helpers/setPath.js
helpers/setPath.spec.js
helpers/setProp.js
helpers/setProp.spec.js
helpers/unsetPath.js
helpers/unsetPath.spec.js
helpers/unsetProp.js
helpers/unsetProp.spec.js
predicates/hasProp.js
predicates/hasProp.spec.js
predicates/hasPropPath.js
predicates/hasPropPath.spec.js
predicates/hasProps.js
predicates/hasProps.spec.js
predicates/pathEq.js
predicates/pathEq.spec.js
predicates/pathSatisfies.js
predicates/pathSatisfies.spec.js
predicates/propEq.js
predicates/propEq.spec.js
predicates/propPathEq.spec.js
predicates/propPathSatisfies.spec.js
predicates/propSatisfies.js
predicates/propSatisfies.spec.js

For paths I have put this wording (affects related test): Non-empty Array of Non-empty Strings, Positive Integers and/or Symbols required ...

@evilsoft Is this fine, also is it worth making an isValidKey helper?

There is also objOf, fromPairs, defineUnion & pick. Should omit vaildate keys? Anything I missed?