Skip to content
/ parse-rect Public

Return rectangle object from any possible rect-like argument

License

Notifications You must be signed in to change notification settings

dy/parse-rect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Apr 3, 2018
1f98478 · Apr 3, 2018

History

10 Commits
Feb 12, 2018
Feb 12, 2018
Feb 12, 2018
Mar 19, 2018
Feb 12, 2018
Apr 3, 2018
Apr 3, 2018
Mar 19, 2018

Repository files navigation

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

About

Return rectangle object from any possible rect-like argument

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published