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

pumpkin.js

v1.0.2

Published

A mini-library for helpful JS functions ๐ŸŽƒ

Downloads

880

Readme

๐ŸŽƒ pumpkin.js

GitHub issues GitHub stars JavaScript Style Guide PRs Welcome

A micro-library for writing vanilla javascript as efficiently as possible.

Official Documentation

โœจ Why pumpkin.js?

With Javascript being so good nowadays, big libraries like jQuery are becoming less and less necessary. There are a few things, however, which you find yourself rewriting a lot, and bulking up your code with random stack overflow snippets.

Pumpkin attempts to eliminate this by adding numerous little helper functions to achieve common goals consistently. It's dependency free, and microscopic in size (written with tree-shaking in mind), making it an easy win on any project.

๐Ÿ”ง Installation

pumpkin.js can be installed via npm or yarn

npm i --save pumpkin.js
yarn add pumpkin.js

๐Ÿ“ฆ Usage

You can import the package using ESM imports

// Import all functions under one variable...
import * as $ from 'pumpkin.js'
// ...or just import the function(s) you need
import css, empty from 'pumpkin.js'

Or just good old CJS imports

const $ = require('pumpkin.js')

โœ๏ธ Example๏ธs

Empty an element of all its children

$.empty(el)

Add CSS to an element

$.css(el, {
  margin: '20px auto',
  background: 'red'
})

Get the last 2 items in an array, in reverse order

$.last([1, 2, 3, 4], 2, true) // [4, 3]

Validate an email address

let realEmail = '[email protected]'
let fakeEmail = 'blah blah blah'

$.validEmail(realEmail) // true
$.validEmail(fakeEmail) // false

Strip HTML tags from a string

$.stripTags('<div>Hello world</div>') // 'Hello world'

There's loads more you can do, too. You can see all the avaliable functions in the docs.

โ“FAQs

  • Q. Isn't this quite a random selection of functions?

    A. Yes, yes it is. The aim of the project is to essentially eliminate the amount of times you need to paste some questionable code in from Stack Overflow (How many times have you typed something like "Check if element contains child javascript no jquery", only to have to filter through all the jQuery answers to find out what you need to write). The benefit of this is all the functions in pumpkin.js are heavily tested in lots of different scenarios and are performance optimized.

  • Q. Why would I use this over something like jQuery?

    A. These big libraries are massive in size, and add a lot of weight your page which negatively impacts performance. A lot of the time (but not always), these huge libraries are overkill, and the same effect can be achieved easily with vanilla Javascript, and a bit of help from pumpkin.js.

๐Ÿ‘ซ Contributing

Contributions are welcome, feel free to suggest improvements via GitHub issues, or open any pull requests you may have.