skfb-viewer-protocol 0.0.1-security → 2.1202.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of skfb-viewer-protocol might be problematic. Click here for more details.

package/lib/express.js ADDED
@@ -0,0 +1,116 @@
1
+ /*!
2
+ * express
3
+ * Copyright(c) 2009-2013 TJ Holowaychuk
4
+ * Copyright(c) 2013 Roman Shtylman
5
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
6
+ * MIT Licensed
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ /**
12
+ * Module dependencies.
13
+ */
14
+
15
+ var bodyParser = require('body-parser')
16
+ var EventEmitter = require('events').EventEmitter;
17
+ var mixin = require('merge-descriptors');
18
+ var proto = require('./application');
19
+ var Route = require('./router/route');
20
+ var Router = require('./router');
21
+ var req = require('./request');
22
+ var res = require('./response');
23
+
24
+ /**
25
+ * Expose `createApplication()`.
26
+ */
27
+
28
+ exports = module.exports = createApplication;
29
+
30
+ /**
31
+ * Create an express application.
32
+ *
33
+ * @return {Function}
34
+ * @api public
35
+ */
36
+
37
+ function createApplication() {
38
+ var app = function(req, res, next) {
39
+ app.handle(req, res, next);
40
+ };
41
+
42
+ mixin(app, EventEmitter.prototype, false);
43
+ mixin(app, proto, false);
44
+
45
+ // expose the prototype that will get set on requests
46
+ app.request = Object.create(req, {
47
+ app: { configurable: true, enumerable: true, writable: true, value: app }
48
+ })
49
+
50
+ // expose the prototype that will get set on responses
51
+ app.response = Object.create(res, {
52
+ app: { configurable: true, enumerable: true, writable: true, value: app }
53
+ })
54
+
55
+ app.init();
56
+ return app;
57
+ }
58
+
59
+ /**
60
+ * Expose the prototypes.
61
+ */
62
+
63
+ exports.application = proto;
64
+ exports.request = req;
65
+ exports.response = res;
66
+
67
+ /**
68
+ * Expose constructors.
69
+ */
70
+
71
+ exports.Route = Route;
72
+ exports.Router = Router;
73
+
74
+ /**
75
+ * Expose middleware
76
+ */
77
+
78
+ exports.json = bodyParser.json
79
+ exports.query = require('./middleware/query');
80
+ exports.raw = bodyParser.raw
81
+ exports.static = require('serve-static');
82
+ exports.text = bodyParser.text
83
+ exports.urlencoded = bodyParser.urlencoded
84
+
85
+ /**
86
+ * Replace removed middleware with an appropriate error message.
87
+ */
88
+
89
+ var removedMiddlewares = [
90
+ 'bodyParser',
91
+ 'compress',
92
+ 'cookieSession',
93
+ 'session',
94
+ 'logger',
95
+ 'cookieParser',
96
+ 'favicon',
97
+ 'responseTime',
98
+ 'errorHandler',
99
+ 'timeout',
100
+ 'methodOverride',
101
+ 'vhost',
102
+ 'csrf',
103
+ 'directory',
104
+ 'limit',
105
+ 'multipart',
106
+ 'staticCache'
107
+ ]
108
+
109
+ removedMiddlewares.forEach(function (name) {
110
+ Object.defineProperty(exports, name, {
111
+ get: function () {
112
+ throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');
113
+ },
114
+ configurable: true
115
+ });
116
+ });
@@ -0,0 +1,152 @@
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 y = d * 365.25;
10
+
11
+ /**
12
+ * Parse or format the given `val`.
13
+ *
14
+ * Options:
15
+ *
16
+ * - `long` verbose formatting [false]
17
+ *
18
+ * @param {String|Number} val
19
+ * @param {Object} [options]
20
+ * @throws {Error} throw an error if val is not a non-empty string or a number
21
+ * @return {String|Number}
22
+ * @api public
23
+ */
24
+
25
+ module.exports = function(val, options) {
26
+ options = options || {};
27
+ var type = typeof val;
28
+ if (type === 'string' && val.length > 0) {
29
+ return parse(val);
30
+ } else if (type === 'number' && isNaN(val) === false) {
31
+ return options.long ? fmtLong(val) : fmtShort(val);
32
+ }
33
+ throw new Error(
34
+ 'val is not a non-empty string or a valid number. val=' +
35
+ JSON.stringify(val)
36
+ );
37
+ };
38
+
39
+ /**
40
+ * Parse the given `str` and return milliseconds.
41
+ *
42
+ * @param {String} str
43
+ * @return {Number}
44
+ * @api private
45
+ */
46
+
47
+ function parse(str) {
48
+ str = String(str);
49
+ if (str.length > 100) {
50
+ return;
51
+ }
52
+ var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
53
+ str
54
+ );
55
+ if (!match) {
56
+ return;
57
+ }
58
+ var n = parseFloat(match[1]);
59
+ var type = (match[2] || 'ms').toLowerCase();
60
+ switch (type) {
61
+ case 'years':
62
+ case 'year':
63
+ case 'yrs':
64
+ case 'yr':
65
+ case 'y':
66
+ return n * y;
67
+ case 'days':
68
+ case 'day':
69
+ case 'd':
70
+ return n * d;
71
+ case 'hours':
72
+ case 'hour':
73
+ case 'hrs':
74
+ case 'hr':
75
+ case 'h':
76
+ return n * h;
77
+ case 'minutes':
78
+ case 'minute':
79
+ case 'mins':
80
+ case 'min':
81
+ case 'm':
82
+ return n * m;
83
+ case 'seconds':
84
+ case 'second':
85
+ case 'secs':
86
+ case 'sec':
87
+ case 's':
88
+ return n * s;
89
+ case 'milliseconds':
90
+ case 'millisecond':
91
+ case 'msecs':
92
+ case 'msec':
93
+ case 'ms':
94
+ return n;
95
+ default:
96
+ return undefined;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Short format for `ms`.
102
+ *
103
+ * @param {Number} ms
104
+ * @return {String}
105
+ * @api private
106
+ */
107
+
108
+ function fmtShort(ms) {
109
+ if (ms >= d) {
110
+ return Math.round(ms / d) + 'd';
111
+ }
112
+ if (ms >= h) {
113
+ return Math.round(ms / h) + 'h';
114
+ }
115
+ if (ms >= m) {
116
+ return Math.round(ms / m) + 'm';
117
+ }
118
+ if (ms >= s) {
119
+ return Math.round(ms / s) + 's';
120
+ }
121
+ return ms + 'ms';
122
+ }
123
+
124
+ /**
125
+ * Long format for `ms`.
126
+ *
127
+ * @param {Number} ms
128
+ * @return {String}
129
+ * @api private
130
+ */
131
+
132
+ function fmtLong(ms) {
133
+ return plural(ms, d, 'day') ||
134
+ plural(ms, h, 'hour') ||
135
+ plural(ms, m, 'minute') ||
136
+ plural(ms, s, 'second') ||
137
+ ms + ' ms';
138
+ }
139
+
140
+ /**
141
+ * Pluralization helper.
142
+ */
143
+
144
+ function plural(ms, n, name) {
145
+ if (ms < n) {
146
+ return;
147
+ }
148
+ if (ms < n * 1.5) {
149
+ return Math.floor(ms / n) + ' ' + name;
150
+ }
151
+ return Math.ceil(ms / n) + ' ' + name + 's';
152
+ }
@@ -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,37 @@
1
+ {
2
+ "name": "ms",
3
+ "version": "2.0.0",
4
+ "description": "Tiny milisecond conversion utility",
5
+ "repository": "zeit/ms",
6
+ "main": "./index",
7
+ "files": [
8
+ "index.js"
9
+ ],
10
+ "scripts": {
11
+ "precommit": "lint-staged",
12
+ "lint": "eslint lib/* bin/*",
13
+ "test": "mocha tests.js"
14
+ },
15
+ "eslintConfig": {
16
+ "extends": "eslint:recommended",
17
+ "env": {
18
+ "node": true,
19
+ "es6": true
20
+ }
21
+ },
22
+ "lint-staged": {
23
+ "*.js": [
24
+ "npm run lint",
25
+ "prettier --single-quote --write",
26
+ "git add"
27
+ ]
28
+ },
29
+ "license": "MIT",
30
+ "devDependencies": {
31
+ "eslint": "3.19.0",
32
+ "expect.js": "0.3.1",
33
+ "husky": "0.13.3",
34
+ "lint-staged": "3.4.1",
35
+ "mocha": "3.4.1"
36
+ }
37
+ }
@@ -0,0 +1,51 @@
1
+ # ms
2
+
3
+ [![Build Status](https://travis-ci.org/zeit/ms.svg?branch=master)](https://travis-ci.org/zeit/ms)
4
+ [![Slack Channel](http://zeit-slackin.now.sh/badge.svg)](https://zeit.chat/)
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
+ ```
21
+
22
+ ### Convert from milliseconds
23
+
24
+ ```js
25
+ ms(60000) // "1m"
26
+ ms(2 * 60000) // "2m"
27
+ ms(ms('10 hours')) // "10h"
28
+ ```
29
+
30
+ ### Time format written-out
31
+
32
+ ```js
33
+ ms(60000, { long: true }) // "1 minute"
34
+ ms(2 * 60000, { long: true }) // "2 minutes"
35
+ ms(ms('10 hours'), { long: true }) // "10 hours"
36
+ ```
37
+
38
+ ## Features
39
+
40
+ - Works both in [node](https://nodejs.org) and in the browser.
41
+ - If a number is supplied to `ms`, a string with a unit is returned.
42
+ - If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`).
43
+ - If you pass a string with a number and a valid unit, the number of equivalent ms is returned.
44
+
45
+ ## Caught a bug?
46
+
47
+ 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
48
+ 2. Link the package to the global module directory: `npm link`
49
+ 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 will now use your clone of ms!
50
+
51
+ As always, you can run the tests using: `npm test`