koajs / json-filter

Middleware allowing the client to filter the response to only what they need, reducing the amount of traffic over the wire.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with object creation

sajumani opened this issue · comments

TypeError: simpleJSONFilter is not a constructor

//code.jquery.com/jquery-1.11.3.min.js
//require.js

var simpleJSONFilter;

define(function (require) {
simpleJSONFilter = require('index.js');
});
var sjf = new simpleJSONFilter();

var data = {
one: {
    id: 1,
    name: 'Hiro Protagonist',
    age: 27
},
two: {
    id: 2,
    name: 'Y.T.',
    age: 16
},
three: {
    id: 3,
    name: 'Raven',
    age: 40,
},
four: {
    id: 4,
    name: 'Uncle Enzo',
    age: 80
},
five: {
    id: 5,
    name: 'Fisheye',
    age: 50
}

};

var filter = {id: 1};
var result = sjf.exec(filter, data); // Returns {one: {id: 1,name: 'Hiro Protagonist',age: 27}}

console.log(result);

i did with Jquery Grep function