pixelify

2.0.1 • Public • Published

pixelify

Build status NPM version js-xo-style

Append "px" to a number, if it's appropriate

Installation

Install pixelify using npm:

npm install --save pixelify

Usage

Module usage

var pixelify = require('pixelify');
 
pixelify(5);
// '5px'
pixelify(1, 'opacity');
// 1
pixelify(0, 'margin');
// 0
pixelify(10, 'margin');
// '10px'

pixelify does not append "px" to zero values or properties in this list:

  • box-flex
  • box-flex-group
  • column-count
  • fill-opacity
  • flex
  • flex-grow
  • flex-positive
  • flex-shrink
  • flex-negative
  • font-weight
  • line-clamp
  • line-height
  • opacity
  • order
  • orphans
  • stroke-opacity
  • widows
  • z-index
  • zoom

pixelify accepts a camel cased or dash cased property name.

API

pixelify(value [, property])

Name Type Description
value Mixed The CSS value to pixelify
property String The name of the CSS property

Returns: Mixed, the pixelified value.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i pixelify

Weekly Downloads

0

Version

2.0.1

License

MIT

Last publish

Collaborators

  • joakimbeng