1. shellwords
Manipulate strings according to the word parsing rules of the UNIX Bourne shell.
shellwords
Package: shellwords
Created by: jimmycuadra
Last modified: Sat, 24 Jun 2023 02:18:07 GMT
Version: 1.0.1
License: MIT
Downloads: 20,824,064
Repository: https://github.com/jimmycuadra/shellwords

Install

npm install shellwords
yarn add shellwords

Shellwords

Shellwords provides functions to manipulate strings according to the word parsing rules of the UNIX Bourne shell. It is based on the Ruby module of the same name.

Installation

With npm:

npm install shellwords

With Yarn:

yarn add shellwords

API

Shellwords exports the following functions, shown here in the TypeScript declaration file format.

 /**
 * Splits a string into an array of tokens in the same way the UNIX Bourne shell does.
 *
 * @param line A string to split.
 * @returns An array of the split tokens.
 */
export declare const split: (line?: string) => string[];

/**
 * Escapes a string so that it can be safely used in a Bourne shell command line.
 *
 * @param str A string to escape.
 * @returns The escaped string.
 */
export declare const escape: (str?: string) => string;

Example

 import { escape, split } from "shellwords";

split("foo 'bar baz'");
// ["foo", "bar baz"]

escape("What's up, yo?");
// 'What\\\'s\\ up,\\ yo\\?'

shellwords is released under the MIT license. See LICENSE.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin