mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-06-13 08:01:26 +00:00
NodeJs native binding 추가
This commit is contained in:
34
nodejs/lib/index.js
Normal file
34
nodejs/lib/index.js
Normal file
@ -0,0 +1,34 @@
|
||||
const { Compile, Selector, selectStr } = require('../native');
|
||||
|
||||
function compile(path) {
|
||||
let compile = new Compile(path);
|
||||
return (json) => {
|
||||
if(typeof json != 'string') {
|
||||
json = JSON.stringify(json)
|
||||
}
|
||||
return compile.template(json);
|
||||
};
|
||||
}
|
||||
|
||||
function selector(json) {
|
||||
if(typeof json != 'string') {
|
||||
json = JSON.stringify(json)
|
||||
}
|
||||
let selector = new Selector(json);
|
||||
return (path) => {
|
||||
return selector.selector(path);
|
||||
}
|
||||
}
|
||||
|
||||
function select(json, path) {
|
||||
if(typeof json != 'string') {
|
||||
json = JSON.stringify(json)
|
||||
}
|
||||
return selectStr(json, path);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
compile,
|
||||
selector,
|
||||
select
|
||||
};
|
Reference in New Issue
Block a user