feat: ✨ Created a mini nodeJS server with NewMan for testing without PostMan GUI.
This will mimic a run in a CD/CI environment or docker container.
This commit is contained in:
10
node_modules/intel/lib/utils/fn.js
generated
vendored
Normal file
10
node_modules/intel/lib/utils/fn.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
module.exports = function fn(args) {
|
||||
/*jshint evil: true*/
|
||||
console.log(args, [].slice.call(arguments, 1).join('\n'));
|
||||
return new Function(args, [].slice.call(arguments, 1).join('\n'));
|
||||
};
|
32
node_modules/intel/lib/utils/json.js
generated
vendored
Normal file
32
node_modules/intel/lib/utils/json.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// util to protect us from circular references when stringifying
|
||||
|
||||
'use strict';
|
||||
|
||||
function stringify(obj, indent) {
|
||||
var seen = [];
|
||||
return JSON.stringify(obj, function filter(key, val) {
|
||||
if (!val || typeof val !== 'object') {
|
||||
return val;
|
||||
} else if (seen.indexOf(val) !== -1) {
|
||||
return '[Circular]';
|
||||
}
|
||||
seen.push(val);
|
||||
return val;
|
||||
}, indent || 0);
|
||||
}
|
||||
|
||||
function nativeJson(obj, indent) {
|
||||
return indent ? JSON.stringify(obj, null, indent) : JSON.stringify(obj);
|
||||
}
|
||||
|
||||
module.exports = function json(obj, indent) {
|
||||
try {
|
||||
return nativeJson(obj, indent);
|
||||
} catch (e) {
|
||||
return stringify(obj, indent);
|
||||
}
|
||||
};
|
27
node_modules/intel/lib/utils/klass.js
generated
vendored
Normal file
27
node_modules/intel/lib/utils/klass.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const util = require('util');
|
||||
|
||||
function klass(ctor) {
|
||||
if (!(this instanceof klass)) {
|
||||
return new klass(ctor);
|
||||
}
|
||||
this._ctor = ctor;
|
||||
}
|
||||
|
||||
klass.prototype = {
|
||||
inherit: function inherit(par) {
|
||||
util.inherits(this._ctor, par);
|
||||
return this;
|
||||
},
|
||||
mixin: function mixin(other) {
|
||||
for (var k in other) {
|
||||
this._ctor.prototype[k] = other[k];
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = klass;
|
126
node_modules/intel/lib/utils/printf.js
generated
vendored
Normal file
126
node_modules/intel/lib/utils/printf.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const json = require('./json');
|
||||
|
||||
const RE = /%(-?\d+)?(\.-?\d+)?(:\d+)?(%|(\([^\)]+\))?([sdOj\?]))/g;
|
||||
|
||||
const toString = Object.prototype.toString;
|
||||
function type(x) {
|
||||
return toString.call(x).slice(8, -1).toLowerCase();
|
||||
}
|
||||
|
||||
function pad(str, value) {
|
||||
var isRight = false;
|
||||
|
||||
if(value < 0) {
|
||||
isRight = true;
|
||||
value = -value;
|
||||
}
|
||||
|
||||
if(str.length < value) {
|
||||
var padding = new Array(value - str.length + 1).join(' ');
|
||||
return isRight ? str + padding : padding + str;
|
||||
} else{
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
function truncate(str, value) {
|
||||
if(value > 0) {// truncate from begining
|
||||
return str.slice(-value);
|
||||
} else {// truncate from end
|
||||
return str.slice(0, -value);
|
||||
}
|
||||
}
|
||||
|
||||
function defaultFmt(x) {
|
||||
switch (type(x)) {
|
||||
case 'arguments':
|
||||
case 'object':
|
||||
return json(x);
|
||||
default:
|
||||
return String(x);
|
||||
}
|
||||
}
|
||||
|
||||
function printfNextValue(format, nextValFn) {
|
||||
var str = String(format).replace(RE,
|
||||
function(match, padding, trunc, indent, kind, name, type) {
|
||||
|
||||
if (kind === '%') {
|
||||
return '%';
|
||||
}
|
||||
|
||||
var val = nextValFn(name);
|
||||
|
||||
|
||||
var fmt = '';
|
||||
|
||||
switch (type) {
|
||||
case 's':
|
||||
fmt = String(val);
|
||||
break;
|
||||
case 'd':
|
||||
fmt = String(Number(val));
|
||||
break;
|
||||
case 'O':
|
||||
case 'j':
|
||||
fmt = json(val, indent && parseInt(indent.slice(1), 10));
|
||||
break;
|
||||
case '?':
|
||||
fmt = defaultFmt(val);
|
||||
break;
|
||||
}
|
||||
|
||||
if (trunc !== undefined) {
|
||||
fmt = truncate(fmt, trunc.slice(1));
|
||||
}
|
||||
|
||||
if (padding !== undefined) {
|
||||
fmt = pad(fmt, padding);
|
||||
}
|
||||
|
||||
return fmt;
|
||||
});
|
||||
return str;
|
||||
}
|
||||
|
||||
function printfObj(format, obj) {
|
||||
return printfNextValue(format, function(name) {
|
||||
name = name && name.slice(1, -1);
|
||||
return obj[name];
|
||||
});
|
||||
}
|
||||
|
||||
function printfArgs(format, args) {
|
||||
var i = 0;
|
||||
var len = args.length;
|
||||
var str = printfNextValue(format, function() {
|
||||
return args[i++];
|
||||
});
|
||||
if (len > 0) {
|
||||
for (var x = args[i]; i < len; x = args[++i]) {
|
||||
str += ' ' + defaultFmt(x);
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
// Usage:
|
||||
// printf('I am %d %s old', 4, 'years');
|
||||
// printf('%(name)s: %:2(message)j', { name: 'foo', message: { foo: 'bar' }});
|
||||
const OBJECT_FMT = /%([:\-]?\d+)?\([^\)]+\)[sdjO\?]/;
|
||||
module.exports = function printf(format, obj/*, ..args*/) {
|
||||
if (!OBJECT_FMT.test(format)) {
|
||||
var args = new Array(arguments.length - 1);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
args[i] = arguments[i + 1];
|
||||
}
|
||||
return printfArgs(format, args);
|
||||
} else {
|
||||
return printfObj(format, obj);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user