@hpcc-js/util
Advanced tools
Comparing version 0.0.14 to 0.0.17
@@ -1,42 +0,52 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Dictionary = (function () { | ||
function Dictionary(attrs) { | ||
this.store = {}; | ||
if (attrs) { | ||
for (var key in attrs) { | ||
this.set(key, attrs[key]); | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Dictionary = (function () { | ||
function Dictionary(attrs) { | ||
this.store = {}; | ||
if (attrs) { | ||
for (var key in attrs) { | ||
this.set(key, attrs[key]); | ||
} | ||
} | ||
} | ||
} | ||
Dictionary.prototype.set = function (key, value) { | ||
var retVal = this.store[key]; | ||
this.store[key] = value; | ||
return retVal; | ||
}; | ||
Dictionary.prototype.get = function (key) { | ||
return this.store[key]; | ||
}; | ||
Dictionary.prototype.has = function (key) { | ||
return this.store[key] !== undefined; | ||
}; | ||
Dictionary.prototype.remove = function (key) { | ||
delete this.store[key]; | ||
}; | ||
Dictionary.prototype.keys = function () { | ||
var retVal = []; | ||
for (var key in this.store) { | ||
retVal.push(key); | ||
} | ||
return retVal; | ||
}; | ||
Dictionary.prototype.values = function () { | ||
var retVal = []; | ||
for (var key in this.store) { | ||
retVal.push(this.store[key]); | ||
} | ||
return retVal; | ||
}; | ||
return Dictionary; | ||
}()); | ||
exports.Dictionary = Dictionary; | ||
Dictionary.prototype.set = function (key, value) { | ||
var retVal = this.store[key]; | ||
this.store[key] = value; | ||
return retVal; | ||
}; | ||
Dictionary.prototype.get = function (key) { | ||
return this.store[key]; | ||
}; | ||
Dictionary.prototype.has = function (key) { | ||
return this.store[key] !== undefined; | ||
}; | ||
Dictionary.prototype.remove = function (key) { | ||
delete this.store[key]; | ||
}; | ||
Dictionary.prototype.keys = function () { | ||
var retVal = []; | ||
for (var key in this.store) { | ||
retVal.push(key); | ||
} | ||
return retVal; | ||
}; | ||
Dictionary.prototype.values = function () { | ||
var retVal = []; | ||
for (var key in this.store) { | ||
retVal.push(this.store[key]); | ||
} | ||
return retVal; | ||
}; | ||
return Dictionary; | ||
}()); | ||
exports.Dictionary = Dictionary; | ||
}); |
@@ -0,8 +1,13 @@ | ||
export * from "./cache"; | ||
export * from "./dictionary"; | ||
export * from "./esp"; | ||
export * from "./graph"; | ||
export * from "./logging"; | ||
export * from "./object"; | ||
export * from "./observer"; | ||
export * from "./platform"; | ||
export * from "./saxParser"; | ||
export * from "./stack"; | ||
export * from "./stateful"; | ||
export * from "./string"; | ||
export * from "./url"; |
@@ -1,13 +0,28 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./dictionary")); | ||
__export(require("./logging")); | ||
__export(require("./object")); | ||
__export(require("./platform")); | ||
__export(require("./saxParser")); | ||
__export(require("./stack")); | ||
__export(require("./string")); | ||
__export(require("./url")); | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./cache", "./dictionary", "./esp", "./graph", "./logging", "./object", "./observer", "./platform", "./saxParser", "./stack", "./stateful", "./string", "./url"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./cache")); | ||
__export(require("./dictionary")); | ||
__export(require("./esp")); | ||
__export(require("./graph")); | ||
__export(require("./logging")); | ||
__export(require("./object")); | ||
__export(require("./observer")); | ||
__export(require("./platform")); | ||
__export(require("./saxParser")); | ||
__export(require("./stack")); | ||
__export(require("./stateful")); | ||
__export(require("./string")); | ||
__export(require("./url")); | ||
}); |
@@ -1,176 +0,184 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var stack_1 = require("./stack"); | ||
var platform_1 = require("./platform"); | ||
var Level; | ||
(function (Level) { | ||
Level[Level["debug"] = 0] = "debug"; | ||
Level[Level["info"] = 1] = "info"; | ||
Level[Level["notice"] = 2] = "notice"; | ||
Level[Level["warning"] = 3] = "warning"; | ||
Level[Level["error"] = 4] = "error"; | ||
Level[Level["critical"] = 5] = "critical"; | ||
Level[Level["alert"] = 6] = "alert"; | ||
Level[Level["emergency"] = 7] = "emergency"; | ||
})(Level = exports.Level || (exports.Level = {})); | ||
var colours = { | ||
debug: "cyan", | ||
info: "green", | ||
notice: "grey", | ||
warning: "blue", | ||
error: "red", | ||
critical: "magenta", | ||
alert: "magenta", | ||
emergency: "magenta" | ||
}; | ||
var ConsoleWriter = (function () { | ||
function ConsoleWriter() { | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
ConsoleWriter.prototype.write = function (dateTime, level, id, msg) { | ||
if (platform_1.isNode) { | ||
// tslint:disable-next-line:no-console | ||
console.log("[" + dateTime + "] " + Level[level].toUpperCase() + " " + id + ": " + msg); | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./stack", "./platform"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var stack_1 = require("./stack"); | ||
var platform_1 = require("./platform"); | ||
var Level; | ||
(function (Level) { | ||
Level[Level["debug"] = 0] = "debug"; | ||
Level[Level["info"] = 1] = "info"; | ||
Level[Level["notice"] = 2] = "notice"; | ||
Level[Level["warning"] = 3] = "warning"; | ||
Level[Level["error"] = 4] = "error"; | ||
Level[Level["critical"] = 5] = "critical"; | ||
Level[Level["alert"] = 6] = "alert"; | ||
Level[Level["emergency"] = 7] = "emergency"; | ||
})(Level = exports.Level || (exports.Level = {})); | ||
var colours = { | ||
debug: "cyan", | ||
info: "green", | ||
notice: "grey", | ||
warning: "blue", | ||
error: "red", | ||
critical: "magenta", | ||
alert: "magenta", | ||
emergency: "magenta" | ||
}; | ||
var ConsoleWriter = (function () { | ||
function ConsoleWriter() { | ||
} | ||
else { | ||
// tslint:disable-next-line:no-console | ||
console.log("[" + dateTime + "] %c" + Level[level].toUpperCase() + "%c " + id + ": " + msg, "color:" + colours[Level[level]], ""); | ||
ConsoleWriter.prototype.write = function (dateTime, level, id, msg) { | ||
if (platform_1.isNode) { | ||
// tslint:disable-next-line:no-console | ||
console.log("[" + dateTime + "] " + Level[level].toUpperCase() + " " + id + ": " + msg); | ||
} | ||
else { | ||
// tslint:disable-next-line:no-console | ||
console.log("[" + dateTime + "] %c" + Level[level].toUpperCase() + "%c " + id + ": " + msg, "color:" + colours[Level[level]], ""); | ||
} | ||
}; | ||
return ConsoleWriter; | ||
}()); | ||
var Logging = (function () { | ||
function Logging() { | ||
this._levelStack = new stack_1.Stack(); | ||
this._level = Level.info; | ||
this._filter = ""; | ||
this._writer = new ConsoleWriter(); | ||
} | ||
}; | ||
return ConsoleWriter; | ||
}()); | ||
var Logging = (function () { | ||
function Logging() { | ||
this._levelStack = new stack_1.Stack(); | ||
this._level = Level.info; | ||
this._filter = ""; | ||
this._writer = new ConsoleWriter(); | ||
} | ||
Logging.Instance = function () { | ||
return this._instance || (this._instance = new this()); | ||
}; | ||
Logging.prototype.stringify = function (obj) { | ||
var cache = []; | ||
return JSON.stringify(obj, function (_key, value) { | ||
if (typeof value === "object" && value !== null) { | ||
if (cache.indexOf(value) !== -1) { | ||
return; | ||
Logging.Instance = function () { | ||
return this._instance || (this._instance = new this()); | ||
}; | ||
Logging.prototype.stringify = function (obj) { | ||
var cache = []; | ||
return JSON.stringify(obj, function (_key, value) { | ||
if (typeof value === "object" && value !== null) { | ||
if (cache.indexOf(value) !== -1) { | ||
return; | ||
} | ||
cache.push(value); | ||
} | ||
cache.push(value); | ||
return value; | ||
}, 2); | ||
}; | ||
Logging.prototype.writer = function (_) { | ||
if (_ === void 0) | ||
return this._writer; | ||
this._writer = _; | ||
return this; | ||
}; | ||
Logging.prototype.log = function (level, id, msg) { | ||
if (level < this._level) | ||
return; | ||
if (this._filter && this._filter !== id) | ||
return; | ||
if (typeof msg !== "string") { | ||
msg = this.stringify(msg); | ||
} | ||
return value; | ||
}, 2); | ||
}; | ||
Logging.prototype.writer = function (_) { | ||
if (_ === void 0) | ||
return this._writer; | ||
this._writer = _; | ||
return this; | ||
}; | ||
Logging.prototype.log = function (level, id, msg) { | ||
if (level < this._level) | ||
return; | ||
if (this._filter && this._filter !== id) | ||
return; | ||
var d = new Date(); | ||
var n = d.toISOString(); | ||
if (typeof msg !== "string") { | ||
msg = this.stringify(msg); | ||
this._writer.write(new Date().toISOString(), level, id, msg); | ||
}; | ||
Logging.prototype.debug = function (id, msg) { | ||
this.log(Level.debug, id, msg); | ||
}; | ||
Logging.prototype.info = function (id, msg) { | ||
this.log(Level.info, id, msg); | ||
}; | ||
Logging.prototype.notice = function (id, msg) { | ||
this.log(Level.notice, id, msg); | ||
}; | ||
Logging.prototype.warning = function (id, msg) { | ||
this.log(Level.warning, id, msg); | ||
}; | ||
Logging.prototype.error = function (id, msg) { | ||
this.log(Level.error, id, msg); | ||
}; | ||
Logging.prototype.critical = function (id, msg) { | ||
this.log(Level.critical, id, msg); | ||
}; | ||
Logging.prototype.alert = function (id, msg) { | ||
this.log(Level.alert, id, msg); | ||
}; | ||
Logging.prototype.emergency = function (id, msg) { | ||
this.log(Level.emergency, id, msg); | ||
}; | ||
Logging.prototype.level = function (_) { | ||
if (_ === void 0) | ||
return this._level; | ||
this._level = _; | ||
return this; | ||
}; | ||
Logging.prototype.pushLevel = function (_) { | ||
this._levelStack.push(this._level); | ||
this._level = _; | ||
return this; | ||
}; | ||
Logging.prototype.popLevel = function () { | ||
this._level = this._levelStack.pop(); | ||
return this; | ||
}; | ||
Logging.prototype.filter = function (_) { | ||
if (_ === void 0) | ||
return this._filter; | ||
this._filter = _; | ||
return this; | ||
}; | ||
return Logging; | ||
}()); | ||
exports.Logging = Logging; | ||
exports.logger = Logging.Instance(); | ||
var ScopedLogging = (function () { | ||
function ScopedLogging(scopeID) { | ||
this._scopeID = scopeID; | ||
} | ||
this._writer.write(n, level, id, msg); | ||
}; | ||
Logging.prototype.debug = function (id, msg) { | ||
this.log(Level.debug, id, msg); | ||
}; | ||
Logging.prototype.info = function (id, msg) { | ||
this.log(Level.info, id, msg); | ||
}; | ||
Logging.prototype.notice = function (id, msg) { | ||
this.log(Level.notice, id, msg); | ||
}; | ||
Logging.prototype.warning = function (id, msg) { | ||
this.log(Level.warning, id, msg); | ||
}; | ||
Logging.prototype.error = function (id, msg) { | ||
this.log(Level.error, id, msg); | ||
}; | ||
Logging.prototype.critical = function (id, msg) { | ||
this.log(Level.critical, id, msg); | ||
}; | ||
Logging.prototype.alert = function (id, msg) { | ||
this.log(Level.alert, id, msg); | ||
}; | ||
Logging.prototype.emergency = function (id, msg) { | ||
this.log(Level.emergency, id, msg); | ||
}; | ||
Logging.prototype.level = function (_) { | ||
if (_ === void 0) | ||
return this._level; | ||
this._level = _; | ||
return this; | ||
}; | ||
Logging.prototype.pushLevel = function (_) { | ||
this._levelStack.push(this._level); | ||
this._level = _; | ||
return this; | ||
}; | ||
Logging.prototype.popLevel = function () { | ||
this._level = this._levelStack.pop(); | ||
return this; | ||
}; | ||
Logging.prototype.filter = function (_) { | ||
if (_ === void 0) | ||
return this._filter; | ||
this._filter = _; | ||
return this; | ||
}; | ||
return Logging; | ||
}()); | ||
exports.Logging = Logging; | ||
exports.logger = Logging.Instance(); | ||
var ScopedLogging = (function () { | ||
function ScopedLogging(scopeID) { | ||
this._scopeID = scopeID; | ||
ScopedLogging.prototype.debug = function (msg) { | ||
exports.logger.debug(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.info = function (msg) { | ||
exports.logger.info(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.notice = function (msg) { | ||
exports.logger.notice(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.warning = function (msg) { | ||
exports.logger.warning(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.error = function (msg) { | ||
exports.logger.error(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.critical = function (msg) { | ||
exports.logger.critical(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.alert = function (msg) { | ||
exports.logger.alert(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.emergency = function (msg) { | ||
exports.logger.emergency(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.pushLevel = function (_) { | ||
exports.logger.pushLevel(_); | ||
return this; | ||
}; | ||
ScopedLogging.prototype.popLevel = function () { | ||
exports.logger.popLevel(); | ||
return this; | ||
}; | ||
return ScopedLogging; | ||
}()); | ||
exports.ScopedLogging = ScopedLogging; | ||
function scopedLogger(scopeID, filter) { | ||
if (filter === void 0) { filter = true; } | ||
if (filter) { | ||
exports.logger.filter(scopeID); | ||
} | ||
return new ScopedLogging(scopeID); | ||
} | ||
ScopedLogging.prototype.debug = function (msg) { | ||
exports.logger.debug(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.info = function (msg) { | ||
exports.logger.info(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.notice = function (msg) { | ||
exports.logger.notice(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.warning = function (msg) { | ||
exports.logger.warning(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.error = function (msg) { | ||
exports.logger.error(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.critical = function (msg) { | ||
exports.logger.critical(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.alert = function (msg) { | ||
exports.logger.alert(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.emergency = function (msg) { | ||
exports.logger.emergency(this._scopeID, msg); | ||
}; | ||
ScopedLogging.prototype.pushLevel = function (_) { | ||
exports.logger.pushLevel(_); | ||
return this; | ||
}; | ||
ScopedLogging.prototype.popLevel = function () { | ||
exports.logger.popLevel(); | ||
return this; | ||
}; | ||
return ScopedLogging; | ||
}()); | ||
exports.ScopedLogging = ScopedLogging; | ||
function scopedLogger(scopeID, filter) { | ||
if (filter === void 0) { filter = true; } | ||
if (filter) { | ||
exports.logger.filter(scopeID); | ||
} | ||
return new ScopedLogging(scopeID); | ||
} | ||
exports.scopedLogger = scopedLogger; | ||
exports.scopedLogger = scopedLogger; | ||
}); |
@@ -1,89 +0,99 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* inner - return inner property of Object | ||
* Usage: inner("some.prop.to.locate", obj); | ||
* | ||
* @param prop - property to locate | ||
* @param obj - object to locate property in | ||
*/ | ||
function inner(prop, obj) { | ||
if (prop === void 0 || obj === void 0) | ||
return void 0; | ||
for (var _i = 0, _a = prop.split("."); _i < _a.length; _i++) { | ||
var item = _a[_i]; | ||
if (!obj.hasOwnProperty(item)) { | ||
return undefined; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* inner - return inner property of Object | ||
* Usage: inner("some.prop.to.locate", obj); | ||
* | ||
* @param prop - property to locate | ||
* @param obj - object to locate property in | ||
*/ | ||
function inner(prop, obj) { | ||
if (prop === void 0 || obj === void 0) | ||
return void 0; | ||
for (var _i = 0, _a = prop.split("."); _i < _a.length; _i++) { | ||
var item = _a[_i]; | ||
if (!obj.hasOwnProperty(item)) { | ||
return undefined; | ||
} | ||
obj = obj[item]; | ||
} | ||
obj = obj[item]; | ||
return obj; | ||
} | ||
return obj; | ||
} | ||
exports.inner = inner; | ||
/** | ||
* exists - return true if inner property of Object exists | ||
* Usage: exists("some.prop.to.locate", obj); | ||
* | ||
* @param prop - property to locate | ||
* @param obj - object to locate property in | ||
*/ | ||
function exists(prop, obj) { | ||
return inner(prop, obj) !== undefined; | ||
} | ||
exports.exists = exists; | ||
function _mixin(dest, source) { | ||
var empty = {}; | ||
for (var key in source) { | ||
var s = source[key]; | ||
if (s instanceof Array) { | ||
// TODO: Do we need to support arrays? | ||
exports.inner = inner; | ||
/** | ||
* exists - return true if inner property of Object exists | ||
* Usage: exists("some.prop.to.locate", obj); | ||
* | ||
* @param prop - property to locate | ||
* @param obj - object to locate property in | ||
*/ | ||
function exists(prop, obj) { | ||
return inner(prop, obj) !== undefined; | ||
} | ||
exports.exists = exists; | ||
function _mixin(dest, source) { | ||
var empty = {}; | ||
for (var key in source) { | ||
var s = source[key]; | ||
if (s instanceof Array) { | ||
// TODO: Do we need to support arrays? | ||
} | ||
else if (typeof s === "object") { | ||
s = deepMixin(dest[key], s); | ||
} | ||
if (!(key in dest) || (dest[key] !== s && (!(key in empty) || empty[key] !== s))) { | ||
dest[key] = s; | ||
} | ||
} | ||
else if (typeof s === "object") { | ||
s = deepMixin(dest[key], s); | ||
return dest; | ||
} | ||
/** | ||
* deepMixin - combine several objects from right to left | ||
* Usage: deepMixin({a: "a"}, {b: "b"}); | ||
* | ||
* @param dest - target object to mix into. | ||
* @param sources - objects to mix in | ||
*/ | ||
function deepMixin(dest) { | ||
if (dest === void 0) { dest = {}; } | ||
var sources = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
sources[_i - 1] = arguments[_i]; | ||
} | ||
if (!(key in dest) || (dest[key] !== s && (!(key in empty) || empty[key] !== s))) { | ||
dest[key] = s; | ||
if (typeof dest !== "object") | ||
throw new Error("Destination \"" + dest + "\" must be an object."); | ||
for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { | ||
var source = sources_1[_a]; | ||
_mixin(dest, source); | ||
} | ||
return dest; | ||
} | ||
return dest; | ||
} | ||
/** | ||
* deepMixin - combine several objects from right to left | ||
* Usage: deepMixin({a: "a"}, {b: "b"}); | ||
* | ||
* @param dest - target object to mix into. | ||
* @param sources - objects to mix in | ||
*/ | ||
function deepMixin(dest) { | ||
if (dest === void 0) { dest = {}; } | ||
var sources = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
sources[_i - 1] = arguments[_i]; | ||
exports.deepMixin = deepMixin; | ||
/** | ||
* deepMixinT - combine several objects of Partial<T> from right to left | ||
* Usage: deepMixinT<MyInterface>({a: "a"}, {b: "b"}); | ||
* | ||
* Note: Only provided as a convenience, so user gets auto completion based on destination type. | ||
* | ||
* @param dest - target object to mix into. | ||
* @param sources - objects to mix in | ||
*/ | ||
function deepMixinT(dest) { | ||
if (dest === void 0) { dest = {}; } | ||
var sources = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
sources[_i - 1] = arguments[_i]; | ||
} | ||
return deepMixin.apply(void 0, [dest].concat(sources)); | ||
} | ||
if (typeof dest !== "object") | ||
throw new Error("Destination \"" + dest + "\" must be an object."); | ||
for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { | ||
var source = sources_1[_a]; | ||
_mixin(dest, source); | ||
} | ||
return dest; | ||
} | ||
exports.deepMixin = deepMixin; | ||
/** | ||
* deepMixinT - combine several objects of Partial<T> from right to left | ||
* Usage: deepMixinT<MyInterface>({a: "a"}, {b: "b"}); | ||
* | ||
* Note: Only provided as a convenience, so user gets auto completion based on destination type. | ||
* | ||
* @param dest - target object to mix into. | ||
* @param sources - objects to mix in | ||
*/ | ||
function deepMixinT(dest) { | ||
if (dest === void 0) { dest = {}; } | ||
var sources = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
sources[_i - 1] = arguments[_i]; | ||
} | ||
return deepMixin.apply(void 0, [dest].concat(sources)); | ||
} | ||
exports.deepMixinT = deepMixinT; | ||
exports.deepMixinT = deepMixinT; | ||
}); |
@@ -1,6 +0,16 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.root = new Function("try{return global;}catch(e){return window;}")(); | ||
exports.isBrowser = new Function("try{return this===window;}catch(e){return false;}"); | ||
exports.isNode = new Function("try{return this===global;}catch(e){return false;}"); | ||
exports.isTravis = new Function("try{return process.env.TRAVIS;}catch(e){return false;}"); | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.root = new Function("try{return global;}catch(e){return window;}")(); | ||
exports.isBrowser = new Function("try{return this===window;}catch(e){return false;}"); | ||
exports.isNode = new Function("try{return this===global;}catch(e){return false;}"); | ||
exports.isTravis = new Function("try{return process.env.TRAVIS;}catch(e){return false;}"); | ||
}); |
@@ -1,128 +0,138 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var stack_1 = require("./stack"); | ||
var XMLNode = (function () { | ||
function XMLNode(name) { | ||
this.name = ""; | ||
this.$ = {}; | ||
this._children = []; | ||
this.content = ""; | ||
this.name = name; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
XMLNode.prototype.appendAttribute = function (key, val) { | ||
this.$[key] = val; | ||
}; | ||
XMLNode.prototype.appendContent = function (content) { | ||
this.content += content; | ||
}; | ||
XMLNode.prototype.appendChild = function (child) { | ||
this._children.push(child); | ||
}; | ||
XMLNode.prototype.children = function (tag) { | ||
if (tag === undefined) { | ||
return this._children; | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "tslib", "./stack"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var stack_1 = require("./stack"); | ||
var XMLNode = (function () { | ||
function XMLNode(name) { | ||
this.name = ""; | ||
this.$ = {}; | ||
this._children = []; | ||
this.content = ""; | ||
this.name = name; | ||
} | ||
return this._children.filter(function (xmlNode) { | ||
return xmlNode.name === tag; | ||
}); | ||
}; | ||
return XMLNode; | ||
}()); | ||
exports.XMLNode = XMLNode; | ||
var SAXStackParser = (function () { | ||
function SAXStackParser() { | ||
this.stack = new stack_1.Stack(); | ||
} | ||
SAXStackParser.prototype.walkDoc = function (node) { | ||
this.startXMLNode(node); | ||
if (node.attributes) { | ||
for (var i = 0; i < node.attributes.length; ++i) { | ||
var attribute = node.attributes.item(i); | ||
this.attributes(attribute.nodeName, attribute.nodeValue); | ||
XMLNode.prototype.appendAttribute = function (key, val) { | ||
this.$[key] = val; | ||
}; | ||
XMLNode.prototype.appendContent = function (content) { | ||
this.content += content; | ||
}; | ||
XMLNode.prototype.appendChild = function (child) { | ||
this._children.push(child); | ||
}; | ||
XMLNode.prototype.children = function (tag) { | ||
if (tag === undefined) { | ||
return this._children; | ||
} | ||
return this._children.filter(function (xmlNode) { | ||
return xmlNode.name === tag; | ||
}); | ||
}; | ||
return XMLNode; | ||
}()); | ||
exports.XMLNode = XMLNode; | ||
var SAXStackParser = (function () { | ||
function SAXStackParser() { | ||
this.stack = new stack_1.Stack(); | ||
} | ||
if (node.childNodes) { | ||
for (var i = 0; i < node.childNodes.length; ++i) { | ||
var childNode = node.childNodes.item(i); | ||
if (childNode.nodeType === childNode.TEXT_NODE) { | ||
this.characters(childNode.nodeValue); | ||
SAXStackParser.prototype.walkDoc = function (node) { | ||
this.startXMLNode(node); | ||
if (node.attributes) { | ||
for (var i = 0; i < node.attributes.length; ++i) { | ||
var attribute = node.attributes.item(i); | ||
this.attributes(attribute.nodeName, attribute.nodeValue); | ||
} | ||
else { | ||
this.walkDoc(childNode); | ||
} | ||
if (node.childNodes) { | ||
for (var i = 0; i < node.childNodes.length; ++i) { | ||
var childNode = node.childNodes.item(i); | ||
if (childNode.nodeType === childNode.TEXT_NODE) { | ||
this.characters(childNode.nodeValue); | ||
} | ||
else { | ||
this.walkDoc(childNode); | ||
} | ||
} | ||
} | ||
this.endXMLNode(node); | ||
}; | ||
SAXStackParser.prototype.parse = function (xml) { | ||
var domParser = new DOMParser(); | ||
var doc = domParser.parseFromString(xml, "application/xml"); | ||
this.startDocument(); | ||
this.walkDoc(doc); | ||
this.endDocument(); | ||
}; | ||
// Callbacks --- | ||
SAXStackParser.prototype.startDocument = function () { | ||
}; | ||
SAXStackParser.prototype.endDocument = function () { | ||
}; | ||
SAXStackParser.prototype.startXMLNode = function (node) { | ||
var newNode = new XMLNode(node.nodeName); | ||
if (!this.stack.depth()) { | ||
this.root = newNode; | ||
} | ||
else { | ||
this.stack.top().appendChild(newNode); | ||
} | ||
return this.stack.push(newNode); | ||
}; | ||
SAXStackParser.prototype.endXMLNode = function (_node) { | ||
return this.stack.pop(); | ||
}; | ||
SAXStackParser.prototype.attributes = function (key, val) { | ||
this.stack.top().appendAttribute(key, val); | ||
}; | ||
SAXStackParser.prototype.characters = function (text) { | ||
this.stack.top().appendContent(text); | ||
}; | ||
return SAXStackParser; | ||
}()); | ||
exports.SAXStackParser = SAXStackParser; | ||
var XML2JSONParser = (function (_super) { | ||
tslib_1.__extends(XML2JSONParser, _super); | ||
function XML2JSONParser() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
this.endXMLNode(node); | ||
}; | ||
SAXStackParser.prototype.parse = function (xml) { | ||
var domParser = new DOMParser(); | ||
var doc = domParser.parseFromString(xml, "application/xml"); | ||
this.startDocument(); | ||
this.walkDoc(doc); | ||
this.endDocument(); | ||
}; | ||
// Callbacks --- | ||
SAXStackParser.prototype.startDocument = function () { | ||
}; | ||
SAXStackParser.prototype.endDocument = function () { | ||
}; | ||
SAXStackParser.prototype.startXMLNode = function (node) { | ||
var newNode = new XMLNode(node.nodeName); | ||
if (!this.stack.depth()) { | ||
this.root = newNode; | ||
} | ||
else { | ||
this.stack.top().appendChild(newNode); | ||
} | ||
return this.stack.push(newNode); | ||
}; | ||
SAXStackParser.prototype.endXMLNode = function (_node) { | ||
return this.stack.pop(); | ||
}; | ||
SAXStackParser.prototype.attributes = function (key, val) { | ||
this.stack.top().appendAttribute(key, val); | ||
}; | ||
SAXStackParser.prototype.characters = function (text) { | ||
this.stack.top().appendContent(text); | ||
}; | ||
return SAXStackParser; | ||
}()); | ||
exports.SAXStackParser = SAXStackParser; | ||
var XML2JSONParser = (function (_super) { | ||
tslib_1.__extends(XML2JSONParser, _super); | ||
function XML2JSONParser() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
XML2JSONParser.prototype.startXMLNode = function (node) { | ||
var e = _super.prototype.startXMLNode.call(this, node); | ||
switch (e.name) { | ||
case "xs:element": | ||
break; | ||
case "xs:simpleType": | ||
break; | ||
default: | ||
break; | ||
} | ||
return e; | ||
}; | ||
XML2JSONParser.prototype.endXMLNode = function (node) { | ||
var e = this.stack.top(); | ||
switch (e.name) { | ||
case "xs:element": | ||
break; | ||
case "xs:simpleType": | ||
break; | ||
default: | ||
break; | ||
} | ||
return _super.prototype.endXMLNode.call(this, node); | ||
}; | ||
return XML2JSONParser; | ||
}(SAXStackParser)); | ||
function xml2json(xml) { | ||
var saxParser = new XML2JSONParser(); | ||
saxParser.parse(xml); | ||
return saxParser.root; | ||
} | ||
XML2JSONParser.prototype.startXMLNode = function (node) { | ||
var e = _super.prototype.startXMLNode.call(this, node); | ||
switch (e.name) { | ||
case "xs:element": | ||
break; | ||
case "xs:simpleType": | ||
break; | ||
default: | ||
break; | ||
} | ||
return e; | ||
}; | ||
XML2JSONParser.prototype.endXMLNode = function (node) { | ||
var e = this.stack.top(); | ||
switch (e.name) { | ||
case "xs:element": | ||
break; | ||
case "xs:simpleType": | ||
break; | ||
default: | ||
break; | ||
} | ||
return _super.prototype.endXMLNode.call(this, node); | ||
}; | ||
return XML2JSONParser; | ||
}(SAXStackParser)); | ||
function xml2json(xml) { | ||
var saxParser = new XML2JSONParser(); | ||
saxParser.parse(xml); | ||
return saxParser.root; | ||
} | ||
exports.xml2json = xml2json; | ||
exports.xml2json = xml2json; | ||
}); |
@@ -1,43 +0,53 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* A generic Stack | ||
*/ | ||
var Stack = (function () { | ||
function Stack() { | ||
this.stack = []; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Push element onto the stack | ||
* | ||
* @param e - element to push | ||
* A generic Stack | ||
*/ | ||
Stack.prototype.push = function (e) { | ||
this.stack.push(e); | ||
return e; | ||
}; | ||
/** | ||
* Pop element off the stack | ||
*/ | ||
Stack.prototype.pop = function () { | ||
return this.stack.pop(); | ||
}; | ||
/** | ||
* Top item on the stack | ||
* | ||
* @returns Top element on the stack | ||
*/ | ||
Stack.prototype.top = function () { | ||
return this.stack.length ? this.stack[this.stack.length - 1] : undefined; | ||
}; | ||
/** | ||
* Depth of stack | ||
* | ||
* @returns Depth | ||
*/ | ||
Stack.prototype.depth = function () { | ||
return this.stack.length; | ||
}; | ||
return Stack; | ||
}()); | ||
exports.Stack = Stack; | ||
var Stack = (function () { | ||
function Stack() { | ||
this.stack = []; | ||
} | ||
/** | ||
* Push element onto the stack | ||
* | ||
* @param e - element to push | ||
*/ | ||
Stack.prototype.push = function (e) { | ||
this.stack.push(e); | ||
return e; | ||
}; | ||
/** | ||
* Pop element off the stack | ||
*/ | ||
Stack.prototype.pop = function () { | ||
return this.stack.pop(); | ||
}; | ||
/** | ||
* Top item on the stack | ||
* | ||
* @returns Top element on the stack | ||
*/ | ||
Stack.prototype.top = function () { | ||
return this.stack.length ? this.stack[this.stack.length - 1] : undefined; | ||
}; | ||
/** | ||
* Depth of stack | ||
* | ||
* @returns Depth | ||
*/ | ||
Stack.prototype.depth = function () { | ||
return this.stack.length; | ||
}; | ||
return Stack; | ||
}()); | ||
exports.Stack = Stack; | ||
}); |
@@ -1,26 +0,36 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function trim(str, char) { | ||
if (typeof char !== "string") | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function trim(str, char) { | ||
if (typeof char !== "string") | ||
return str; | ||
if (char.length === 0) | ||
return str; | ||
while (str.indexOf(char) === 0) { | ||
str = str.substring(1); | ||
} | ||
while (endsWith(str, char)) { | ||
str = str.substring(0, str.length - 1); | ||
} | ||
return str; | ||
if (char.length === 0) | ||
return str; | ||
while (str.indexOf(char) === 0) { | ||
str = str.substring(1); | ||
} | ||
while (endsWith(str, char)) { | ||
str = str.substring(0, str.length - 1); | ||
exports.trim = trim; | ||
function endsWith(origString, searchString, position) { | ||
var subjectString = origString.toString(); | ||
if (typeof position !== "number" || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { | ||
position = subjectString.length; | ||
} | ||
position -= searchString.length; | ||
var lastIndex = subjectString.lastIndexOf(searchString, position); | ||
return lastIndex !== -1 && lastIndex === position; | ||
} | ||
return str; | ||
} | ||
exports.trim = trim; | ||
function endsWith(origString, searchString, position) { | ||
var subjectString = origString.toString(); | ||
if (typeof position !== "number" || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { | ||
position = subjectString.length; | ||
} | ||
position -= searchString.length; | ||
var lastIndex = subjectString.lastIndexOf(searchString, position); | ||
return lastIndex !== -1 && lastIndex === position; | ||
} | ||
exports.endsWith = endsWith; | ||
exports.endsWith = endsWith; | ||
}); |
@@ -1,14 +0,24 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var string_1 = require("./string"); | ||
function join() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
var partialUrl = args.length && args[0].length && args[0].charAt(0) === "/"; | ||
return (partialUrl ? "/" : "") + args.map(function (arg) { | ||
return string_1.trim(arg, "/"); | ||
}).join("/"); | ||
} | ||
exports.join = join; | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./string"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var string_1 = require("./string"); | ||
function join() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var partialUrl = args.length && args[0].length && args[0].charAt(0) === "/"; | ||
return (partialUrl ? "/" : "") + args.map(function (arg) { | ||
return string_1.trim(arg, "/"); | ||
}).join("/"); | ||
} | ||
exports.join = join; | ||
}); |
{ | ||
"name": "@hpcc-js/util", | ||
"version": "0.0.14", | ||
"version": "0.0.17", | ||
"description": "hpcc-js - Utilities", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65071
33
1718