Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

jqnpm/jq-disarray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jqnpm logotype, a Penrose triangle

Manipulate arrays while avoiding general disarray.

⚠️ This project has been archived

No future updates are planned. Feel free to continue using it, but expect no support.

This is a package for the command-line JSON processor jq. Install the package in your jq project/package directory with jqnpm:

jqnpm install joelpurra/jq-disarray

Usage

import "joelpurra/jq-disarray" as Disarray;

# Disarray::haveSameLength(other)
null | Disarray::haveSameLength([]) # false
[] | Disarray::haveSameLength([]) # true
[ "a" ] | Disarray::haveSameLength([ "b" ]) # true
[ "a" ] | Disarray::haveSameLength([]) # false

# Disarray::ifSameLength(other)
[ "a" ] | Disarray::ifSameLength([ "b" ]; map(. + "!")) # [ "a!" ]
[ "a" ] | [ "b" ] as $right | Disarray::ifSameLength($right; Disarray::addition($right)) # [ "ab" ]

# Disarray::defaults(obj)
null | Disarray::defaults(1; "a") # [ "a" ]
null | Disarray::defaults(2; { "a": true }) # [ { "a": true }, { "a": true } ]

# Disarray::zeros
null | Disarray::zeros(3) # [ 0, 0, 0 ]

# Disarray::addition(other)
[ "a" ] | Disarray::addition([ "b" ]) # [ "ab" ]
[ 2, 3, 4 ] | Disarray::addition([ 3, 4, 5 ]) # [ 5, 7, 9 ]
[ "a" ] | Disarray::addition([ "b", "c" ]) # [ "ab", "c" ]

License

Copyright (c) 2015 Joel Purra https://joelpurra.com/ All rights reserved.

When using jq-disarray, comply to the MIT license. Please see the LICENSE file for details.