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

@easytech-international-sdn-bhd/jstring

v1.1.7

Published

Custom string class for JavaScript

Downloads

18

Readme

JString

Handy tool for Javascript String. Can be used in NodeJSReact-NativeReactJS applications.


Table of Contents


Installation

With npm:

$ npm install @easytech-international-sdn-bhd/jstring

With yarn:

$ yarn add @easytech-international-sdn-bhd/jstring

Methods

Any string like 'null'/'undefined' will be auto converted to ''

| method | description | example | |---|---|---| | trimHtml | Remove all the html tags from string | JString(<p>Hello World</p>).trimHtml().toStr(); output: Hello World | | searchDeep | Search case insensitive in string | JString('Hello World').searchDeep('w'); output: true | | searchTokens | Search tokens in string(case insensitive) | JString('Hello World').searchTokens(['w','h']); output: true | | isSafe | Check if the string isValid and returns the string if it's valid otherwise empty string | JString(' ').isSafe(); output: '' | | removeLastChar | Remove last character from string. This method comes with an optional parameter. If the optional parameter is provided, the function will remove that parameter only | var ex = JString('abc-com').removeLastChar().toStr(); output: 'abc-co'ex.removeLastChar('o').toStr();output: 'abc-c' | | removeFirstChar | Remove first char. Same functionality as removeLastChar | - | | removeSpecialChar | Remove all the special or sensitive characters from string | JString('abc_de/f^g%h%i$j').removeSpecialChar().toStr();output: 'abcdefghij' | | replaceInfinity | Replace all from string based on given parameter | JString('Dogge Doggo').replaceInfinity('g','').toStr();output: 'Doe Doo' | | rollback | Rollback changes | JString('Dogge Doggo').replaceInfinity('g','').rollback(); | | inCurrency | Convert into currency format | JString('12345.67').inCurrency('$').toStr();output: '$12,345.67' | | isJson | Check whether the string is JSON | JString('{"jstring":"JSON example"}').isJson();output: true | | toJson | Convert string to JSON. Return null if not JSON | JString('{"jstring":"JSON example"}').toJson(); | | isNumber | Check if the string can be a number | JString('101').isNumber();output: true | | toNumber | Convert string to number | JString('101').toNumber();output: 101 | | isPassword | Check if the string is a number with an optional parameter of minimum number of characters | JString('abc'o').isPassword();output:false | | isFormSafe | Check if a string is valid for form or database | JString('ab#c').isFormSafe();output:false | | isEmail | Check if the string is an email | JString('abc.com').isEmail();output:false | | isValid | Check if the string is a valid string | JString('').isValid();output:false | | instanceOfJString | Return JString instance | - | | instanceOfString | Return String instance | - | | firstUpperCase | Convert first character to upper case | JString('aBC').firstUpperCase().toStr();output:'ABC' | | firstLowerCase | Convert first character to lower case | JString('ABC').firstLowerCase().toStr();output:'aBC' | | lastUpperCase | Convert last character to upper case | JString('abc').lastUpperCase().toStr();output:'abC' | | lastLowerCase | Convert last character to lower case | JString('ABC').lastLowerCase().toStr();output:'ABc' | | isEqual | Compare string case sensitive | JString('AC').isEqual('ac');output:false | | isEqualDeep | Compare string case insensitive | JString('AC').isEqualDeep('ac');output:true | | toArray | Convert string into array of char | JString('ADC').toArray();output:['A','D','C'] | | walk | Loop through string | JString('abcd').walk((char,index)=>{ }); | | occurrenceOf | Count number of occurance of char | JString('abcdcc').occurrenceOf('c');output:3 |

TODO

  • Allow schema for password validation
  • Allow schema for form validation
  • Compress & Decompress string
  • ~~Allow tokenize search~~

Author

💻 🛠 Mohammad Julfikar Mahmud