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

formatting

v1.0.6

Published

format value letter

Downloads

8

Readme

Formatting

Process data like value, file, url, array and object. Demo page: https://goo.gl/djJJ17

Installation

  1. node
npm install formatting --save
  1. browser
find node_modules/formatting/bin/browser.js
and use <script src=""></script> to require it

Usage

  1. node
import Formatting from 'formatting';

const valueFormat = new Formatting('value');
valueFormat.leading(1, 3, 0);
  1. browser
<script>
const valueFormat = new Formatting('value');
valueFormat.leading(1, 3, 0);
</script>

API

Create a Constructor like const format = new Formatting(type),and type is the mode which your data is. If you want to use all methods, type can be empty.

const format = new Formatting()

Object APIs | explan | return type ------------------------------------------ | ------------------------------------------------------------------- | ------------------- format.deepMerge(obj1, obj2) | Combine two nested object | object format.deepEuqal(obj1, obj2) | Compared two nested object(use deep-equal module) | boolean

Array APIs | explan | return type ------------------------------------------ | ------------------------------------------------------------------- | ------------------ format.arrayMerge(array1, array2) | Merge two nested array with non duplicate value. (array2 to array1) | array format.arraySameValue(array1, array2) | Compare two nested array, and get duplicate value | array format.arrayRemoveValue(array1, array2) | Remove children value that array2 has from array1 | array format.arrayNonrepeatValue(array1, array2) | Compare two nested array, and get non duplicate value | array

Value APIs | explan | return type ------------------------------------------ | --------------------------------------------------------------------|------------------- format.leading(value, length, letter) | value: the data you want to format. length the result string length. letter: fill leading character | string format.tailing(value, length, letter) | value: the data you want to format. length the result string length. letter: fill tailing character | string format.sequence(value, letter, number) | value: the data you want to format. letter: the character want to insert. number: loop number. | string format.insert(value, letter, start) | value: the data you want to format. letter: the character want to insert. start: insert index. | string format.replace(value, letter, replaceLetter) | value: the data you want to format. letter: the character want to be replaced. replaceLetter: the replace character. | string format.replaceWithRange(value, replaceLetter, start, end) | value: the data you want to format. replaceLetter: the replace character. start: replace start index. end: replace end index. | string

File APIs | explan | return type ------------------------------ | -------------|------------ format.file(selector) | Get input file info, selector is className / id / etc selector | array format.size(value) | Compute file size, minimal unit is Bytes | string format.duration(Second) | Convert Time to HH:MM:SS | string format.videoInfo(selector) | Get input file info with formatted size, type and duration. Selector is className / id / etc selector. The return value is promise, so if want to see the result, it would look like format.videoInfo(selector).then(data) => { console.log(data) } | promise format.imageInfo(selector) | Get input file info with formatted size and type. Selector is className / id / etc selector. The return value is promise, so if want to see the result, it would look like format.imageInfo(selector).then(data) => { console.log(data) } | promise

Url APIs | explan | return type ------------------------------ | -------------|------------ format.getHash(url) | Get url hash value, if url variable is empty, it will get location.href. | object format.getParamByName(url, name) | Get url param value with indicate name. If url variable is empty, it will get location.href. | string format.getParams(url) | Get all url params value. If url variable is empty, it will get location.href. | object