File tree Expand file tree Collapse file tree 5 files changed +14
-26
lines changed Expand file tree Collapse file tree 5 files changed +14
-26
lines changed Original file line number Diff line number Diff line change
1
+ ## 1.1.0
2
+
3
+ requirement: Node 10 => Node 8
4
+
1
5
## 1.0.0
2
6
3
7
:tada :
Original file line number Diff line number Diff line change 3
3
4
4
![ hosejs] ( https://github.com/deptno/hosejs/raw/master/asset/hosejs.gif )
5
5
6
- > Required node > v10
7
-
8
6
Transform JSON data with just ** JavaScript** in terminal
9
7
10
8
` jq ` ? javascript is clearly better option for people already use javascript.
@@ -27,7 +25,7 @@ npm -g install hosejs
27
25
28
26
## usage
29
27
30
- ```
28
+ ``` bash
31
29
$ cat some.json | j ' _.map(x => x.timestamp)'
32
30
$ cat some.json | j ' _.map(x => x.timestamp)' --tab 4
33
31
$ cat some.json | j ' _.map(x => x.timestamp)' --file pre.js --tab 2
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
3
- import { chomp , chunksToLinesAsync } from '@rauschma/stringio'
4
3
import { createContext , runInContext } from 'vm'
5
4
import * as meow from 'meow'
6
5
import * as fs from 'fs'
7
6
import { promisify } from 'util'
7
+ import * as stdin from 'get-stdin'
8
8
9
9
const program = meow ( `
10
10
HoseJS
@@ -29,24 +29,16 @@ const program = meow(`
29
29
async function main ( ) {
30
30
const { input, flags} = program
31
31
const readFile = promisify ( fs . readFile )
32
- const stream = process . stdin as any
33
- const lines = [ ]
34
-
35
32
if ( flags . file ) {
36
33
input . unshift ( ( await readFile ( flags . file ) ) . toString ( ) )
37
34
}
38
35
39
- for await ( const line of chunksToLinesAsync ( stream ) ) {
40
- lines . push ( chomp ( line ) )
41
- }
42
-
43
36
try {
44
- const _ = JSON . parse ( lines . join ( '' ) )
37
+ const _ = JSON . parse ( await stdin ( ) )
45
38
const sandbox = { _}
46
39
47
40
createContext ( sandbox )
48
41
runInContext ( input . map ( c => `_ = ${ c } ` ) . join ( ';' ) , sandbox )
49
-
50
42
print ( sandbox . _ , parseInt ( flags . tab ) )
51
43
} catch ( e ) {
52
44
console . error ( '🚫' , e )
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " hosejs" ,
3
- "version" : " 1.0 .0" ,
3
+ "version" : " 1.1 .0" ,
4
4
"description" : " javascript pipe, jq alternative" ,
5
5
"main" : " index.js" ,
6
6
"bin" : {
14
14
"author" : " Bonggyun Lee <deptno@gmail.com>" ,
15
15
"license" : " MIT" ,
16
16
"dependencies" : {
17
- "@rauschma/stringio " : " ^1.4 .0" ,
17
+ "get-stdin " : " ^6.0 .0" ,
18
18
"meow" : " ^5.0.0"
19
19
},
20
20
"devDependencies" : {
Original file line number Diff line number Diff line change 2
2
# yarn lockfile v1
3
3
4
4
5
- " @rauschma/stringio@^1.4.0 " :
6
- version "1.4.0"
7
- resolved "https://registry.yarnpkg.com/@rauschma/stringio/-/stringio-1.4.0.tgz#0b667bea726652a10a48dfc1dadc89e0ec51e269"
8
- dependencies :
9
- " @types/node" " ^10.0.3"
10
-
11
5
" @types/meow@^4.0.1 " :
12
6
version "4.0.1"
13
7
resolved "https://registry.yarnpkg.com/@types/meow/-/meow-4.0.1.tgz#cb80b9f0b8695df7ac15f0165585bcd2d0a6d94f"
24
18
version "1.2.0"
25
19
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
26
20
27
- " @types/node@^10.0.3 " , "@types/node@^10. 1.0":
21
+ " @types/node@^10.1.0 " :
28
22
version "10.1.2"
29
23
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.1.2.tgz#1b928a0baa408fc8ae3ac012cc81375addc147c6"
30
24
31
- " @types/ramda@^0.25.28 " :
32
- version "0.25.29"
33
- resolved "https://registry.yarnpkg.com/@types/ramda/-/ramda-0.25.29.tgz#05a58a3ba728344ecc9d99e37beb2adf822fb01c"
34
-
35
25
array-find-index@^1.0.1 :
36
26
version "1.0.2"
37
27
resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1"
@@ -85,6 +75,10 @@ find-up@^2.0.0:
85
75
dependencies :
86
76
locate-path "^2.0.0"
87
77
78
+ get-stdin@^6.0.0 :
79
+ version "6.0.0"
80
+ resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
81
+
88
82
graceful-fs@^4.1.2 :
89
83
version "4.1.11"
90
84
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
You can’t perform that action at this time.
0 commit comments