Giter Site home page Giter Site logo

jsedn's People

Contributors

douglasxtaylor avatar epoberezkin avatar kwijibo avatar nberger avatar shaunxcode avatar yveslange avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar

jsedn's Issues

remove underscore dep

Should not require underscore, only used minimally anyway so should not be a huge deal to remove.

setTokenAction for tagged

The regex you have is looking for anything that starts with a #, so when you setTokenAction for 'tagged', it also will mutate Sets since they also begin with a #

Quote escaping problem

When using encode on the result of JSON.stringify, the quote escaping seems to be thrown off.

$ node
> JSON.stringify({a:1});
'{"a":1}'
> JSON.stringify({a:"1"});
'{"a":"1"}'

> var edn = require('jsedn');
> edn.encode(JSON.stringify({a:1}));
'"{"a":1}"'
> edn.encode(JSON.stringify({a:"1"}));
'"{"a":"1"}"'

> edn.parse(edn.encode(JSON.stringify({a:1})));
unexpected end of list
> edn.parse(edn.encode(JSON.stringify({a:"1"})));
unexpected end of list

add support for meta

the ruby edn reader supports meta information, it would not be hard to add this but need to clarify with edn spec if this is going to be officially supported or not.

Considering query variables as keywords

I am calling edn.encode [':find', '?m', ':where', ['?m', ':movie/title']] trying to get '[:find ?m :where [?m :movie/title]]'

but '?m' turns into "?m" because is recognized as a regular string

I get around by changing the keyword matcher to keyword: pattern: /^[\:\?].*$/

require fails in webpack due to node imports

Module not found: Error: Can't resolve 'fs' in '/home/brian/tmp/XenaGoWidget/node_modules/jsedn/lib'
 @ ./node_modules/jsedn/lib/reader.js 275:9-22
 @ ./node_modules/jsedn/index.js
 @ ./src/XenaGoApp.js
 @ ./demo/src/index.js
 @ multi ./node_modules/nwb/polyfills.js (webpack)-dev-server/client?/ (webpack)/hot/only-dev-server.js ./demo/src/index.js
Module not found: Error: Can't resolve 'type' in '/home/brian/tmp/XenaGoWidget/node_modules/jsedn/lib'
 @ ./node_modules/jsedn/lib/type.js 3:105-120
 @ ./node_modules/jsedn/lib/reader.js
 @ ./node_modules/jsedn/index.js
 @ ./src/XenaGoApp.js
 @ ./demo/src/index.js
 @ multi ./node_modules/nwb/polyfills.js (webpack)-dev-server/client?/ (webpack)/hot/only-dev-server.js ./demo/src/index.js

Using Jest test suite, unable to find type module

I started migrating my test suite from Mocha to Jest for a web server and I use jsedn in some places.

When I made the change, it threw an error that it cannot find module type.

Jest automatically provides a global object window that make support for FrontEnd testing in Node.js but I guess it does not automatically provide type module.

I think it's not sufficient to test whether global object window is available to assume type module is also directly available (in src/type.coffee). Maybe, you'd like to use type-component uniformly throughout the entire project, I don't know which one would be the best solutions for this.

toJS returns edn string

I have the following edn string:

var edn = '{"items" [{"title" "Test" "type" "test"}]}'

When I use jsedn.toJS(edn) I just get the edn string back instead of a JavaScript object

Parsing Array as Vectors

When I do new Vector([':a', 'b']).ednEncode() i get '[::a :b]' instead of [:a 'b'] ... In essence it is adding : to every string without spaces. How could I avoid that?

Ty very much

Default encode js array to vector

I haven't thought thru this much ... But i keep running into this kind of problem

edn.encode [':db/add', 42, ':col/field', 'value'] returns (:db/add, 42, :col/field, "value")

In the cases so far I was looking for [:db/add, 42, :col/field, "value"]

I can hack it on ..

encode = ....

    else if us.isArray obj
        ...
        "[#{result.join " "}]"

But I was wondering if the default makes sense and/or if some opts would be reasonable ... or if it doesn't make sense at all :)

Remove compiled JS code from repo

Current version of coffee-script compiles code very differently - there are a lot of changes that would create noise in PRs. A more common approach is to only publish compiled code to npm, but not to have it in the repo

< and > not handled correctly in symbols.

Version 0.4.0
Tested on macOS Sierra v. 10.12.5

Trying to parse repl-test.core/foo->bar results int the following error:

provided an invalid symbol repl-test.core/foo->bar

I notice that this is a result of failing to match the following regex (atoms.coffee) in the Symbols class:

validRegex: /[0-9A-Za-z.*+!\-_?$%&=:#/]+/

This regex does not contain < or >.

Read me example throws error

This example from the readme:

edn.parse("{:x 300 y: 800}").map(function(val, key){
	return new edn.Pair(edn.kw("#{key}-squared"), val * val);
});

Throws Error: keyword must start with a :

Valid keyword fails to parse

Using jsedn 0.4.1, I get an error thrown when a keyword contains the ">" character. This is a valid EDN keyword as per the EDN spec.

Symbols begin with a non-numeric character and can contain alphanumeric characters and . * + ! - _ ? $ % & = < >.

Example failing case.

const edn = require("jsedn");
edn.parse("{:a->b 1}")
Uncaught 'provided an invalid symbol :a->b'

Don't Evaluate Tags

This:

jsedn.encode(jsedn.unify('{:uuid #uuid ?a}',{a: "ac24e310-703e-11e5-92c2-d57ad6a6c940"}))

results in

"{:uuid "ac24e310-703e-11e5-92c2-d57ad6a6c940"}"

but I'm trying to get back

"{:uuid #uuid "ac24e310-703e-11e5-92c2-d57ad6a6c940"}"

So how should I go about keeping the tag in the output?

Keywords and symbols

You mention that the choice is to convert a string into a keyword if possible, but it's not consistently so. Here the key "name" becomes a keyword, but the value "walter" doesn't, unless I prepend with a colon:

> edn.encode(new edn.Tagged(new edn.Tag("myApp", "Person"), {"name": "walter", age: 300}));
'#myApp/Person {:name "walter" :age 300}'
> edn.encode(new edn.Tagged(new edn.Tag("myApp", "Person"), {"name": ":walter", age: 300}));
'#myApp/Person {:name :walter :age 300}'

Also, how do I get a symbol from a js string key?

> edn.encode({a:1});
'{:a 1}'
> edn.encode({"a":1});
'{:a 1}'
> edn.encode({":a":1});
'{::a 1}'
> edn.encode({"?a":1});
'{:?a 1}'

Readme example for setTokenPattern seems incomplete

Hi there, I was reading the documentation and stumbled upon this.
Not sure if it's intended, but right now one of the examples just reads:

edn.setTokenPattern()))

The text above it also doesn't make it super clear what it's about.

move classes to support, allow dep injection to use other hash_map etc. e.g. mori

It would be nice to move out the support classes for hash_map, vector etc. so that jsedn is mainly the reader and the underlying implementations can be changed easily. Technically this can be done already by just doing edn.Map = MyOtherMap so really this is just about breaking out the default implementations into their own file so that in theory one could build a version w/o them that would utilize mori or the es6 hashmap etc.

Mistakes in conversion table

Seems the jsedn column in the conversion table in readme has some problems. The constructors take collections, but the List and Vector examples do not. Don't think those examples work. The example for Set is missing some commas, so that doesn't work either.

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.