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 🙏

© 2025 – Pkg Stats / Ryan Hefner

chooles

v0.1.0

Published

Collection of everyday tools that are too small to belong to a dedicated lib

Downloads

13

Readme

Chooles

Collection of everyday tools that are too small to belong to a dedicated lib

Developped with Babel, webpack, Jest and :heart:

Usage

Here is the simplest way to init and use the tools. You can find more examples in the examples/ directory of this repo.

import Chooles from 'chooles';
Chooles.ready(() => { console.log('ready'); });

Table of Contents

Installation

npm install chooles
yarn add chooles

Methods

dom

Ready

This methods allows to execute a function after a specific ready state, or execute it right away if the state is already passed. Params:

  • function: the function to execute the page has loaded
  • readyState(string)(default 'loading'): the ready state after which the method must be executed
const meth = () => alert('ready');

Chooles.ready(meth);
Chooles.dom.ready(meth);
Chooles.ready(meth, Chooles.dom.readyStates.complete);

injectScript

Injects a script at the end of the head of the page. Chech first if a script with provided exist already. Params:

  • src(string): Script source url
  • id(string): script id
Chooles.injectScript('https://cdnjs.cloudflare.com/ajax/libs/impress.js/0.5.3/impress.js', 'id');
Chooles.dom.injectScript('https://cdnjs.cloudflare.com/ajax/libs/impress.js/0.5.3/impress.js', 'id');

closest

Gets the closest parent of an element identified by a selector Params:

  • $el(string|domNode): either a domNode or a querySelector
  • selector(string): querySelector of the element parent
Chooles.closest('.foo', '.bar');
Chooles.dom.closest(document.querySelector('.foo'), '.bar');

forms

Methods to manipulate forms

serializeFormToJson

Gets a domNode, find all form controls in it then transform their values to a js object. Params:

  • $form(domNode): a domNode containing form controls
const json = Chooles.form.serializeFormToJson(document.querySelector('.foo'));

jsonToFormData

Gets a json representation of a form and serialize it to FormData. Params:

  • json(object): object from serializeFormToJson()
const formData = Chooles.form.jsonToFormData({
    foo: 'bar',
});

serializeForm

Receives a domNode and generate FormData from its form controls (serializeFormToJson + serializeForm). Params:

  • $form(domNode): a domNode containing form controls
const formData = Chooles.form.serializeForm(document.querySelector('.foo'));

Abstract Component

Abstract class for JS components

import { AbstractComponent } from 'chooles';
export default class MyComponent extends AbstractComponent {
    constructor(globals) {
        super(globals, { selector: '.js-header' });
    }

    if (this.exists) {
        ...
    }
}

Contribute

File structure

chooles/
 ├──src/                             * our source files that will be compiled to javascript
 |   ├──app/                         * Lib sources
 │   │
 |   └──examples/                    * examples sources
 │       ├──index.pug                * our index.html
 │       │
 │       ├──html/                    * where you keep your pug templates
 │       │   └──layout.pug           * the main pug layout
 │       │
 │       └──app/                     * JavaScript/ES2015 files
 │
 ├──test/                            * Jest test definitions
 │
 ├──webpack/                         * Webpack configuration files
 │   ├──webpack.config.base.js       * Base config
 │   ├──webpack.config.js            * Development overrides
 │   └──webpack.config.prod.js       * Production overrides
 │
 └──package.json                     * package.json

Getting Started

Dependencies

You need to install the following on you system

  • node and npm
  • Ensure you running Node version >= 8.0.0

Installing

Running the app

After all dependencies are installed, just run make start to start a local server using webpack-dev-server which will watch your files and build them. webpack-dev-server will display the address and port of your server (by default, http://0.0.0.0:3000).

Build commands

Server

# build files then launch the server and watch files
make start

Build files

# build files in ./build/ (Webpack, Sass, Pug) and validate them
make build
# "compile" files in ./dist/
# minify and concatenate assets
make release

Validate files

# runs the validations eslint and jest tests
make test

License

MIT

Author: Frank Gairal