npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cli-string

v1.0.2

Published

Common operations with strings, which can be used in your command line and code.

Downloads

2

Readme

🖹 CLI String - to manipulate strings in the console (and more)

This package gives you opportunity to manipulate strings in local environemnt. Maybe your company restricts you from sharing the data in the open web, or you're afraid of web tools stealing your data for self purpose - CLI String is locally installed and is not sharing your information anywhere. It's opensource - check that out.

Contents

Installation

To use CLI String, install in globally, or add it tou the project to get access to all the methods available in CLI.

npm install -g cli-string

or

npm i -g cli-string

Usage

CLI

To list all commands:

$ cstr help

To run command with the full name:

$ cli-string <command> [options] <string>

Or shortened alias:

$ cstr <command> [options] <string>

Code

you can also use the library in your code:

import { jsonPretty } from 'cli-string';

const prettyJson = jsonPretty('{"thisIs": "JSON"}', 4);
/**
 * {
 *     "thisIs": "JSON"
 * }
 */

Commands

jsonPretty

Makes your ugly JSON string pretty with specified spaces amount

USAGE
  $ cstr jsonPretty [--spaces <n>] <JSON>

OPTIONS
  --spaces 2 # Number of spaces for tabulation. Can't be less than 2, default: 2
  
EXAMPLE
  $ cstr jsonPretty --spaces 4 "{\"test\":\"JSON\"}"
  #  {
  #      "test": "JSON"
  #  }

encode

Encodes given string in specific format

USAGE
  $ cstr encode <format> <string>

FORMATS
  - base64
  - base64url
  - ascii
  - binary
  - hex
  - utf16le
  
EXAMPLE
  $ cstr encode base64 "This is my string"
  #  VGhpcyBpcyBteSBzdHJpbmc=

decode

Decodes given string from specific format to UTF-8 string

USAGE
  $ cstr decode <format> <string>

FORMATS
  - base64
  - base64url
  - ascii
  - binary
  - hex
  - utf16le
  
EXAMPLE
  $ cstr decode base64 VGhpcyBpcyBteSBzdHJpbmc=
  #  This is my string

hash

Hashes string in specified format

USAGE
  $ cstr hash <format> <string>

FORMATS
  - md5
  - sha1
  - sha256
  - sha224
  - sha512
  - sha384
  - sha3
  - ripemd160
  
EXAMPLE
  $ cstr hash sha256 "This is my string"
  #  9da6c02379110815278b615f015f0b254fd3d5a691c9d8abf8141655982c046b

addslashes

Quote string with slashes

USAGE
  $ cstr addslashes <string>
  
EXAMPLE
  $ cstr addslashes "O'Reilly?"
  #  O\'Reilly?

stripslashes

Un-quotes a quoted string

USAGE
  $ cstr stripslashes <string>
  
EXAMPLE
  $ cstr stripslashes "O\'Reilly?"
  #  O'Reilly?

encodeUrl

Encodes the special characters. In addition, it encodes the following characters: , / ? : @ & = + $ #

USAGE
  $ cstr encodeUrl <string>
  
EXAMPLE
  $ cstr encodeUrl "https://this.is/my?=url"
  #  https%3A%2F%2Fthis.is%2Fmy%3F%3Durl

decodeUrl

Decodes URL generated by encodeUrl

USAGE
  $ cstr decodeUrl <string>
  
EXAMPLE
  $ cstr decodeUrl "https%3A%2F%2Fthis.is%2Fmy%3F%3Durl"
  #  https://this.is/my?=url

Tips and Tricks

Pipe and save

You can curl url content, prettify it and save to the file:

$ curl https://www.boredapi.com/api/activity | xargs -t -0 ./dist/cli.js jsonPretty > test.txt

This will create a test.txt file with content like this:

{
  "activity": "Write a short story",
  "type": "recreational",
  "participants": 1,
  "price": 0,
  "link": "",
  "key": "6301585",
  "accessibility": 0.1
}