Comparing version 1.1.1 to 1.2.0
27
index.js
@@ -19,13 +19,25 @@ 'use strict' | ||
} | ||
else if (typeof arg === 'number') { | ||
arg = [arg] | ||
} | ||
// 0, 0, 100, 100 - array-like | ||
if (arg.length && typeof arg[0] === 'number') { | ||
if (arg.length === 2) { | ||
// [w, w] | ||
if (arg.length === 1) { | ||
rect = { | ||
width: arg[0], | ||
height: arg[0], | ||
x: 0, y: 0 | ||
} | ||
} | ||
// [w, h] | ||
else if (arg.length === 2) { | ||
rect = { | ||
width: arg[0], | ||
height: arg[1], | ||
x: 0, | ||
y: 0 | ||
x: 0, y: 0 | ||
} | ||
} | ||
// [l, t, r, b] | ||
else { | ||
@@ -40,2 +52,3 @@ rect = { | ||
} | ||
// {x, y, w, h} or {l, t, b, r} | ||
else if (arg) { | ||
@@ -45,6 +58,6 @@ arg = pick(arg, { | ||
top: 'y t top Top', | ||
width: 'w width', | ||
height: 'h height', | ||
bottom: 'b bottom', | ||
right: 'r right' | ||
width: 'w width W Width', | ||
height: 'h height W Width', | ||
bottom: 'b bottom Bottom', | ||
right: 'r right Right' | ||
}) | ||
@@ -51,0 +64,0 @@ |
{ | ||
"name": "parse-rect", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Parse any input rectangle format", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,2 +22,6 @@ # parse-rect [![experimental](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges) [![Build Status](https://travis-ci.org/dfcreative/parse-rect.png)](https://travis-ci.org/dfcreative/parse-rect) | ||
parseRect([ 90, 80 ]) | ||
// {x: 0, y: 0, width: 90, height: 90} | ||
parseRect(90) | ||
parseRect([90]) | ||
``` | ||
@@ -24,0 +28,0 @@ |
@@ -19,1 +19,3 @@ 'use strict' | ||
assert.deepEqual(parseRect([10, 20]), {width: 10, height: 20, x: 0, y: 0}) | ||
assert.deepEqual(parseRect(10), {width: 10, height: 10, x: 0, y: 0}) | ||
assert.deepEqual(parseRect([10]), {width: 10, height: 10, x: 0, y: 0}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6515
135
31
183883