mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Improve reIsUint to filter strings like '0001' and add tests.
This commit is contained in:
committed by
John-David Dalton
parent
7e726735ba
commit
c7ef030ef5
@@ -132,7 +132,7 @@
|
|||||||
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
||||||
|
|
||||||
/** Used to detect unsigned integer values. */
|
/** Used to detect unsigned integer values. */
|
||||||
var reIsUint = /^\d+$/;
|
var reIsUint = /^(?:\d|[1-9]\d+)$/;
|
||||||
|
|
||||||
/** Used to match latin-1 supplementary letters (excluding mathematical operators). */
|
/** Used to match latin-1 supplementary letters (excluding mathematical operators). */
|
||||||
var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
|
var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
|
||||||
|
|||||||
@@ -734,6 +734,7 @@
|
|||||||
|
|
||||||
if (func) {
|
if (func) {
|
||||||
assert.strictEqual(func(0), true);
|
assert.strictEqual(func(0), true);
|
||||||
|
assert.strictEqual(func('0'), true);
|
||||||
assert.strictEqual(func('1'), true);
|
assert.strictEqual(func('1'), true);
|
||||||
assert.strictEqual(func(3, 4), true);
|
assert.strictEqual(func(3, 4), true);
|
||||||
assert.strictEqual(func(MAX_SAFE_INTEGER - 1), true);
|
assert.strictEqual(func(MAX_SAFE_INTEGER - 1), true);
|
||||||
@@ -748,6 +749,8 @@
|
|||||||
|
|
||||||
if (func) {
|
if (func) {
|
||||||
assert.strictEqual(func('1abc'), false);
|
assert.strictEqual(func('1abc'), false);
|
||||||
|
assert.strictEqual(func('07'), false);
|
||||||
|
assert.strictEqual(func('0001'), false);
|
||||||
assert.strictEqual(func(-1), false);
|
assert.strictEqual(func(-1), false);
|
||||||
assert.strictEqual(func(3, 3), false);
|
assert.strictEqual(func(3, 3), false);
|
||||||
assert.strictEqual(func(1.1), false);
|
assert.strictEqual(func(1.1), false);
|
||||||
|
|||||||
Reference in New Issue
Block a user