@panda-clouds/string

1.2.0 • Public • Published

PCString

maintained by PandaClouds.com

PCString is a lightweight JavaScript library for Node.js that provides additional String methods.

Installation

  1. If you want to use this library, you first need to install the Node.js.

  2. When you install node.js, will also be installed npm.

  3. Please run the following command.

npm install --save @panda-clouds/string

Usage

Node.js

const PCString = require('@panda-clouds/string');

// example usage
PCString.isString('yup!'); // => true;
PCString.hasWhitespace('ABC'); // => false;

You can replace PCString with any variable.

Methods

Unit Tests are an additional resource for learning functionality.

- isString(string)

Returns whether a given object is a String.

Example:

PCString.isString('ABC') // => true
PCString.isString(5) // => false
PCString.isString({}) // => false
PCString.isString([]) // => false

- hasWhiteSpace(string)

returns true if the string has white space, false if not.

Example:

PCString.hasWhitespace(' ') // => true
PCString.hasWhitespace('A B') // => true
PCString.hasWhitespace('AB') // => false
PCString.hasWhitespace('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-!@#$%^&*()') // => false

- removeWhitespace(string)

Removes all white characters from the given string.

Example:

PCString.removeWhitespace(' A B  C   D    ') // => 'ABCD'
PCString.removeWhitespace('	A	B	C			D	') // => 'ABCD'
PCString.removeWhitespace('\nA\nB\n\nC\n\n\nD\n\n\n\n') // => 'ABCD'
PCString.removeWhitespace(null) // => ''

- domainSafeString(string)

Removes all non-domain-safe characters.

Example:

PCString.domainSafeString('_A_B__C___D____') // => 'ABCD'
PCString.domainSafeString('	A	B	C			D	') // => 'ABCD'
PCString.domainSafeString('\nA\nB\n\nC\n\n\nD\n\n\n\n') // => 'ABCD'
PCString.domainSafeString(null) // => ''

Contributions

Pull requests are welcome! here is a checklist to speed things up:

  • modify PCString.js
  • add unit tests in PCString.spec.js
  • run npm test
  • document method in README.md
  • add your name to 'Contributors' in README.md

Contributors

(Add your name)

Readme

Keywords

Package Sidebar

Install

npm i @panda-clouds/string

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

17.7 kB

Total Files

10

Last publish

Collaborators

  • mrmarcsmith