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

@spark-engine/toolbox

v1.6.3

Published

A collection of small tools to simplify front-end development.

Downloads

7

Readme

Spark Toolbox

Build Status

The toolbox is a small collection of tools (and polyfils) to simplify front-end development.

This library uses polyfills to add native support for Element.classlist(), Element.closest(), Element.matches(), and Object.assign.

Dom Tools

Simple tools for working with the DOM.

  • getClosest(el, selector) - Provides browser support for Element.cloest() - a DOM method that returns the current element if it matches the given selector, or else the closest ancestor element that matches the given selector, or else null.
  • childOf(el, parent) - Returns true if an element is a child of another element.
  • isElement(el) - Returns true if an object is of type HTML Element.
  • formData(el) - Returns formData for ajax form submission, assembled from all inputs beneath a given element. If any input is disabled or a child of a [disabled] element, they are omitted.
  • scrollTo(to, options) - This scrolls the document (or an element) to a y-coordinate or another element with an ease function.

scrollTo Arguments:

  • to - a y-coordinate or DOM element.

Options:

  • callback: function - function to trigger on complete
  • duration: 500 - time in milliseconds to scroll (default: 500)
  • scroll: element - element to scroll (default: document root)

Object Tools

Simple tools to make working with objects easier.

merge(object, object, [object, …])

This relies on Object.assign and exists becuase Object.assign modifies the first object in the arguments, which isn't often what I want. This merges objects, returning a new merged object without modifying any object passed.

Object.assign(a, b)      // Returns `a`, merged with `b` but modifies references to `a`.
Object.assign({}, a, b)  // Equivilent to `merge(a, b)`, does not modify either object.

The second option is often what I want, but it looks very strange to merge objects with an empty object. This is where I wish Javascript worked like Ruby and I could have merge and merge!. Alas.

slice(obj, [length])

Easy access to Array.prototype.slice for converting objects into arrays of values which is useful for casting collections of DOM tree nodes.

each(obj, func)

Under the hood this maps to Array.prototype.forEach.call(obj, func), which is casts DOM tree nodes as an array before iterating. It mostly exists to improve the readabilty of code.