@mehmetb/rollup-plugin-node-builtins 3.0.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.
- package/README.md +101 -0
- package/dist/constants.js +474 -0
- package/dist/rollup-plugin-node-builtins.cjs.js +77 -0
- package/dist/rollup-plugin-node-builtins.es6.js +75 -0
- package/package.json +42 -0
- package/src/es6/assert.js +488 -0
- package/src/es6/console.js +13 -0
- package/src/es6/domain.js +100 -0
- package/src/es6/empty.js +1 -0
- package/src/es6/events.js +475 -0
- package/src/es6/http-lib/capability.js +52 -0
- package/src/es6/http-lib/request.js +278 -0
- package/src/es6/http-lib/response.js +185 -0
- package/src/es6/http-lib/to-arraybuffer.js +30 -0
- package/src/es6/http.js +167 -0
- package/src/es6/inherits.js +25 -0
- package/src/es6/os.js +113 -0
- package/src/es6/path.js +234 -0
- package/src/es6/punycode.js +475 -0
- package/src/es6/qs.js +147 -0
- package/src/es6/readable-stream/buffer-list.js +59 -0
- package/src/es6/readable-stream/duplex.js +45 -0
- package/src/es6/readable-stream/passthrough.js +15 -0
- package/src/es6/readable-stream/readable.js +896 -0
- package/src/es6/readable-stream/transform.js +174 -0
- package/src/es6/readable-stream/writable.js +483 -0
- package/src/es6/setimmediate.js +185 -0
- package/src/es6/stream.js +110 -0
- package/src/es6/string-decoder.js +220 -0
- package/src/es6/timers.js +76 -0
- package/src/es6/tty.js +20 -0
- package/src/es6/url.js +745 -0
- package/src/es6/util.js +598 -0
- package/src/es6/vm.js +202 -0
- package/src/es6/zlib-lib/LICENSE +21 -0
- package/src/es6/zlib-lib/adler32.js +31 -0
- package/src/es6/zlib-lib/binding.js +269 -0
- package/src/es6/zlib-lib/crc32.js +40 -0
- package/src/es6/zlib-lib/deflate.js +1862 -0
- package/src/es6/zlib-lib/inffast.js +325 -0
- package/src/es6/zlib-lib/inflate.js +1650 -0
- package/src/es6/zlib-lib/inftrees.js +329 -0
- package/src/es6/zlib-lib/messages.js +11 -0
- package/src/es6/zlib-lib/trees.js +1220 -0
- package/src/es6/zlib-lib/utils.js +73 -0
- package/src/es6/zlib-lib/zstream.js +28 -0
- package/src/es6/zlib.js +635 -0
- package/src/index.js +73 -0
package/src/es6/os.js
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
/*
|
2
|
+
The MIT License (MIT)
|
3
|
+
|
4
|
+
Copyright (c) 2016 CoderPuppy
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
23
|
+
|
24
|
+
*/
|
25
|
+
var _endianness;
|
26
|
+
export function endianness() {
|
27
|
+
if (typeof _endianness === 'undefined') {
|
28
|
+
var a = new ArrayBuffer(2);
|
29
|
+
var b = new Uint8Array(a);
|
30
|
+
var c = new Uint16Array(a);
|
31
|
+
b[0] = 1;
|
32
|
+
b[1] = 2;
|
33
|
+
if (c[0] === 258) {
|
34
|
+
_endianness = 'BE';
|
35
|
+
} else if (c[0] === 513){
|
36
|
+
_endianness = 'LE';
|
37
|
+
} else {
|
38
|
+
throw new Error('unable to figure out endianess');
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return _endianness;
|
42
|
+
}
|
43
|
+
|
44
|
+
export function hostname() {
|
45
|
+
if (typeof global.location !== 'undefined') {
|
46
|
+
return global.location.hostname
|
47
|
+
} else return '';
|
48
|
+
}
|
49
|
+
|
50
|
+
export function loadavg() {
|
51
|
+
return [];
|
52
|
+
}
|
53
|
+
|
54
|
+
export function uptime() {
|
55
|
+
return 0;
|
56
|
+
}
|
57
|
+
|
58
|
+
export function freemem() {
|
59
|
+
return Number.MAX_VALUE;
|
60
|
+
}
|
61
|
+
|
62
|
+
export function totalmem() {
|
63
|
+
return Number.MAX_VALUE;
|
64
|
+
}
|
65
|
+
|
66
|
+
export function cpus() {
|
67
|
+
return [];
|
68
|
+
}
|
69
|
+
|
70
|
+
export function type() {
|
71
|
+
return 'Browser';
|
72
|
+
}
|
73
|
+
|
74
|
+
export function release () {
|
75
|
+
if (typeof global.navigator !== 'undefined') {
|
76
|
+
return global.navigator.appVersion;
|
77
|
+
}
|
78
|
+
return '';
|
79
|
+
}
|
80
|
+
|
81
|
+
export function networkInterfaces(){}
|
82
|
+
export function getNetworkInterfaces(){}
|
83
|
+
|
84
|
+
export function arch() {
|
85
|
+
return 'javascript';
|
86
|
+
}
|
87
|
+
|
88
|
+
export function platform() {
|
89
|
+
return 'browser';
|
90
|
+
}
|
91
|
+
|
92
|
+
export function tmpDir() {
|
93
|
+
return '/tmp';
|
94
|
+
}
|
95
|
+
export var tmpdir = tmpDir;
|
96
|
+
|
97
|
+
export var EOL = '\n';
|
98
|
+
export default {
|
99
|
+
EOL: EOL,
|
100
|
+
tmpdir: tmpdir,
|
101
|
+
tmpDir: tmpDir,
|
102
|
+
networkInterfaces:networkInterfaces,
|
103
|
+
getNetworkInterfaces: getNetworkInterfaces,
|
104
|
+
release: release,
|
105
|
+
type: type,
|
106
|
+
cpus: cpus,
|
107
|
+
totalmem: totalmem,
|
108
|
+
freemem: freemem,
|
109
|
+
uptime: uptime,
|
110
|
+
loadavg: loadavg,
|
111
|
+
hostname: hostname,
|
112
|
+
endianness: endianness,
|
113
|
+
}
|
package/src/es6/path.js
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
2
|
+
//
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
// copy of this software and associated documentation files (the
|
5
|
+
// "Software"), to deal in the Software without restriction, including
|
6
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
+
// persons to whom the Software is furnished to do so, subject to the
|
9
|
+
// following conditions:
|
10
|
+
//
|
11
|
+
// The above copyright notice and this permission notice shall be included
|
12
|
+
// in all copies or substantial portions of the Software.
|
13
|
+
//
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
17
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
18
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
19
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
20
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
// resolves . and .. elements in a path array with directory names there
|
23
|
+
// must be no slashes, empty elements, or device names (c:\) in the array
|
24
|
+
// (so also no leading and trailing slashes - it does not distinguish
|
25
|
+
// relative and absolute paths)
|
26
|
+
function normalizeArray(parts, allowAboveRoot) {
|
27
|
+
// if the path tries to go above the root, `up` ends up > 0
|
28
|
+
var up = 0;
|
29
|
+
for (var i = parts.length - 1; i >= 0; i--) {
|
30
|
+
var last = parts[i];
|
31
|
+
if (last === '.') {
|
32
|
+
parts.splice(i, 1);
|
33
|
+
} else if (last === '..') {
|
34
|
+
parts.splice(i, 1);
|
35
|
+
up++;
|
36
|
+
} else if (up) {
|
37
|
+
parts.splice(i, 1);
|
38
|
+
up--;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
// if the path is allowed to go above the root, restore leading ..s
|
43
|
+
if (allowAboveRoot) {
|
44
|
+
for (; up--; up) {
|
45
|
+
parts.unshift('..');
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
return parts;
|
50
|
+
}
|
51
|
+
|
52
|
+
// Split a filename into [root, dir, basename, ext], unix version
|
53
|
+
// 'root' is just a slash, or nothing.
|
54
|
+
var splitPathRe =
|
55
|
+
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
56
|
+
var splitPath = function(filename) {
|
57
|
+
return splitPathRe.exec(filename).slice(1);
|
58
|
+
};
|
59
|
+
|
60
|
+
// path.resolve([from ...], to)
|
61
|
+
// posix version
|
62
|
+
export function resolve() {
|
63
|
+
var resolvedPath = '',
|
64
|
+
resolvedAbsolute = false;
|
65
|
+
|
66
|
+
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
67
|
+
var path = (i >= 0) ? arguments[i] : '/';
|
68
|
+
|
69
|
+
// Skip empty and invalid entries
|
70
|
+
if (typeof path !== 'string') {
|
71
|
+
throw new TypeError('Arguments to path.resolve must be strings');
|
72
|
+
} else if (!path) {
|
73
|
+
continue;
|
74
|
+
}
|
75
|
+
|
76
|
+
resolvedPath = path + '/' + resolvedPath;
|
77
|
+
resolvedAbsolute = path.charAt(0) === '/';
|
78
|
+
}
|
79
|
+
|
80
|
+
// At this point the path should be resolved to a full absolute path, but
|
81
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
82
|
+
|
83
|
+
// Normalize the path
|
84
|
+
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
85
|
+
return !!p;
|
86
|
+
}), !resolvedAbsolute).join('/');
|
87
|
+
|
88
|
+
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
89
|
+
};
|
90
|
+
|
91
|
+
// path.normalize(path)
|
92
|
+
// posix version
|
93
|
+
export function normalize(path) {
|
94
|
+
var isPathAbsolute = isAbsolute(path),
|
95
|
+
trailingSlash = substr(path, -1) === '/';
|
96
|
+
|
97
|
+
// Normalize the path
|
98
|
+
path = normalizeArray(filter(path.split('/'), function(p) {
|
99
|
+
return !!p;
|
100
|
+
}), !isPathAbsolute).join('/');
|
101
|
+
|
102
|
+
if (!path && !isPathAbsolute) {
|
103
|
+
path = '.';
|
104
|
+
}
|
105
|
+
if (path && trailingSlash) {
|
106
|
+
path += '/';
|
107
|
+
}
|
108
|
+
|
109
|
+
return (isPathAbsolute ? '/' : '') + path;
|
110
|
+
};
|
111
|
+
|
112
|
+
// posix version
|
113
|
+
export function isAbsolute(path) {
|
114
|
+
return path.charAt(0) === '/';
|
115
|
+
}
|
116
|
+
|
117
|
+
// posix version
|
118
|
+
export function join() {
|
119
|
+
var paths = Array.prototype.slice.call(arguments, 0);
|
120
|
+
return normalize(filter(paths, function(p, index) {
|
121
|
+
if (typeof p !== 'string') {
|
122
|
+
throw new TypeError('Arguments to path.join must be strings');
|
123
|
+
}
|
124
|
+
return p;
|
125
|
+
}).join('/'));
|
126
|
+
}
|
127
|
+
|
128
|
+
|
129
|
+
// path.relative(from, to)
|
130
|
+
// posix version
|
131
|
+
export function relative(from, to) {
|
132
|
+
from = resolve(from).substr(1);
|
133
|
+
to = resolve(to).substr(1);
|
134
|
+
|
135
|
+
function trim(arr) {
|
136
|
+
var start = 0;
|
137
|
+
for (; start < arr.length; start++) {
|
138
|
+
if (arr[start] !== '') break;
|
139
|
+
}
|
140
|
+
|
141
|
+
var end = arr.length - 1;
|
142
|
+
for (; end >= 0; end--) {
|
143
|
+
if (arr[end] !== '') break;
|
144
|
+
}
|
145
|
+
|
146
|
+
if (start > end) return [];
|
147
|
+
return arr.slice(start, end - start + 1);
|
148
|
+
}
|
149
|
+
|
150
|
+
var fromParts = trim(from.split('/'));
|
151
|
+
var toParts = trim(to.split('/'));
|
152
|
+
|
153
|
+
var length = Math.min(fromParts.length, toParts.length);
|
154
|
+
var samePartsLength = length;
|
155
|
+
for (var i = 0; i < length; i++) {
|
156
|
+
if (fromParts[i] !== toParts[i]) {
|
157
|
+
samePartsLength = i;
|
158
|
+
break;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
var outputParts = [];
|
163
|
+
for (var i = samePartsLength; i < fromParts.length; i++) {
|
164
|
+
outputParts.push('..');
|
165
|
+
}
|
166
|
+
|
167
|
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
168
|
+
|
169
|
+
return outputParts.join('/');
|
170
|
+
}
|
171
|
+
|
172
|
+
export var sep = '/';
|
173
|
+
export var delimiter = ':';
|
174
|
+
|
175
|
+
export function dirname(path) {
|
176
|
+
var result = splitPath(path),
|
177
|
+
root = result[0],
|
178
|
+
dir = result[1];
|
179
|
+
|
180
|
+
if (!root && !dir) {
|
181
|
+
// No dirname whatsoever
|
182
|
+
return '.';
|
183
|
+
}
|
184
|
+
|
185
|
+
if (dir) {
|
186
|
+
// It has a dirname, strip trailing slash
|
187
|
+
dir = dir.substr(0, dir.length - 1);
|
188
|
+
}
|
189
|
+
|
190
|
+
return root + dir;
|
191
|
+
}
|
192
|
+
|
193
|
+
export function basename(path, ext) {
|
194
|
+
var f = splitPath(path)[2];
|
195
|
+
// TODO: make this comparison case-insensitive on windows?
|
196
|
+
if (ext && f.substr(-1 * ext.length) === ext) {
|
197
|
+
f = f.substr(0, f.length - ext.length);
|
198
|
+
}
|
199
|
+
return f;
|
200
|
+
}
|
201
|
+
|
202
|
+
|
203
|
+
export function extname(path) {
|
204
|
+
return splitPath(path)[3];
|
205
|
+
}
|
206
|
+
export default {
|
207
|
+
extname: extname,
|
208
|
+
basename: basename,
|
209
|
+
dirname: dirname,
|
210
|
+
sep: sep,
|
211
|
+
delimiter: delimiter,
|
212
|
+
relative: relative,
|
213
|
+
join: join,
|
214
|
+
isAbsolute: isAbsolute,
|
215
|
+
normalize: normalize,
|
216
|
+
resolve: resolve
|
217
|
+
};
|
218
|
+
function filter (xs, f) {
|
219
|
+
if (xs.filter) return xs.filter(f);
|
220
|
+
var res = [];
|
221
|
+
for (var i = 0; i < xs.length; i++) {
|
222
|
+
if (f(xs[i], i, xs)) res.push(xs[i]);
|
223
|
+
}
|
224
|
+
return res;
|
225
|
+
}
|
226
|
+
|
227
|
+
// String.prototype.substr - negative index don't work in IE8
|
228
|
+
var substr = 'ab'.substr(-1) === 'b' ?
|
229
|
+
function (str, start, len) { return str.substr(start, len) } :
|
230
|
+
function (str, start, len) {
|
231
|
+
if (start < 0) start = str.length + start;
|
232
|
+
return str.substr(start, len);
|
233
|
+
}
|
234
|
+
;
|