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

preact-util

v1.4.70

Published

A utility for preact apps.

Downloads

105

Readme

A Node.js collection model for mongoose stuff

Build Status Coverage Status GitHub version npm version

TL;DR

Installation

npm install preact-util --save

Usage

It's easy. Import and use the utilities.

import util from 'preact-util';

const apiServer = props.apiServer || `${window.location.protocol}//${window.location.host}`;
util.setApiServer(apiServer);

List of some useful functions

  • isNumber
  • checkNested
  • setNestedValue
  • asNumber
  • asString
  • asObject
  • asBoolean
  • cleanObject
  • padDate
  • parseInputDate
  • isoDate
  • getApiServer
  • setApiServer
  • getImageServer
  • setImageServer
  • getJwtToken
  • setJwtToken
  • removeJwtToken
  • setUserEmail
  • getUserEmail
  • removeUserEmail
  • setObject
  • unsetObj
  • getObject
  • set
  • unset
  • get
  • fetchApi
  • format
  • formatCompact
  • formatBytes
  • getDomain
  • getImageHostname
  • getImageSrc
  • isCapsLock
  • validateEmail
  • ucfirst
  • randomPassword
  • toggleDarkModeClasses

I promise to add some more documentation, or if you want to help, please follow the instructions below.

Helper modules in use:

Jest A browser JavaScript testing toolkit. Jest is used by Facebook to test all JavaScript code including React applications. One of Jest's philosophies is to provide an integrated "zero-configuration" experience.

ESLint ESLint is a code style linter for programmatically enforcing your style guide.

Travis Travis CI is a hosted continuous integration service. It is integrated with GitHub and offers first class support for many languages.

Coveralls.io Coveralls is a web service to help you track your code coverage over time, and ensure that all your new code is fully covered.

Retire Scanner detecting the use of JavaScript libraries with known vulnerabilities.

Howto to get started with contributions

$ git clone [email protected]:5orenso/preact-util.git
$ cd preact-util/
$ npm install

Start developing. Remember to start watching your files:

$ npm run test:watch

HOWTO fix eslint issues

$ eslint --fix lib/utilities.js

Howto contribute

$ git clone [email protected]:5orenso/preact-util.git

Do your magic and create a pull request.

Howto report issues

Use the Issue tracker

Howto update CHANGELOG.md

$ bash ./changelog.sh

Howto update NPM module

  1. Bump version inside package.json
  2. Push all changes to Github.
  3. Push all changes to npmjs.com: $ bash ./npm-release.sh.

Howto check for vulnerabilities in modules

# Install Node Security Platform CLI
$ npm install nsp --global  

# From inside your project directory
$ nsp check  

Howto upgrade modules

$ sudo npm install -g npm-check-updates
$ ncu -u -a
$ npm install --no-optional

Versioning

For transparency and insight into the release cycle, releases will be numbered with the follow format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backwards compatibility bumps the major
  • New additions without breaking backwards compatibility bumps the minor
  • Bug fixes and misc changes bump the patch

For more information on semantic versioning, please visit http://semver.org/.

Contributions and feedback:

We ❤️ contributions and feedback.

If you want to contribute, please check out the CONTRIBUTING.md file.

If you have any question or suggestion create an issue.

Bug reports should always be done with a new issue.

Other Resources

More about the author