@port-labs/jq-node-bindings 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +77 -0
- package/index.d.ts +1 -1
- package/package.json +2 -2
- package/reports/jest-port-api.xml +8 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present, Port IO, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# jq-node-bindings
|
|
2
|
+
|
|
3
|
+
This is a library for Node.js that provides C bindings to the [jq](https://stedolan.github.io/jq/) library. It allows you to use jq to extract and manipulate data from JSON objects in Node.js.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install @port-labs/jq-node-bindings
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
To use this library, you must have `node-gyp` installed on your system. and the following libraries
|
|
14
|
+
|
|
15
|
+
1. `node-gyp`
|
|
16
|
+
```
|
|
17
|
+
npm install -g node-gyp
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
2. XCode on Mac, gcc on unix
|
|
21
|
+
Mac
|
|
22
|
+
```
|
|
23
|
+
xcode-select --install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Yum
|
|
27
|
+
```
|
|
28
|
+
sudo yum install gcc g++
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
apt-get
|
|
32
|
+
```
|
|
33
|
+
sudo apt-get gcc g++
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. The following C\C++ toolchains autoconf make libtool automake
|
|
37
|
+
Homebrew
|
|
38
|
+
```
|
|
39
|
+
brew install autoconf make automake libtool
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Yum
|
|
43
|
+
```
|
|
44
|
+
sudo apt-get install -y autoconf make libtool automake
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
apt-get
|
|
48
|
+
```
|
|
49
|
+
sudo apt-get install -y autoconf make libtool automake
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
Here's an example of how to use the library:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { exec } from 'jq-node-bindings';
|
|
60
|
+
|
|
61
|
+
const json = { foo: 'bar' };
|
|
62
|
+
const input = '.foo';
|
|
63
|
+
|
|
64
|
+
const result = exec(json, input);
|
|
65
|
+
|
|
66
|
+
console.log(result); // outputs "bar"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The exec function takes two arguments: a JSON object and a jq input string. It returns the result of running the jq program on the JSON object. The result can be of any type supported by jq: object, array, string, number, boolean, or null.
|
|
70
|
+
|
|
71
|
+
## Contributing
|
|
72
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
73
|
+
|
|
74
|
+
Please make sure to update tests as appropriate.
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@port-labs/jq-node-bindings",
|
|
3
|
-
"version": "v0.0.
|
|
3
|
+
"version": "v0.0.3",
|
|
4
4
|
"description": "Node.js bindings for JQ",
|
|
5
|
-
"jq-node-bindings": "0.0.
|
|
5
|
+
"jq-node-bindings": "0.0.3",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"configure": "node-gyp configure",
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<testsuites name="jest tests" tests="15" failures="0" errors="0" time="0.
|
|
3
|
-
<testsuite name="jq" errors="0" failures="0" skipped="0" timestamp="2023-02-
|
|
4
|
-
<testcase classname="jq should break" name="jq should break" time="0.
|
|
2
|
+
<testsuites name="jest tests" tests="15" failures="0" errors="0" time="0.369">
|
|
3
|
+
<testsuite name="jq" errors="0" failures="0" skipped="0" timestamp="2023-02-16T09:01:38" time="0.328" tests="15">
|
|
4
|
+
<testcase classname="jq should break" name="jq should break" time="0.004">
|
|
5
5
|
</testcase>
|
|
6
6
|
<testcase classname="jq should break for invalid input" name="jq should break for invalid input" time="0.002">
|
|
7
7
|
</testcase>
|
|
8
|
-
<testcase classname="jq should break for invalid input" name="jq should break for invalid input" time="0.
|
|
8
|
+
<testcase classname="jq should break for invalid input" name="jq should break for invalid input" time="0.003">
|
|
9
9
|
</testcase>
|
|
10
|
-
<testcase classname="jq should break for invalid input" name="jq should break for invalid input" time="0.
|
|
10
|
+
<testcase classname="jq should break for invalid input" name="jq should break for invalid input" time="0.002">
|
|
11
11
|
</testcase>
|
|
12
12
|
<testcase classname="jq string should work" name="jq string should work" time="0">
|
|
13
13
|
</testcase>
|
|
14
|
-
<testcase classname="jq number should work" name="jq number should work" time="0
|
|
14
|
+
<testcase classname="jq number should work" name="jq number should work" time="0">
|
|
15
15
|
</testcase>
|
|
16
16
|
<testcase classname="jq should return null" name="jq should return null" time="0.002">
|
|
17
17
|
</testcase>
|
|
18
18
|
<testcase classname="jq should return array with object" name="jq should return array with object" time="0">
|
|
19
19
|
</testcase>
|
|
20
|
-
<testcase classname="jq should return an item of an array" name="jq should return an item of an array" time="0.
|
|
20
|
+
<testcase classname="jq should return an item of an array" name="jq should return an item of an array" time="0.001">
|
|
21
21
|
</testcase>
|
|
22
22
|
<testcase classname="jq should return array with objects" name="jq should return array with objects" time="0">
|
|
23
23
|
</testcase>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
</testcase>
|
|
28
28
|
<testcase classname="jq should return recursed obj" name="jq should return recursed obj" time="0.001">
|
|
29
29
|
</testcase>
|
|
30
|
-
<testcase classname="jq should return recursed obj" name="jq should return recursed obj" time="0">
|
|
30
|
+
<testcase classname="jq should return recursed obj" name="jq should return recursed obj" time="0.001">
|
|
31
31
|
</testcase>
|
|
32
32
|
<testcase classname="jq should return null on invalid json" name="jq should return null on invalid json" time="0">
|
|
33
33
|
</testcase>
|