chime-ui 0.0.1-security → 101.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chime-ui might be problematic. Click here for more details.
- package/README.md +3 -3
- package/config/dev.env.js +37 -0
- package/config/hap.amend.js +29 -0
- package/config/index.js +8 -0
- package/config/prod.env.js +28 -0
- package/index.d.ts +130 -0
- package/index.js +1 -0
- package/package.json +44 -3
- package/src/index.html +12 -0
- package/src/lib/app.js +103 -0
- package/src/lib/axios/CHANGELOG.md +245 -0
- package/src/lib/axios/LICENSE +19 -0
- package/src/lib/axios/README.md +625 -0
- package/src/lib/axios/UPGRADE_GUIDE.md +162 -0
- package/src/lib/axios/dist/axios.js +1603 -0
- package/src/lib/axios/dist/axios.map +1 -0
- package/src/lib/axios/dist/axios.min.js +9 -0
- package/src/lib/axios/dist/axios.min.map +1 -0
- package/src/lib/axios/index.d.ts +131 -0
- package/src/lib/axios/index.js +1 -0
- package/src/lib/axios/lib/adapters/README.md +37 -0
- package/src/lib/axios/lib/adapters/http.js +237 -0
- package/src/lib/axios/lib/adapters/xhr.js +180 -0
- package/src/lib/axios/lib/axios.js +52 -0
- package/src/lib/axios/lib/cancel/Cancel.js +19 -0
- package/src/lib/axios/lib/cancel/CancelToken.js +57 -0
- package/src/lib/axios/lib/cancel/isCancel.js +5 -0
- package/src/lib/axios/lib/core/Axios.js +79 -0
- package/src/lib/axios/lib/core/InterceptorManager.js +52 -0
- package/src/lib/axios/lib/core/README.md +7 -0
- package/src/lib/axios/lib/core/createError.js +18 -0
- package/src/lib/axios/lib/core/dispatchRequest.js +86 -0
- package/src/lib/axios/lib/core/enhanceError.js +21 -0
- package/src/lib/axios/lib/core/settle.js +26 -0
- package/src/lib/axios/lib/core/transformData.js +20 -0
- package/src/lib/axios/lib/defaults.js +96 -0
- package/src/lib/axios/lib/helpers/README.md +7 -0
- package/src/lib/axios/lib/helpers/bind.js +11 -0
- package/src/lib/axios/lib/helpers/btoa.js +36 -0
- package/src/lib/axios/lib/helpers/buildURL.js +66 -0
- package/src/lib/axios/lib/helpers/combineURLs.js +14 -0
- package/src/lib/axios/lib/helpers/cookies.js +53 -0
- package/src/lib/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/src/lib/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/src/lib/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/src/lib/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/src/lib/axios/lib/helpers/parseHeaders.js +53 -0
- package/src/lib/axios/lib/helpers/spread.js +27 -0
- package/src/lib/axios/lib/utils.js +303 -0
- package/src/lib/axios/modules/debug/CHANGELOG.md +395 -0
- package/src/lib/axios/modules/debug/LICENSE +19 -0
- package/src/lib/axios/modules/debug/README.md +437 -0
- package/src/lib/axios/modules/debug/dist/debug.js +886 -0
- package/src/lib/axios/modules/debug/node.js +1 -0
- package/src/lib/axios/modules/debug/package.json +96 -0
- package/src/lib/axios/modules/debug/src/browser.js +180 -0
- package/src/lib/axios/modules/debug/src/common.js +249 -0
- package/src/lib/axios/modules/debug/src/index.js +12 -0
- package/src/lib/axios/modules/debug/src/node.js +174 -0
- package/src/lib/axios/modules/follow-redirects/LICENSE +18 -0
- package/src/lib/axios/modules/follow-redirects/README.md +145 -0
- package/src/lib/axios/modules/follow-redirects/http.js +1 -0
- package/src/lib/axios/modules/follow-redirects/https.js +1 -0
- package/src/lib/axios/modules/follow-redirects/index.js +452 -0
- package/src/lib/axios/modules/follow-redirects/package.json +92 -0
- package/src/lib/axios/modules/is-buffer/LICENSE +21 -0
- package/src/lib/axios/modules/is-buffer/README.md +53 -0
- package/src/lib/axios/modules/is-buffer/index.js +21 -0
- package/src/lib/axios/modules/is-buffer/package.json +90 -0
- package/src/lib/axios/modules/is-buffer/test/basic.js +24 -0
- package/src/lib/axios/modules/ms/index.js +162 -0
- package/src/lib/axios/modules/ms/license.md +21 -0
- package/src/lib/axios/modules/ms/package.json +72 -0
- package/src/lib/axios/modules/ms/readme.md +60 -0
- package/src/lib/axios/package-lock.json +10437 -0
- package/src/lib/axios/package.json +111 -0
- package/src/lib/axios.min.js +10 -0
- package/src/lib/axiosRequest.js +84 -0
- package/src/lib/bmob.js +36 -0
- package/src/lib/common.js +227 -0
- package/src/lib/config.dev.js +62 -0
- package/src/lib/config.js +69 -0
- package/src/lib/dataType.js +17 -0
- package/src/lib/error.js +32 -0
- package/src/lib/file.js +250 -0
- package/src/lib/hapRequest.js +68 -0
- package/src/lib/hapStorage.js +62 -0
- package/src/lib/init.js +0 -0
- package/src/lib/nodestorage.js +14 -0
- package/src/lib/pay.js +19 -0
- package/src/lib/pointer.js +18 -0
- package/src/lib/query.js +689 -0
- package/src/lib/relation.js +45 -0
- package/src/lib/request.js +21 -0
- package/src/lib/sms.js +40 -0
- package/src/lib/socket.js +292 -0
- package/src/lib/storage.js +21 -0
- package/src/lib/user.js +225 -0
- package/src/lib/utf8md5.js +205 -0
- package/src/lib/utils.js +61 -0
- package/src/lib/webstorage.js +32 -0
- package/src/lib/wxRequest.js +88 -0
- package/src/lib/wxstorage.js +27 -0
- package/src/main.js +27 -0
- package/test/index.html +15 -0
- package/test/index.js +12 -0
- package/tsconfig.json +100 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_from": "is-buffer@^1.1.5",
|
|
3
|
+
"_id": "is-buffer@1.1.6",
|
|
4
|
+
"_inBundle": false,
|
|
5
|
+
"_integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
|
|
6
|
+
"_location": "/is-buffer",
|
|
7
|
+
"_phantomChildren": {},
|
|
8
|
+
"_requested": {
|
|
9
|
+
"type": "range",
|
|
10
|
+
"registry": true,
|
|
11
|
+
"raw": "is-buffer@^1.1.5",
|
|
12
|
+
"name": "is-buffer",
|
|
13
|
+
"escapedName": "is-buffer",
|
|
14
|
+
"rawSpec": "^1.1.5",
|
|
15
|
+
"saveSpec": null,
|
|
16
|
+
"fetchSpec": "^1.1.5"
|
|
17
|
+
},
|
|
18
|
+
"_requiredBy": [
|
|
19
|
+
"#USER",
|
|
20
|
+
"/",
|
|
21
|
+
"/align-text/kind-of",
|
|
22
|
+
"/expand-range/kind-of",
|
|
23
|
+
"/has-values/kind-of",
|
|
24
|
+
"/http-proxy-middleware/kind-of",
|
|
25
|
+
"/is-accessor-descriptor/kind-of",
|
|
26
|
+
"/is-data-descriptor/kind-of",
|
|
27
|
+
"/is-number/kind-of",
|
|
28
|
+
"/karma/kind-of",
|
|
29
|
+
"/object-copy/kind-of",
|
|
30
|
+
"/snapdragon-util/kind-of",
|
|
31
|
+
"/to-object-path/kind-of",
|
|
32
|
+
"/watchpack/kind-of"
|
|
33
|
+
],
|
|
34
|
+
"_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
|
35
|
+
"_shasum": "efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be",
|
|
36
|
+
"_spec": "is-buffer@^1.1.5",
|
|
37
|
+
"_where": "F:\\项目\\hydrogen-js-sdk\\src\\lib\\axios",
|
|
38
|
+
"author": {
|
|
39
|
+
"name": "Feross Aboukhadijeh",
|
|
40
|
+
"email": "feross@feross.org",
|
|
41
|
+
"url": "http://feross.org/"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/feross/is-buffer/issues"
|
|
45
|
+
},
|
|
46
|
+
"bundleDependencies": false,
|
|
47
|
+
"dependencies": {},
|
|
48
|
+
"deprecated": false,
|
|
49
|
+
"description": "Determine if an object is a Buffer",
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"standard": "*",
|
|
52
|
+
"tape": "^4.0.0",
|
|
53
|
+
"zuul": "^3.0.0"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://github.com/feross/is-buffer#readme",
|
|
56
|
+
"keywords": [
|
|
57
|
+
"buffer",
|
|
58
|
+
"buffers",
|
|
59
|
+
"type",
|
|
60
|
+
"core buffer",
|
|
61
|
+
"browser buffer",
|
|
62
|
+
"browserify",
|
|
63
|
+
"typed array",
|
|
64
|
+
"uint32array",
|
|
65
|
+
"int16array",
|
|
66
|
+
"int32array",
|
|
67
|
+
"float32array",
|
|
68
|
+
"float64array",
|
|
69
|
+
"browser",
|
|
70
|
+
"arraybuffer",
|
|
71
|
+
"dataview"
|
|
72
|
+
],
|
|
73
|
+
"license": "MIT",
|
|
74
|
+
"main": "index.js",
|
|
75
|
+
"name": "is-buffer",
|
|
76
|
+
"repository": {
|
|
77
|
+
"type": "git",
|
|
78
|
+
"url": "git://github.com/feross/is-buffer.git"
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"test": "standard && npm run test-node && npm run test-browser",
|
|
82
|
+
"test-browser": "zuul -- test/*.js",
|
|
83
|
+
"test-browser-local": "zuul --local -- test/*.js",
|
|
84
|
+
"test-node": "tape test/*.js"
|
|
85
|
+
},
|
|
86
|
+
"testling": {
|
|
87
|
+
"files": "test/*.js"
|
|
88
|
+
},
|
|
89
|
+
"version": "1.1.6"
|
|
90
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var isBuffer = require('../')
|
|
2
|
+
var test = require('tape')
|
|
3
|
+
|
|
4
|
+
test('is-buffer', function (t) {
|
|
5
|
+
t.equal(isBuffer(Buffer.alloc(4)), true, 'new Buffer(4)')
|
|
6
|
+
t.equal(isBuffer(Buffer.allocUnsafeSlow(100)), true, 'SlowBuffer(100)')
|
|
7
|
+
|
|
8
|
+
t.equal(isBuffer(undefined), false, 'undefined')
|
|
9
|
+
t.equal(isBuffer(null), false, 'null')
|
|
10
|
+
t.equal(isBuffer(''), false, 'empty string')
|
|
11
|
+
t.equal(isBuffer(true), false, 'true')
|
|
12
|
+
t.equal(isBuffer(false), false, 'false')
|
|
13
|
+
t.equal(isBuffer(0), false, '0')
|
|
14
|
+
t.equal(isBuffer(1), false, '1')
|
|
15
|
+
t.equal(isBuffer(1.0), false, '1.0')
|
|
16
|
+
t.equal(isBuffer('string'), false, 'string')
|
|
17
|
+
t.equal(isBuffer({}), false, '{}')
|
|
18
|
+
t.equal(isBuffer([]), false, '[]')
|
|
19
|
+
t.equal(isBuffer(function foo () {}), false, 'function foo () {}')
|
|
20
|
+
t.equal(isBuffer({ isBuffer: null }), false, '{ isBuffer: null }')
|
|
21
|
+
t.equal(isBuffer({ isBuffer: function () { throw new Error() } }), false, '{ isBuffer: function () { throw new Error() } }')
|
|
22
|
+
|
|
23
|
+
t.end()
|
|
24
|
+
})
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
var s = 1000;
|
|
6
|
+
var m = s * 60;
|
|
7
|
+
var h = m * 60;
|
|
8
|
+
var d = h * 24;
|
|
9
|
+
var w = d * 7;
|
|
10
|
+
var y = d * 365.25;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parse or format the given `val`.
|
|
14
|
+
*
|
|
15
|
+
* Options:
|
|
16
|
+
*
|
|
17
|
+
* - `long` verbose formatting [false]
|
|
18
|
+
*
|
|
19
|
+
* @param {String|Number} val
|
|
20
|
+
* @param {Object} [options]
|
|
21
|
+
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
22
|
+
* @return {String|Number}
|
|
23
|
+
* @api public
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
module.exports = function(val, options) {
|
|
27
|
+
options = options || {};
|
|
28
|
+
var type = typeof val;
|
|
29
|
+
if (type === 'string' && val.length > 0) {
|
|
30
|
+
return parse(val);
|
|
31
|
+
} else if (type === 'number' && isFinite(val)) {
|
|
32
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
33
|
+
}
|
|
34
|
+
throw new Error(
|
|
35
|
+
'val is not a non-empty string or a valid number. val=' +
|
|
36
|
+
JSON.stringify(val)
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Parse the given `str` and return milliseconds.
|
|
42
|
+
*
|
|
43
|
+
* @param {String} str
|
|
44
|
+
* @return {Number}
|
|
45
|
+
* @api private
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function parse(str) {
|
|
49
|
+
str = String(str);
|
|
50
|
+
if (str.length > 100) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
54
|
+
str
|
|
55
|
+
);
|
|
56
|
+
if (!match) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var n = parseFloat(match[1]);
|
|
60
|
+
var type = (match[2] || 'ms').toLowerCase();
|
|
61
|
+
switch (type) {
|
|
62
|
+
case 'years':
|
|
63
|
+
case 'year':
|
|
64
|
+
case 'yrs':
|
|
65
|
+
case 'yr':
|
|
66
|
+
case 'y':
|
|
67
|
+
return n * y;
|
|
68
|
+
case 'weeks':
|
|
69
|
+
case 'week':
|
|
70
|
+
case 'w':
|
|
71
|
+
return n * w;
|
|
72
|
+
case 'days':
|
|
73
|
+
case 'day':
|
|
74
|
+
case 'd':
|
|
75
|
+
return n * d;
|
|
76
|
+
case 'hours':
|
|
77
|
+
case 'hour':
|
|
78
|
+
case 'hrs':
|
|
79
|
+
case 'hr':
|
|
80
|
+
case 'h':
|
|
81
|
+
return n * h;
|
|
82
|
+
case 'minutes':
|
|
83
|
+
case 'minute':
|
|
84
|
+
case 'mins':
|
|
85
|
+
case 'min':
|
|
86
|
+
case 'm':
|
|
87
|
+
return n * m;
|
|
88
|
+
case 'seconds':
|
|
89
|
+
case 'second':
|
|
90
|
+
case 'secs':
|
|
91
|
+
case 'sec':
|
|
92
|
+
case 's':
|
|
93
|
+
return n * s;
|
|
94
|
+
case 'milliseconds':
|
|
95
|
+
case 'millisecond':
|
|
96
|
+
case 'msecs':
|
|
97
|
+
case 'msec':
|
|
98
|
+
case 'ms':
|
|
99
|
+
return n;
|
|
100
|
+
default:
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Short format for `ms`.
|
|
107
|
+
*
|
|
108
|
+
* @param {Number} ms
|
|
109
|
+
* @return {String}
|
|
110
|
+
* @api private
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
function fmtShort(ms) {
|
|
114
|
+
var msAbs = Math.abs(ms);
|
|
115
|
+
if (msAbs >= d) {
|
|
116
|
+
return Math.round(ms / d) + 'd';
|
|
117
|
+
}
|
|
118
|
+
if (msAbs >= h) {
|
|
119
|
+
return Math.round(ms / h) + 'h';
|
|
120
|
+
}
|
|
121
|
+
if (msAbs >= m) {
|
|
122
|
+
return Math.round(ms / m) + 'm';
|
|
123
|
+
}
|
|
124
|
+
if (msAbs >= s) {
|
|
125
|
+
return Math.round(ms / s) + 's';
|
|
126
|
+
}
|
|
127
|
+
return ms + 'ms';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Long format for `ms`.
|
|
132
|
+
*
|
|
133
|
+
* @param {Number} ms
|
|
134
|
+
* @return {String}
|
|
135
|
+
* @api private
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
function fmtLong(ms) {
|
|
139
|
+
var msAbs = Math.abs(ms);
|
|
140
|
+
if (msAbs >= d) {
|
|
141
|
+
return plural(ms, msAbs, d, 'day');
|
|
142
|
+
}
|
|
143
|
+
if (msAbs >= h) {
|
|
144
|
+
return plural(ms, msAbs, h, 'hour');
|
|
145
|
+
}
|
|
146
|
+
if (msAbs >= m) {
|
|
147
|
+
return plural(ms, msAbs, m, 'minute');
|
|
148
|
+
}
|
|
149
|
+
if (msAbs >= s) {
|
|
150
|
+
return plural(ms, msAbs, s, 'second');
|
|
151
|
+
}
|
|
152
|
+
return ms + ' ms';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Pluralization helper.
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
function plural(ms, msAbs, n, name) {
|
|
160
|
+
var isPlural = msAbs >= n * 1.5;
|
|
161
|
+
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
|
162
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Zeit, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_args": [
|
|
3
|
+
[
|
|
4
|
+
"ms@2.1.2",
|
|
5
|
+
"F:\\项目\\hydrogen-js-sdk\\src\\lib\\axios"
|
|
6
|
+
]
|
|
7
|
+
],
|
|
8
|
+
"_from": "ms@2.1.2",
|
|
9
|
+
"_id": "ms@2.1.2",
|
|
10
|
+
"_inBundle": false,
|
|
11
|
+
"_integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
|
12
|
+
"_location": "/ms",
|
|
13
|
+
"_phantomChildren": {},
|
|
14
|
+
"_requested": {
|
|
15
|
+
"type": "version",
|
|
16
|
+
"registry": true,
|
|
17
|
+
"raw": "ms@2.1.2",
|
|
18
|
+
"name": "ms",
|
|
19
|
+
"escapedName": "ms",
|
|
20
|
+
"rawSpec": "2.1.2",
|
|
21
|
+
"saveSpec": null,
|
|
22
|
+
"fetchSpec": "2.1.2"
|
|
23
|
+
},
|
|
24
|
+
"_requiredBy": [
|
|
25
|
+
"/debug"
|
|
26
|
+
],
|
|
27
|
+
"_resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
|
28
|
+
"_spec": "2.1.2",
|
|
29
|
+
"_where": "F:\\项目\\hydrogen-js-sdk\\src\\lib\\axios",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/zeit/ms/issues"
|
|
32
|
+
},
|
|
33
|
+
"description": "Tiny millisecond conversion utility",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"eslint": "4.12.1",
|
|
36
|
+
"expect.js": "0.3.1",
|
|
37
|
+
"husky": "0.14.3",
|
|
38
|
+
"lint-staged": "5.0.0",
|
|
39
|
+
"mocha": "4.0.1"
|
|
40
|
+
},
|
|
41
|
+
"eslintConfig": {
|
|
42
|
+
"extends": "eslint:recommended",
|
|
43
|
+
"env": {
|
|
44
|
+
"node": true,
|
|
45
|
+
"es6": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"index.js"
|
|
50
|
+
],
|
|
51
|
+
"homepage": "https://github.com/zeit/ms#readme",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"lint-staged": {
|
|
54
|
+
"*.js": [
|
|
55
|
+
"npm run lint",
|
|
56
|
+
"prettier --single-quote --write",
|
|
57
|
+
"git add"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"main": "./index",
|
|
61
|
+
"name": "ms",
|
|
62
|
+
"repository": {
|
|
63
|
+
"type": "git",
|
|
64
|
+
"url": "git+https://github.com/zeit/ms.git"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"lint": "eslint lib/* bin/*",
|
|
68
|
+
"precommit": "lint-staged",
|
|
69
|
+
"test": "mocha tests.js"
|
|
70
|
+
},
|
|
71
|
+
"version": "2.1.2"
|
|
72
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# ms
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/zeit/ms)
|
|
4
|
+
[](https://spectrum.chat/zeit)
|
|
5
|
+
|
|
6
|
+
Use this package to easily convert various time formats to milliseconds.
|
|
7
|
+
|
|
8
|
+
## Examples
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
ms('2 days') // 172800000
|
|
12
|
+
ms('1d') // 86400000
|
|
13
|
+
ms('10h') // 36000000
|
|
14
|
+
ms('2.5 hrs') // 9000000
|
|
15
|
+
ms('2h') // 7200000
|
|
16
|
+
ms('1m') // 60000
|
|
17
|
+
ms('5s') // 5000
|
|
18
|
+
ms('1y') // 31557600000
|
|
19
|
+
ms('100') // 100
|
|
20
|
+
ms('-3 days') // -259200000
|
|
21
|
+
ms('-1h') // -3600000
|
|
22
|
+
ms('-200') // -200
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Convert from Milliseconds
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
ms(60000) // "1m"
|
|
29
|
+
ms(2 * 60000) // "2m"
|
|
30
|
+
ms(-3 * 60000) // "-3m"
|
|
31
|
+
ms(ms('10 hours')) // "10h"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Time Format Written-Out
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
ms(60000, { long: true }) // "1 minute"
|
|
38
|
+
ms(2 * 60000, { long: true }) // "2 minutes"
|
|
39
|
+
ms(-3 * 60000, { long: true }) // "-3 minutes"
|
|
40
|
+
ms(ms('10 hours'), { long: true }) // "10 hours"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- Works both in [Node.js](https://nodejs.org) and in the browser
|
|
46
|
+
- If a number is supplied to `ms`, a string with a unit is returned
|
|
47
|
+
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
|
|
48
|
+
- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
|
|
49
|
+
|
|
50
|
+
## Related Packages
|
|
51
|
+
|
|
52
|
+
- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
|
|
53
|
+
|
|
54
|
+
## Caught a Bug?
|
|
55
|
+
|
|
56
|
+
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
|
57
|
+
2. Link the package to the global module directory: `npm link`
|
|
58
|
+
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
|
|
59
|
+
|
|
60
|
+
As always, you can run the tests using: `npm test`
|