2.0.1 • Published 9 years ago

pixelify v2.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

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])

NameTypeDescription
valueMixedThe CSS value to pixelify
propertyStringThe name of the CSS property

Returns: Mixed, the pixelified value.

License

MIT