parse-rect

1.2.0 • Public • Published

parse-rect experimental Build Status

Take any rectangle-like argument and return rectangle values.

npm install parse-rect

const parseRect = require('parse-rect')
 
// {x: 10, y: 20, width: 90, height: 80}
parseRect('10 20 100 100')
parseRect(10, 20, 100, 100)
parseRect([10, 20, 100, 100])
parseRect({ x: 10, y: 20, width: 90, height: 80 })
parseRect({ x: 10, y: 20, w: 90, h: 80 })
parseRect({ l: 10, t: 20, r: 100, b: 100 })
parseRect({ left: 10, top: 20, right: 100, bottom: 100 })
 
// {x: 0, y: 0, width: 90, height: 80}
parseRect({ width: 90, height: 80 })
parseRect([ 90, 80 ])
 
// {x: 0, y: 0, width: 90, height: 90}
parseRect(90)
parseRect([90])

License

(c) 2018 Dmitry Yv. MIT License

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.2.0
    228,983
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.2.0
    228,983
  • 1.1.1
    15
  • 1.1.0
    0
  • 1.0.1
    1
  • 1.0.0
    0

Package Sidebar

Install

npm i parse-rect

Weekly Downloads

188,600

Version

1.2.0

License

MIT

Unpacked Size

6.51 kB

Total Files

7

Last publish

Collaborators

  • dfcreative