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

string-methods-extension

v0.1.5

Published

An extension to String Methods, to add some features to ECMAScript 6. It works bothe for Node and the browser.

Downloads

394

Readme

string-methods-extension

This package extends the String Methods, to add some features to ECMAScript 6. It works nicely bothe for Node and the browser.

Installation

Via npm:

npm install string-methods-extension

In a browser:

<script src="string-methods-extension.js"></script>

In Node.js:

require('string-methods-extension');

Using yarn

yarn add string-methods-extension

Table of Contents

Usage

stripLineBreak

The stripLineBreak() method removes all line breaks from a string.

`test\ntest\ntest.`.stripLineBreak();
// => `test test test.`

`test \ntest \ntest.`.stripLineBreak('');
// => `test test test.`

`test\ntest\ntest.`.stripLineBreak('.');
// => `test.test.test.`

trim

The trim() method removes whitespace or a specified character from both sides of a string.

`     ahsdfjhfhf    `.trim();
// => `ahsdfjhfhf`

`......ahsdfjhfhf.....`.trim('.');
// => `ahsdfjhfhf`

trimStart

The trimStart() method removes whitespace or a specified character at the left side of a string.

`     ahsdfjhfhf    `.trimStart();
// => `ahsdfjhfhf    `

`......ahsdfjhfhf.....`.trimStart('.');
// => `ahsdfjhfhf.....`

trimEnd

The trimEnd() method removes whitespace or a specified character at the right side of a string.

`     ahsdfjhfhf    `.trimEnd();
// => `     ahsdfjhfhf`

`......ahsdfjhfhf.....`.trimEnd('.');
// => `......ahsdfjhfhf`

reverse

The reverse() method reverse the characters of a string.

`abcdef`.reverse();
// => `fedcba`

`Hello World`.reverse();
// => `dlroW olleH`

stripTags

The stripTags() method removes html or xml tags from a string.

`Hello <b>world!</b>`.stripTags();
// => `Hello world!`

`Hello <b><a href="hello.html">world!</a></b>`.stripTags();
// => `Hello world!`

stripWhiteSpace

The stripWhiteSpace() method removes white spaces from a string, with a single space or specified character.

`test     test    test`.stripWhiteSpace();
// => `test test test`

`test     test    test`.stripWhiteSpace('.');
// => `test.test.test`

replaceAll

The replaceAll() method returns a string where a specified string is replaced with another specified string.

`123 test nl.`.replaceAll({'123': 'abc','nl': 'Netherlands',});
// => `abc test Netherlands.`

`You should eat fruits, vegetables, and fiber every day`.replaceAll({'fruits': 'pizza','vegetables': 'beer', 'fiber': 'ice cream',});
// => `You should eat pizza, beer, and ice cream every day`

encodeXML

The encodeXML() method adds XML encoding to a string.

`test&"test" 1<2`.encodeXML();
// => `test&amp;&quot;testquot; 1&lt;2`

decodeXML

The decodeXML() method removes XML encoding form a string.

`test&amp;&quot;testquot; 1&lt;2`.decodeXML();
// => `test&"test" 1<2`

Unit tests & code coverage

After cloning this repository, run npm install--dev to install the dependencies needed for he development and testing. Once that is done, you can run the unit tests in Node using npm test