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

vue-filters-kit

v0.2.2

Published

A collection of useful custom filters for Vue.js(v2.x.x) apps.

Downloads

7

Readme

Vue-Filters-Kit

A collection of useful custom filters for Vue.js(v2.x.x) apps.

Demo

Click Here

This demo uses Bootstrap.css for styling. But you should know that no stylesheets are needed for using these filters in your webapps.

Filters

For now, vue-filters-kit contains 4 custom filters.

  1. Boolean Formatter - converts boolean values into human-readable texts, eg: true-->YES, 0-->Disabled.
  2. Byte Formatter - converts bytes to kilobytes or megabytes or gigabytes or terabytes, eg: 1000000-->976.56K.
  3. Percentage Formatter - converts numbers into percentage, eg: 0.1567-->15.67%.
  4. Timestamp Formatter - converts timestamps into human-readable time, eg: 1456989887000-->Thursday, March 3rd, 2016

Getting Started

  1. Install via npm:

     npm install vue-filters-kit --save
  2. Register these filters in your vue.js webapp:

     const App = new Vue({
         el: '#app',
         // register filters
         filters: {
             booleanFormat: require('vue-filters-kit/filters/booleanFormatter'),
             percentageFormat: require('vue-filters-kit/filters/percentageFormatter'),
             byteFormat: require('vue-filters-kit/filters/byteFormatter'),
             timestampFormat: require('vue-filters-kit/filters/timestampFormatter')
         }
     });

Usage

Boolean Formatter

{{ rawValue | booleanFormat([trueText], [falseText]) }}

[trueText] is the text that will show if rawValue equals to true.

[falseText] is the text that will show if rawValue equals to false.

For example:

<span>{{ isActive | booleanFormat('Yes', 'No') }}</span>

If isActive equals to true, the rendered html will be:

<span>Yes</span>

Else if isActive equals to false, the result will will be:

<span>No</span>

By default, [trueText] is 'Yes' and [falseText] is 'No'.

Byte Formatter

{{ rawValue | byteFormat }}

rawValue is a number whose unit is byte.

For example:

<span>{{ size | byteFormat }}</span>

If size equals to 1000000, the rendered html will be:

<span>976.56 K</span>

Percentage Formatter

{{ rawValue | percentageFormat([digit]) }}

[digit] is the number of digits to keep after decimal.

For example:

<span>{{ ratio | percentageFormat(4) }}</span>
<span>{{ ratio | percentageFormat(2) }}</span>

If ratio equals to 0.15666666, the rendered html will be:

<span>15.6667%</span>
<span>15.67%</span>

By default, [digit] is 2.

Timestamp Formatter

Timestamp Formatter depends on Moment.js. Make sure you have installed Moment.js via NPM.

{{ rawValue | timestampFormat([format]) }}

rawValue is a timestamp in milliseconds.

[format] is the format of the output time string.

For example:

<span>{{ startTime | timestampFormat('YYYY/MM/DD') }}</span>

If startTime equals to 1456989887000, the rendered html will be:

<span>2016/03/03</span>

By default, [format] is 'YYYY-MM-DD HH:mm:ss'. You can see more about [format] in Moment.js Documentation.

License

MIT