Skip to content

Commit 0dc49e0

Browse files
committed
requirement down
1 parent a2e3f2c commit 0dc49e0

File tree

5 files changed

+14
-26
lines changed

5 files changed

+14
-26
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.0
2+
3+
requirement: Node 10 => Node 8
4+
15
## 1.0.0
26

37
:tada:

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
![hosejs](https://github.com/deptno/hosejs/raw/master/asset/hosejs.gif)
55

6-
> Required node > v10
7-
86
Transform JSON data with just **JavaScript** in terminal
97

108
`jq`? javascript is clearly better option for people already use javascript.
@@ -27,7 +25,7 @@ npm -g install hosejs
2725

2826
## usage
2927

30-
```
28+
```bash
3129
$ cat some.json | j '_.map(x => x.timestamp)'
3230
$ cat some.json | j '_.map(x => x.timestamp)' --tab 4
3331
$ cat some.json | j '_.map(x => x.timestamp)' --file pre.js --tab 2

index.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env node
22

3-
import {chomp, chunksToLinesAsync} from '@rauschma/stringio'
43
import {createContext, runInContext} from 'vm'
54
import * as meow from 'meow'
65
import * as fs from 'fs'
76
import {promisify} from 'util'
7+
import * as stdin from 'get-stdin'
88

99
const program = meow(`
1010
HoseJS
@@ -29,24 +29,16 @@ const program = meow(`
2929
async function main() {
3030
const {input, flags} = program
3131
const readFile = promisify(fs.readFile)
32-
const stream = process.stdin as any
33-
const lines = []
34-
3532
if (flags.file) {
3633
input.unshift((await readFile(flags.file)).toString())
3734
}
3835

39-
for await (const line of chunksToLinesAsync(stream)) {
40-
lines.push(chomp(line))
41-
}
42-
4336
try {
44-
const _ = JSON.parse(lines.join(''))
37+
const _ = JSON.parse(await stdin())
4538
const sandbox = {_}
4639

4740
createContext(sandbox)
4841
runInContext(input.map(c => `_ = ${c}`).join(';'), sandbox)
49-
5042
print(sandbox._, parseInt(flags.tab))
5143
} catch (e) {
5244
console.error('🚫', e)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hosejs",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "javascript pipe, jq alternative",
55
"main": "index.js",
66
"bin": {
@@ -14,7 +14,7 @@
1414
"author": "Bonggyun Lee <deptno@gmail.com>",
1515
"license": "MIT",
1616
"dependencies": {
17-
"@rauschma/stringio": "^1.4.0",
17+
"get-stdin": "^6.0.0",
1818
"meow": "^5.0.0"
1919
},
2020
"devDependencies": {

yarn.lock

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
# yarn lockfile v1
33

44

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-
115
"@types/meow@^4.0.1":
126
version "4.0.1"
137
resolved "https://registry.yarnpkg.com/@types/meow/-/meow-4.0.1.tgz#cb80b9f0b8695df7ac15f0165585bcd2d0a6d94f"
@@ -24,14 +18,10 @@
2418
version "1.2.0"
2519
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
2620

27-
"@types/node@^10.0.3", "@types/node@^10.1.0":
21+
"@types/node@^10.1.0":
2822
version "10.1.2"
2923
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.1.2.tgz#1b928a0baa408fc8ae3ac012cc81375addc147c6"
3024

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-
3525
array-find-index@^1.0.1:
3626
version "1.0.2"
3727
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:
8575
dependencies:
8676
locate-path "^2.0.0"
8777

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+
8882
graceful-fs@^4.1.2:
8983
version "4.1.11"
9084
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

0 commit comments

Comments
 (0)