This commit is contained in:
hatuhn
2019-09-13 09:44:33 +07:00
parent 1f1633e801
commit f14a34ba19
16798 changed files with 1652961 additions and 4327 deletions
+12
View File
@@ -0,0 +1,12 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
+2
View File
@@ -0,0 +1,2 @@
node_modules
coverage
+16
View File
@@ -0,0 +1,16 @@
# .travis.yml
language: node_js
git:
depth: 1
node_js:
- '6.3'
- '0.12'
notifications:
email: false
script: npm run travis
deploy:
- provider: npm
email: jim@vigour.io
api_key: ${NPM_TOKEN}
on:
branch: master
+13
View File
@@ -0,0 +1,13 @@
Copyright (c) 2016, Vigour.io
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+27
View File
@@ -0,0 +1,27 @@
# is-number-like
<!-- VDOC.badges travis; standard; npm; coveralls -->
<!-- DON'T EDIT THIS SECTION (including comments), INSTEAD RE-RUN `vdoc` TO UPDATE -->
[![Build Status](https://travis-ci.org/vigour-io/is-number-like.svg?branch=master)](https://travis-ci.org/vigour-io/is-number-like)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![npm version](https://badge.fury.io/js/is-number-like.svg)](https://badge.fury.io/js/is-number-like)
[![Coverage Status](https://coveralls.io/repos/github/vigour-io/is-number-like/badge.svg?branch=master)](https://coveralls.io/github/vigour-io/is-number-like?branch=master)
<!-- VDOC END -->
<!-- VDOC.jsdoc isNumberLike -->
<!-- DON'T EDIT THIS SECTION (including comments), INSTEAD RE-RUN `vdoc` TO UPDATE -->
#### var looksLikeNumber = isNumberLike(val)
Checks whether provided parameter looks like a number
- **val** (*any*) - the value to check
- **returns** (*boolean*) looksLikeNumber - `true` if `val` looks like a number, `false` otherwise
<!-- VDOC END -->
```javascript
const isNumberLike = require('is-number-like')
isNumberLike('2') // true
isNumberLike('a') // false
```
+54
View File
@@ -0,0 +1,54 @@
'use strict'
var isNumber = require('lodash.isfinite')
/**
* @id isNumberLike
* @function isNumberLike
* Checks whether provided parameter looks like a number
* @param {any} val - the value to check
* @returns {boolean} looksLikeNumber - `true` if `val` looks like a number, `false` otherwise
*/
module.exports = function isNumberLike (val) {
// fail
if (val === null || val === void 0 || val === false) {
return false
}
if (typeof val === 'function' || val instanceof Array) {
return false
}
var length = val.length
if (!length) {
return isNumber(val)
}
var i = 0
// charAt is faster in v8
if (val.charAt(0) === '-') {
if (length === 1) {
// fail do it
return false
}
i = 1
}
var foundE = false
var foundPeriod = false
for (; i < length; i++) {
var c = val.charAt(i)
// bit range is outside number range
if ((c <= '/' || c >= ':')) {
if (c === 'e') {
if (foundE) {
return false
}
foundE = true
} else if (c === '.') {
if (foundPeriod) {
return false
}
foundPeriod = true
} else {
return false
}
}
}
return true
}
+85
View File
@@ -0,0 +1,85 @@
{
"_from": "is-number-like@^1.0.3",
"_id": "is-number-like@1.0.8",
"_inBundle": false,
"_integrity": "sha512-6rZi3ezCyFcn5L71ywzz2bS5b2Igl1En3eTlZlvKjpz1n3IZLAYMbKYAIQgFmEu0GENg92ziU/faEOA/aixjbA==",
"_location": "/is-number-like",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "is-number-like@^1.0.3",
"name": "is-number-like",
"escapedName": "is-number-like",
"rawSpec": "^1.0.3",
"saveSpec": null,
"fetchSpec": "^1.0.3"
},
"_requiredBy": [
"/portscanner"
],
"_resolved": "https://registry.npmjs.org/is-number-like/-/is-number-like-1.0.8.tgz",
"_shasum": "2e129620b50891042e44e9bbbb30593e75cfbbe3",
"_spec": "is-number-like@^1.0.3",
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro/node_modules/portscanner",
"author": {
"name": "Vigour.io",
"email": "dev@vigour.io"
},
"browserify": {
"transform": [
"bubleify"
]
},
"bugs": {
"url": "https://github.com/vigour-io/is-number-like/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Jim De Beer",
"email": "jim@vigour.io"
},
{
"name": "Shawn Inder",
"email": "shawn@vigour.io"
}
],
"dependencies": {
"lodash.isfinite": "^3.3.2"
},
"deprecated": false,
"description": "Checks whether provided parameter looks like a number",
"devDependencies": {
"coveralls": "^2.11.9",
"ducktape": "^1.0.0",
"istanbul": "^0.4.4",
"nodemon": "^1.9.1",
"pre-commit": "^1.1.3",
"standard": "^8.1.0",
"tap-difflet": "0.6.0",
"tape": "4.4.0"
},
"engines": {},
"homepage": "https://github.com/vigour-io/is-number-like#readme",
"keywords": [
"is-number",
"typeof",
"number-like"
],
"license": "ISC",
"main": "lib/index.js",
"name": "is-number-like",
"repository": {
"type": "git",
"url": "git+https://github.com/vigour-io/is-number-like.git"
},
"scripts": {
"cover": "istanbul cover --report none --print detail test/index.js",
"test": "NODE_ENV=test node test | tap-difflet && standard",
"travis": "npm run cover -s && istanbul report lcov && ((cat coverage/lcov.info | coveralls) || exit 0)",
"view-cover": "istanbul report html && open ./coverage/index.html",
"watch": "nodemon test | tap-difflet"
},
"version": "1.0.8"
}
+39
View File
@@ -0,0 +1,39 @@
'use strict'
var test = require('tape')
var isNumberLike = require('..')
var testCases = [
// ['number', expectedResult]
[0, true],
['0', true],
[1.1, true],
['1.1', true],
[-1.1, true],
['-1.1', true],
['1.1.1', false],
[1.1e2, true],
['1.1e2', true],
['1e2e3', false],
['-', false],
[null, false],
['22221.2.e.34442', false],
[ '111a111', false ],
[[], false],
[[''], false],
[Number.EPSILON, true],
[Number.MAX_SAFE_INTEGER, true],
[Number.MAX_VALUE, true],
[Number.MIN_SAFE_INTEGER, true],
[Number.MIN_VALUE, true],
[Number.NaN, false],
[Number.NEGATIVE_INFINITY, false],
[Number.POSITIVE_INFINITY, false],
[function (arg1, arg2) {}, false]
]
test('isNumberLike', function (t) {
t.plan(testCases.length)
testCases.forEach(function (item) {
t.equals(isNumberLike(item[0]), item[1], 'isNumberLike(' + JSON.stringify(item[0]) + ') === ' + item[1])
})
})
+2738
View File
File diff suppressed because it is too large Load Diff