Coder Social home page Coder Social logo

expr's People

Contributors

anaekin avatar corydeppen avatar jquense avatar radiosilence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

expr's Issues

getter doesn't work when key begins with a number

Here's an example of an issue similar to #2 where the property name begins with a number and results in SyntaxError: Invalid or unexpected token.

My specific use case is working with the yup library to validate a schema. I have a series of properties that begin with numbers (thanks, Salesforce). So given path = '00N40000002S5U0', the result of calling expr() is (data.00N40000002S5U0), which clearly won't work. Before taking a crack at a PR, I'd just like to understand if it's reasonable to think this library should be able to build a valid expression for cases like this?

getter doesn't work with non alphanumeric keys

You know we can have objects with keys with more than alphanumeric characters, like:

const externalIdentifier: 'FE43-D880-21AE';
const data = {
   [externalIdentifier]: true 
};

When we use the getter to access that id, it throws an error exception:

const getFn = getter(externalIdentifier);
console.log(getFn(data);

Error:

Uncaught ReferenceError: D880 is not defined
at eval (eval at getter (:26:43), :3:16)
at :1:1

Failed to compile issue

Getting Failed to compile during npm run build in my react app because of line 55 in index.js. I cannot use react-scripts as I am using a custom script. Suggested change - use of 'var' instead of 'let'.

Correct export in TS definition

I started to use bun by many reasons. and first notices that it throw error

viktord@blade:~/Projects/renthome/dashboard$ bun run build
$ vite build
vite v4.4.11 building for production...
✓ 1858 modules transformed.
✓ built in 8.21s
"getter" is not exported by "node_modules/property-expr/index.js", imported by "node_modules/yup/index.esm.js".
file: /home/viktord/Projects/renthome/dashboard/node_modules/yup/index.esm.js:1:9
1: import { getter, forEach, split, normalizePath, join } from 'property-expr';
            ^
2: import { camelCase, snakeCase } from 'tiny-case';
3: import toposort from 'toposort';
error during build:
RollupError: "getter" is not exported by "node_modules/property-expr/index.js", imported by "node_modules/yup/index.esm.js".
    at error (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
    at Module.error (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:13745:16)
    at Module.traceVariable (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:14175:29)
    at ModuleScope.findVariable (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:12615:39)
    at ChildScope.findVariable (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7124:38)
    at ClassBodyScope.findVariable (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7124:38)
    at ChildScope.findVariable (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7124:38)
    at FunctionScope.findVariable (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7124:38)
    at ChildScope.findVariable (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7124:38)
    at Identifier.bind (file:///home/viktord/Projects/renthome/dashboard/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:8319:40)
error: script "build" exited with code 1 (SIGHUP)

image

I am also using nodejs v20
I think we already have PR to fix it
https://github.com/jquense/expr/pull/16/files
How can I assist to merge this PR?

Not compatible with strict CSP due to `new Function(..)`

Hi,

I'm using react-formal with yup, and while hardening my app's CSP rules to drop unsafe-eval (reference), I'm seeing explosions because this library uses new Function(...) which isn't allowed with that kind of CSP setup.

Any chance doing something else here instead, to make this compatible with stricter CSP rules (which are assumably becoming more common)?

Currently I'm not seeing good ways around this in my end, seems that I need to choose between dropping react-formal and yup or to live with unsafe-eval in CSP (and justify that to the party evaluating the security of my app).

Support selecting into arrays

It would be useful to be able to select into arrays, eg. people[].name or people[*].name to get an array of the contents all the name properties of objects in the people array.

I am currently working on a custom validator for yup that will need to read the the a name property from an object array to validate some other fields in the form. I have ideas on how to work around this, but it would be useful to be be able to simple to do this using a Ref

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.