Socket
Socket
Sign inDemoInstall

jiq

Package Overview
Dependencies
12
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jiq

Use existing javascript knowledge to query or mutate data


Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

A command line tool to manipulate files and directories using javascript

installation

yarn global add jiq

or

npm -g install jiq

Let's start

files and directory

jiq

output

┌───────────────────┬──────────────────┬──────────┬───────────────────┐
│ base              │ type             │ size     │ date              │
├───────────────────┼──────────────────┼──────────┼───────────────────┤
│ .git              │ directory        │ --       │ nov 7th 10:54 pm  │
│ .gitignore        │                  │ 63 B     │ nov 7th 10:54 pm  │
│ .npmignore        │                  │ 103 B    │ nov 9th 11:38 pm  │
│ .vscode           │ directory        │ --       │ nov 10th 9:56 pm  │
│ _config.yml       │ text/yaml        │ 26 B     │ nov 8th 11:32 am  │
│ assets            │ directory        │ --       │ nov 9th 11:39 pm  │
│ build             │ directory        │ --       │ sun 10:00 pm      │
│ docs              │ directory        │ --       │ nov 13th 12:06 am │

filter out directories only

jiq . '.filter(x => x.isDirectory)'

output

┌──────────────┬───────────┬──────┐
│ base         │ type      │ size │
├──────────────┼───────────┼──────┤
│ .git         │ directory │ --   │
│ .vscode      │ directory │ --   │
│ assets       │ directory │ --   │
│ build        │ directory │ --   │
│ docs         │ directory │ --   │
│ node_modules │ directory │ --   │
│ src          │ directory │ --   │
│ stubs        │ directory │ --   │
└──────────────┴───────────┴──────┘

rename js to ts file

jiq . '.filter(x => x.ext === "js").each(x => x.rename(x.name + ".ts"))'

output

rename all js files to ts on specified directory

goto File section

get json from url and print as table.

jiq https://reqres.in/api/users '.data' --print table

output

┌─────────┬────┬────────────────────────────┬────────────┬───────────┬───────────────────────────────────────────────────────────────────────┐
│ (index) │ id │           email            │ first_name │ last_name │                                avatar                                 │
├─────────┼────┼────────────────────────────┼────────────┼───────────┼───────────────────────────────────────────────────────────────────────┤
│    0    │ 1  │  'george.bluth@reqres.in'  │  'George'  │  'Bluth'  │  'https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg'  │
│    1    │ 2  │  'janet.weaver@reqres.in'  │  'Janet'   │ 'Weaver'  │ 'https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jpg'  │
│    2    │ 3  │   'emma.wong@reqres.in'    │   'Emma'   │  'Wong'   │ 'https://s3.amazonaws.com/uifaces/faces/twitter/olegpogodaev/128.jpg' │
│    3    │ 4  │    'eve.holt@reqres.in'    │   'Eve'    │  'Holt'   │ 'https://s3.amazonaws.com/uifaces/faces/twitter/marcoramires/128.jpg' │
│    4    │ 5  │ 'charles.morris@reqres.in' │ 'Charles'  │ 'Morris'  │ 'https://s3.amazonaws.com/uifaces/faces/twitter/stephenmoon/128.jpg'  │
│    5    │ 6  │  'tracey.ramos@reqres.in'  │  'Tracey'  │  'Ramos'  │  'https://s3.amazonaws.com/uifaces/faces/twitter/bigmancho/128.jpg'   │
└─────────┴────┴────────────────────────────┴────────────┴───────────┴───────────────────────────────────────────────────────────────────────┘

see printer

with json output

jiq https://reqres.in/api/users '.data.head(3).pick({email: "email", name: (x) => x.first_name + " " + x.last_name })'

see all available array functions array, and JSON

output

[
    { email: 'george.bluth@reqres.in', name: 'George Bluth' },
    { email: 'janet.weaver@reqres.in', name: 'Janet Weaver' },
    { email: 'emma.wong@reqres.in', name: 'Emma Wong' }
]

Read full documentation here.

Keywords

FAQs

Last updated on 17 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc