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

@sl-code-lords/js-extra-types

v0.0.2-dev

Published

JavaScript extra Types

Downloads

9,360

Readme

Status GitHub Issues GitHub Pull Requests License


📝 Table of Contents

🧐 About

Extra Types For JavaScript

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes

Installing

yarn add @sl-code-lords/js-extra-types

or

npm i @sl-code-lords/js-extra-types

🎈 Usage

const extra_types = require('@sl-code-lords/js-extra-types')
extra_types.init()

Strings

// ----------------String----------------
var data = ''

//bind strings
data = '{} I {} Ravindu {}'.bind('Hello','Am','Manoj')
console.log(data) // => Hello I Am Ravindu Manoj

//split strings without error
data = 'Hello I Am Ravindu Manoj'.cut('Am')
console.log(data) // => [ 'Hello I ', ' Ravindu Manoj' ]

//split strings without error
data = 'Hello I Am Ravindu Manoj'.cut('Sl')
console.log(data) // => [ 'Hello I Am Ravindu Manoj' ]

//includes function without error
data = 'Hello I Am Ravindu Manoj'.have('Ravindu')
console.log(data) // => true

//reverse text
data = 'Hello I Am Ravindu Manoj'.reverse()
console.log(data) // => jonaM udnivaR mA I olleH

//replace again and again one line
data = 'Hello I Am Ravindu Manoj'.replacer('Hello%hi',' Ravindu % ')
console.log(data) // => hi I Am Manoj

//get strings between 2 place
data = '{Hello} {I Am} {Ravindu} {Manoj}'.getBetween('{','}')
console.log(data) // => [ 'Hello', 'I Am', 'Ravindu', 'Manoj' ]

//encrypt strings with crypto
data = 'Hello I Am Ravindu Manoj'.encrypt('Ravindu1234')
console.log(data) // => U2FsdGVkX18IWCpLQUxEeNU1O/vZqBAZMebwpLEGk8J9xWGzAKJ1oif1QkOfe3U/

//decrypt strings with crypto
data = 'U2FsdGVkX18IWCpLQUxEeNU1O/vZqBAZMebwpLEGk8J9xWGzAKJ1oif1QkOfe3U/'.decrypt('Ravindu1234')
console.log(data) // => Hello I Am Ravindu Manoj

//to base64 encode
data = 'Hello I Am Ravindu Manoj'.base(true)
console.log(data) // => SGVsbG8gSSBBbSBSYXZpbmR1IE1hbm9q

//base64 decode
data = 'SGVsbG8gSSBBbSBSYXZpbmR1IE1hbm9q'.base()
console.log(data) // => Hello I Am Ravindu Manoj

//encodeURIComponent function as type function
data = 'Hello @ I Am Ravindu Manoj'.tourl()
console.log(data) // => Hello%20%40%20I%20Am%20Ravindu%20Manoj
// ---------------------------------------

Array

// ----------------Array----------------

// get random element
data = ['banana','mango','apple','orange'].sample()
console.log(data) // => mango

// includes function without error
data = ['banana','mango','apple','orange'].have('apple')
console.log(data) // => true

// get difference item in 2 array
data = ['banana','mango','apple','orange'].difference(['apple','mango','rambutan','pine-apple'])
console.log(data) // => [ 'banana', 'orange', 'rambutan', 'pine-apple' ]

// get difference item in 1st array
data = ['banana','mango','apple','orange'].diff(['apple','mango','rambutan','pine-apple'])
console.log(data) // => [ 'banana', 'orange' ]

// get common item in 2 array
data = ['banana','mango','apple','orange'].common(['apple','mango','rambutan','pine-apple'])
console.log(data) // => [ 'mango', 'apple' ]

// get last item in array
data = ['banana','mango','apple','orange'].last()
console.log(data) // => orange

// remove item with function check
data = ['banana','mango','apple','orange'].rm((item)=> item.have('ng'))
console.log(data) // => [ 'banana', 'apple' ]

// remove item in argument
data = ['banana','mango','apple','orange'].remove('mango','apple')
console.log(data) // => [ 'banana', 'orange' ]

// remove undefined null or empty item in array
data = [null,'banana',undefined,'mango','','apple','orange'].fix()
console.log(data) // => [ 'banana', 'mango', 'apple', 'orange' ]

// remove duplicate item in array
data = ['banana','mango','apple','mango','apple'].fixDuplicate()
console.log(data) // => [ 'banana', 'mango', 'apple' ]

// encrypt array with crypto
data = ['banana','mango','apple','orange'].encrypt('Ravindu1234')
console.log(data) // => U2FsdGVkX18bN6nFeZZx0UrOaeP0smRjAHkY3g2st7zWRT6Fdz/tgZRKc6eh23/1VtoIommjbygCbNdDqiYTzA==

// ---------------------------------------

Object

// ----------------Object-----------------

// encrypt Object with crypto
data = {name:'Ravindu',country : 'sri lanka',age : 21}.encrypt('Ravindu1234')
console.log(data) // => U2FsdGVkX18u/7Y6j8tX/ZA2tDTQzzce0Zs87Saw5gUBQAOhIfyATR2nLQH0oflaxAVuTGYLXjVXLkbuC9VhFsJj8h6RLmWvGUlY2fVTx30=

// get keys length
data = {name:'Ravindu',country : 'sri lanka',age : 21}.length()
console.log(data) // => 3

// get key from value
data = {name:'Ravindu',country : 'sri lanka',age : 21}.getKeyByValue('sri lanka')
console.log(data) // => country

// locate value with argument location
data = {name:{full : { cap : {sir : 'JAYASUNDARA'}}}}.go('name','full','cap','sir')
console.log(data) // => JAYASUNDARA
// ---------------------------------------

Number

// ----------------Number-----------------

// includes function without error
data = Number(123456789).have('2')
console.log(data) // => true

// reverse number
data = Number(123456789).reverse()
console.log(data) // => 987654321

// split numbers
data = Number(123456789).cut('2')
console.log(data) // => [ 1, 3456789 ]

// encrypt numbers with crypto
data = Number(123456789).encrypt('Ravindu1234')
console.log(data) // => U2FsdGVkX18Ly1ll+3fZuaOMtXjy2oVj/Nds09b1f1Y=
// ---------------------------------------

✍️ Authors

See also the list of contributors who participated in this project.