UNPKG

1.34 kBJavaScriptView Raw
1
2var fs = require("fs")
3
4if (!Buffer.from) {
5 // Added in: v5.10.0
6 Buffer.from = Buffer.allocUnsafe = function(arg, enc, len) {
7 return new Buffer(arg, enc, len)
8 }
9 Buffer.allocUnsafe = function(len) {
10 return new Buffer(len)
11 }
12 Buffer.alloc = function (len, fill, enc) {
13 return new Buffer(len).fill(fill, enc)
14 }
15}
16
17if (!fs.copyFileSync) {
18 // Added in: v8.5.0
19 fs.copyFileSync = function(src, dest, mode) {
20 fs.writeFileSync(dest, fs.readFileSync(src))
21 }
22}
23
24if (!process.versions) {
25 process.versions = {}
26 if (process.iotjs) process.versions.iotjs = process.version
27}
28
29if (!process.hrtime) {
30 // for iotjs
31 process.hrtime = function(diff) {
32 var now = (new Date()).getTime() * 1e-3
33 , sec = Math.floor(now)
34 , nano = Math.floor((now%1) * 1e9)
35 if (diff) {
36 sec -= diff[0]
37 nano -= diff[1]
38 if (nano < 0) {
39 sec--
40 nano += 1e9
41 }
42 }
43 return [sec, nano]
44 }
45}
46
47if (!Object.assign) {
48 Object.assign = function(a) {
49 // jshint boss:true
50 var t,k,i=1,A=arguments,l=A.length
51 for (; i<l; ) if (t=A[i++]) for(k in t) if(Object.prototype.hasOwnProperty.call(t,k)) {
52 a[k]=t[k]
53 }
54 return a
55 }
56}
57
58
59module.exports.version = process.versions.litejs = require("./package.json").version
60module.exports.server = require("./server")
61module.exports.log = require("./log")
62module.exports.log.debug(process.env.DEBUG)
63
64
65