Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSPath modifies the input object when it contains an array, which is unexpected behaviour #33

Closed
alehmr opened this issue Feb 16, 2015 · 3 comments

Comments

@alehmr
Copy link

alehmr commented Feb 16, 2015

Please see attached image

image

Suite:

var chai = require('chai');
var expect = chai.expect;
var jsPath = require("jspath");


describe('jspath', function () {

    it('array', function () {
        var obj = {
            a: [
                {b: 1, c: {b: 2}},
                {n: 2}
            ]
        };

        expect(obj.a).to.have.length(2);
        var b = jsPath.apply("..*.b", obj);
        expect(b).to.have.length(2);
        expect(obj.a).to.have.length(2, 'jspath does not modify the input: ' + JSON.stringify(obj.a, null, '\t'));
    });

});
@dfilatov
Copy link
Owner

It's definitely a bug, I'll investigate it asap.

@dfilatov
Copy link
Owner

fixed in 0.3.1

@dfilatov
Copy link
Owner

@alehmr Thanks for report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants