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

jspro

v1.0.2

Published

JSPro or JavaScript Prototypes is a library of hundreds of awesome prototypes for lazy programmers.

Downloads

15

Readme

WTF JSPro is!

JSPro is nothing but JavaScript Prototypes! The publisher is too lazy to write full name that's why it's just JSPro. Whatever, it's a library of hundreds of awesome JavaScript Prototypes (you may know it as dot function) for lazy programmers. Just install the package with a little effort and leave the blames for the publisher.

Sigma rule 512

Life is not a pressure cooker, don't let the pressure get into it.


Not clear yet?

Currently you are able to use some limited prototypes. For rest of the small programs, you need to re-invent the wheel.

For example

To upper case string, you use

const name = "John"

console.log(name.toUpperCase())
// JOHN

or to lower case string

const name = "JOHN"

console.log(name.toLowerCase())
// john

But JavaScript doesn't have any built-in prototypes or functions to capitalize string. So to capitaize string you needed to write a user defined function like this

const capitalizeString = (str) => str[0].toUpperCase() + str.slice(1)

const name = "john"

console.log(capitalizeString(name));

// John

But using JSPro you will be able to code in JavaScript like a pro.

To capitalize string

const name = "john"

console.log(name.toCapitalCase())
// John 

Isn't amazing?

JSPro has hundreds of awesome prototypes like this. You don't need to reinvent the wheel again.

Table of contents


Install

Simply install from you terminal as dev-dependency

npm i -D jspro

Usages

You can use JSPro as Node module as well as ES6/ESNext module. Whatever, only requiring or imporing is enough. YOU DON'T HAVE TO INITIALIZE JSPro.

Node

require("jspro")

ESNext

import "jspro"

Prototypes

  1. String
  2. Number
  3. Array

String

toCapitaCase

Returns first character capitalized

const name = 'john'

name.toCapitalCase()

// John

reverse

Returns reversed string

const name = 'John'

name.reverse()

// nhoJ

toCamelCase

Returns camel case string

const name = 'John Doe'

name.toCamelCase()

// johnDoe

slugify

Slugifies string

const name = 'Hello World'

name.slugify()

// hello-world

dec

Hexadecimal to decimal

const hex = 'a'

hex.dec()

// 10 

bin

Hexadecimal to binary

const hex = 'a'

hex.bin()

// 1010

/**
 * hex a = decimal 10 = binary 1010 
 */

Number

reverse

Reverses number

const number = 12345

number.reverse()

// 54321

repeat

Repeats number

const number = 12

number.repeat(2)

// 1212

bin

Decimal to binary

const number = 2

number.bin()

// 11

hex

Decimal to hexadecimal

const number = 10

number.hex()

// a

is_even

Returns true when number is even

const number = 2

number.is_even()

// true

is_prime

Returns true when number is prime

const number = 7

number.is_prime()

// true

is_palindromic

Returns true when number is palindromic

const number = 12321

number.is_palindromic()

// true

sll

Performs shift left logical, shifts n-th bite to left

const number = 2
const biteToShift = 1

number.sll(biteToShift) // The number of bite ti be shifted, default is 1

// 4

srl

Performs shift right logical, shifts n-th bite to right

const number = 6
const biteToShift = 1

number.srl(biteToShift) // The number of bite ti be shifted, default is 1

// 3

Array

sort_by

Returns sorted array by object key name.

If you have an array where elements are object, you can sort this now by using sort_by prototype with passing the key as string.

const list = [
  { name: 'John' },
  { name: 'Doe' }
]

list.sort_by("name")

/* 

[ 
  { name: 'Doe' }, 
  { name: 'John' } 
]

*/

Customization

Yes, you can load only the prototypes you need.

require("jspro/string") // string only

require("jspro/number") // number only  

require("jspro/array")  // array only

By default, all four types of prototypes will be loaded.

Contribution

Publisher

Contributors

Planning to contribute?

Seems like you are not too lazy!

Git Repository

Thanks for your interested. You can pull the repo from git. But you are requested to open a ticket before pushing for discussing on what you are planning to add.