Comparing version 1.0.1 to 1.0.2
"use strict"; | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
@@ -56,2 +64,59 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
1: [function (require, module, exports) { | ||
/** | ||
* Fable Core Pre-initialization Service Base | ||
* | ||
* For a couple services, we need to be able to instantiate them before the Fable object is fully initialized. | ||
* This is a base class for those services. | ||
* | ||
* @author <steven@velozo.com> | ||
*/ | ||
var FableCoreServiceProviderBase = /*#__PURE__*/function () { | ||
function FableCoreServiceProviderBase(pOptions, pServiceHash) { | ||
_classCallCheck(this, FableCoreServiceProviderBase); | ||
this.fable = false; | ||
this.options = _typeof(pOptions) === 'object' ? pOptions : {}; | ||
this.serviceType = 'Unknown'; | ||
// The hash will be a non-standard UUID ... the UUID service uses this base class! | ||
this.UUID = "CORESVC-".concat(Math.floor(Math.random() * (99999 - 10000) + 10000)); | ||
this.Hash = typeof pServiceHash === 'string' ? pServiceHash : "".concat(this.UUID); | ||
} | ||
_createClass(FableCoreServiceProviderBase, [{ | ||
key: "connectFable", | ||
value: | ||
// After fable is initialized, it would be expected to be wired in as a normal service. | ||
function connectFable(pFable) { | ||
this.fable = pFable; | ||
return true; | ||
} | ||
}]); | ||
return FableCoreServiceProviderBase; | ||
}(); | ||
_defineProperty(FableCoreServiceProviderBase, "isFableService", true); | ||
module.exports = FableCoreServiceProviderBase; | ||
}, {}], | ||
2: [function (require, module, exports) { | ||
/** | ||
* Fable Service Base | ||
* @author <steven@velozo.com> | ||
*/ | ||
var FableServiceProviderBase = /*#__PURE__*/_createClass(function FableServiceProviderBase(pFable, pOptions, pServiceHash) { | ||
_classCallCheck(this, FableServiceProviderBase); | ||
this.fable = pFable; | ||
this.options = _typeof(pOptions) === 'object' ? pOptions : _typeof(pFable) === 'object' && !pFable.isFable ? pFable : {}; | ||
this.serviceType = 'Unknown'; | ||
if (typeof pFable.getUUID == 'function') { | ||
this.UUID = pFable.getUUID(); | ||
} else { | ||
this.UUID = "NoFABLESVC-".concat(Math.floor(Math.random() * (99999 - 10000) + 10000)); | ||
} | ||
this.Hash = typeof pServiceHash === 'string' ? pServiceHash : "".concat(this.UUID); | ||
}); | ||
_defineProperty(FableServiceProviderBase, "isFableService", true); | ||
module.exports = FableServiceProviderBase; | ||
module.exports.CoreServiceProviderBase = require('./Fable-ServiceProviderBase-Preinit.js'); | ||
}, { | ||
"./Fable-ServiceProviderBase-Preinit.js": 1 | ||
}], | ||
3: [function (require, module, exports) { | ||
var libNPMModuleWrapper = require('./CacheTrax.js'); | ||
@@ -63,5 +128,5 @@ if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.hasOwnProperty('CacheTrax')) { | ||
}, { | ||
"./CacheTrax.js": 2 | ||
"./CacheTrax.js": 4 | ||
}], | ||
2: [function (require, module, exports) { | ||
4: [function (require, module, exports) { | ||
/** | ||
@@ -81,28 +146,29 @@ * Cache data structure with: | ||
* | ||
* @license MIT | ||
* | ||
* @author Steven Velozo <steven@velozo.com> | ||
* @module CashMoney | ||
*/ | ||
/** | ||
* Quality Cache Goodness | ||
* | ||
* @class CashMoney | ||
* @constructor | ||
*/ | ||
var libFableServiceProviderBase = require('fable-serviceproviderbase'); | ||
var libLinkedList = require("./LinkedList.js"); | ||
var CashMoney = /*#__PURE__*/function () { | ||
function CashMoney() { | ||
var CashMoney = /*#__PURE__*/function (_libFableServiceProvi) { | ||
_inherits(CashMoney, _libFableServiceProvi); | ||
var _super = _createSuper(CashMoney); | ||
function CashMoney(pFable, pManifest, pServiceHash) { | ||
var _this; | ||
_classCallCheck(this, CashMoney); | ||
if (pFable === undefined) { | ||
_this = _super.call(this, {}); | ||
} else { | ||
_this = _super.call(this, pFable, pManifest, pServiceHash); | ||
} | ||
_this.serviceType = 'ObjectCache'; | ||
// The map of node objects by hash because Reasons. | ||
this._HashMap = {}; | ||
this._List = new libLinkedList(); | ||
_this._HashMap = {}; | ||
_this._List = new libLinkedList(); | ||
// If the list gets over maxLength, we will automatically remove nodes on insertion. | ||
this.maxLength = 0; | ||
_this.maxLength = 0; | ||
// If cache entries get over this age, they are removed with prune | ||
this.maxAge = 0; | ||
_this.maxAge = 0; | ||
return _possibleConstructorReturn(_this); | ||
} | ||
@@ -213,3 +279,3 @@ | ||
value: function prune(fComplete) { | ||
var _this = this; | ||
var _this2 = this; | ||
var tmpRemovedRecords = []; | ||
@@ -223,3 +289,3 @@ | ||
// Now prune based on length, then return the removed records in the callback. | ||
_this.pruneBasedOnLength(fComplete, tmpRemovedRecords); | ||
_this2.pruneBasedOnLength(fComplete, tmpRemovedRecords); | ||
}, tmpRemovedRecords); | ||
@@ -245,8 +311,9 @@ } | ||
return CashMoney; | ||
}(); | ||
}(libFableServiceProviderBase); | ||
module.exports = CashMoney; | ||
}, { | ||
"./LinkedList.js": 4 | ||
"./LinkedList.js": 6, | ||
"fable-serviceproviderbase": 2 | ||
}], | ||
3: [function (require, module, exports) { | ||
5: [function (require, module, exports) { | ||
/** | ||
@@ -279,3 +346,3 @@ * Double Linked List Node | ||
}, {}], | ||
4: [function (require, module, exports) { | ||
6: [function (require, module, exports) { | ||
"use strict"; | ||
@@ -428,3 +495,3 @@ | ||
value: function each(fAction, fComplete) { | ||
var _this2 = this; | ||
var _this3 = this; | ||
if (this.length < 1) return fComplete(); | ||
@@ -437,3 +504,3 @@ var tmpNode = false; | ||
// If there is no node, this must be the initial run. | ||
if (!tmpNode) tmpNode = _this2.head; | ||
if (!tmpNode) tmpNode = _this3.head; | ||
// Check if we are at the tail of the list | ||
@@ -471,5 +538,5 @@ else if (!tmpNode.RightNode) return fComplete(); | ||
}, { | ||
"./LinkedList-Node.js": 3 | ||
"./LinkedList-Node.js": 5 | ||
}] | ||
}, {}, [1])(1); | ||
}, {}, [3])(3); | ||
}); |
@@ -1,22 +0,2 @@ | ||
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,i){return t&&_defineProperties(e.prototype,t),i&&_defineProperties(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}!function(e){if("object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).CacheTrax=e()}}((function(){return function e(t,i,n){function r(o,s){if(!i[o]){if(!t[o]){var h="function"==typeof require&&require;if(!s&&h)return h(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=i[o]={exports:{}};t[o][0].call(f.exports,(function(e){return r(t[o][1][e]||e)}),f,f.exports,e,t,i,n)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)r(n[o]);return r}({1:[function(e,t,i){var n=e("./CacheTrax.js");"object"!==("undefined"==typeof window?"undefined":_typeof(window))||window.hasOwnProperty("CacheTrax")||(window.CacheTrax=n),t.exports=n},{"./CacheTrax.js":2}],2:[function(e,t,i){ | ||
/** | ||
* Cache data structure with: | ||
* - enumerable items | ||
* - unique hash item access (if none is passed in, one is generated) | ||
* - size (length) expiration | ||
* - controllable expiration (e.g. keep in cache longer if older/less likely to change) | ||
* - time-based expiration | ||
* - custom expiration based on passed-in function | ||
* | ||
* Also: | ||
* - built to work well with browserify | ||
* - no dependencies at all | ||
* - pet friendly | ||
* | ||
* @license MIT | ||
* | ||
* @author Steven Velozo <steven@velozo.com> | ||
* @module CashMoney | ||
*/ | ||
var n=e("./LinkedList.js"),r=function(){function e(){_classCallCheck(this,e),this._HashMap={},this._List=new n,this.maxLength=0,this.maxAge=0}return _createClass(e,[{key:"put",value:function(e,t){if(this._HashMap.hasOwnProperty(t))return this._HashMap[t].Datum=e,this._HashMap[t].Datum;var i=this._List.push(e,t);return this._HashMap[i.Hash]=i,this.maxLength>0&&this._List.length>this.maxLength&&(i=this._List.pop(),delete this._HashMap[i.Hash]),i.Metadata.Created=+new Date,i.Datum}},{key:"touch",value:function(e){if(!this._HashMap.hasOwnProperty(e))return!1;var t=this._List.remove(this._HashMap[e]);return delete this._HashMap[e],this.put(t.Datum,t.Hash)}},{key:"expire",value:function(e){if(!this._HashMap.hasOwnProperty(e))return!1;var t=this._HashMap[e];return t=this._List.remove(t),delete this._HashMap[t.Hash],t}},{key:"pruneBasedOnExpiration",value:function(e,t){var i=void 0===t?[]:t;if(this.maxAge<1)return e(i);for(var n=+new Date,r=Object.keys(this._HashMap),a=0;a<r.length;a++)n-this._HashMap[r[a]].Metadata.Created>=this.maxAge&&i.push(this.expire(r[a]));e(i)}},{key:"pruneBasedOnLength",value:function(e,t){var i=void 0===t?[]:t;if(this.maxLength>0)for(;this._List.length>this.maxLength;)i.push(this._List.pop());return e(i)}},{key:"pruneCustom",value:function(e,t,i){for(var n=void 0===i?[]:i,r=Object.keys(this._HashMap),a=0;a<r.length;a++){var o=this._HashMap[r[a]];t(o.Datum,o.Hash,o)&&n.push(this.expire(r[a]))}e(n)}},{key:"prune",value:function(e){var t=this,i=[];if(this._List.length<1)return e(i);this.pruneBasedOnExpiration((function(n){t.pruneBasedOnLength(e,i)}),i)}},{key:"read",value:function(e){return!!this._HashMap.hasOwnProperty(e)&&this._HashMap[e].Datum}},{key:"getNode",value:function(e){return!!this._HashMap.hasOwnProperty(e)&&this._HashMap[e]}}]),e}();t.exports=r},{"./LinkedList.js":4}],3:[function(e,t,i){var n=_createClass((function e(){_classCallCheck(this,e),this.Hash=!1,this.Datum=!1,this.Metadata={},this.LeftNode=!1,this.RightNode=!1,this.__ISNODE=!0}));t.exports=n},{}],4:[function(e,t,i){var n=e("./LinkedList-Node.js"),r=function(){function e(){_classCallCheck(this,e),this.totalNodes=0,this.length=0,this.head=!1,this.tail=!1}return _createClass(e,[{key:"initializeNode",value:function(e,t){if(void 0===e)return!1;this.totalNodes++;var i=void 0!==t?t:"NODE[".concat(this.totalNodes,"]"),r=new n;return r.Hash=i,r.Datum=e,r}},{key:"append",value:function(e,t){var i=this.initializeNode(e,t);return!!i&&(this.length++,1==this.length?(this.head=i,this.tail=i,i):(this.tail.RightNode=i,i.LeftNode=this.tail,this.tail=i,i))}},{key:"push",value:function(e,t){return this.append(e,t)}},{key:"prepend",value:function(e,t){var i=this.initializeNode(e,t);return!!i&&(this.length++,1==this.length?(this.head=i,this.tail=i,i):(this.head.LeftNode=i,i.RightNode=this.head,this.head=i,i))}},{key:"remove",value:function(e){return void 0!==e&&(!!e.__ISNODE&&(this.length--,this.length<1?(this.head=!1,this.tail=!1,e):e.LeftNode&&e.RightNode?(e.LeftNode.RightNode=e.RightNode,e.RightNode.LeftNode=e.LeftNode,e.RightNode=!1,e.LeftNode=!1,e):e.LeftNode?(e.LeftNode.RightNode=!1,this.tail=e.LeftNode,e.LeftNode=!1,e):(e.RightNode.LeftNode=!1,this.head=e.RightNode,e.RightNode=!1,e)))}},{key:"pop",value:function(){return this.remove(this.head)}},{key:"each",value:function(e,t){var i=this;if(this.length<1)return t();var n=!1;return function r(a){if(a)return t(a);if(n){if(!n.RightNode)return t();n=n.RightNode}else n=i.head;e(n.Datum,n.Hash,r)}()}},{key:"seek",value:function(e){if(!e)return!1;if(this.length<1)return!1;if(e>=this.length)return!1;for(var t=this.head,i=0;i<e;i++)t=t.RightNode;return t}}]),e}();t.exports=r},{"./LinkedList-Node.js":3}]},{},[1])(1)})); | ||
"use strict";function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var i,r=_getPrototypeOf(e);if(t){var n=_getPrototypeOf(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return _possibleConstructorReturn(this,i)}}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_toPropertyKey(r.key),r)}}function _createClass(e,t,i){return t&&_defineProperties(e.prototype,t),i&&_defineProperties(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,i){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}!function(e){if("object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).CacheTrax=e()}}((function(){return function e(t,i,r){function n(s,a){if(!i[s]){if(!t[s]){var h="function"==typeof require&&require;if(!a&&h)return h(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var f=i[s]={exports:{}};t[s][0].call(f.exports,(function(e){return n(t[s][1][e]||e)}),f,f.exports,e,t,i,r)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(e,t,i){var r=function(){function e(t,i){_classCallCheck(this,e),this.fable=!1,this.options="object"===_typeof(t)?t:{},this.serviceType="Unknown",this.UUID="CORESVC-".concat(Math.floor(89999*Math.random()+1e4)),this.Hash="string"==typeof i?i:"".concat(this.UUID)}return _createClass(e,[{key:"connectFable",value:function(e){return this.fable=e,!0}}]),e}();_defineProperty(r,"isFableService",!0),t.exports=r},{}],2:[function(e,t,i){var r=_createClass((function e(t,i,r){_classCallCheck(this,e),this.fable=t,this.options="object"===_typeof(i)?i:"object"!==_typeof(t)||t.isFable?{}:t,this.serviceType="Unknown","function"==typeof t.getUUID?this.UUID=t.getUUID():this.UUID="NoFABLESVC-".concat(Math.floor(89999*Math.random()+1e4)),this.Hash="string"==typeof r?r:"".concat(this.UUID)}));_defineProperty(r,"isFableService",!0),t.exports=r,t.exports.CoreServiceProviderBase=e("./Fable-ServiceProviderBase-Preinit.js")},{"./Fable-ServiceProviderBase-Preinit.js":1}],3:[function(e,t,i){var r=e("./CacheTrax.js");"object"!==("undefined"==typeof window?"undefined":_typeof(window))||window.hasOwnProperty("CacheTrax")||(window.CacheTrax=r),t.exports=r},{"./CacheTrax.js":4}],4:[function(e,t,i){var r=e("fable-serviceproviderbase"),n=e("./LinkedList.js"),o=function(e){_inherits(i,e);var t=_createSuper(i);function i(e,r,o){var s;return _classCallCheck(this,i),(s=void 0===e?t.call(this,{}):t.call(this,e,r,o)).serviceType="ObjectCache",s._HashMap={},s._List=new n,s.maxLength=0,s.maxAge=0,_possibleConstructorReturn(s)}return _createClass(i,[{key:"put",value:function(e,t){if(this._HashMap.hasOwnProperty(t))return this._HashMap[t].Datum=e,this._HashMap[t].Datum;var i=this._List.push(e,t);return this._HashMap[i.Hash]=i,this.maxLength>0&&this._List.length>this.maxLength&&(i=this._List.pop(),delete this._HashMap[i.Hash]),i.Metadata.Created=+new Date,i.Datum}},{key:"touch",value:function(e){if(!this._HashMap.hasOwnProperty(e))return!1;var t=this._List.remove(this._HashMap[e]);return delete this._HashMap[e],this.put(t.Datum,t.Hash)}},{key:"expire",value:function(e){if(!this._HashMap.hasOwnProperty(e))return!1;var t=this._HashMap[e];return t=this._List.remove(t),delete this._HashMap[t.Hash],t}},{key:"pruneBasedOnExpiration",value:function(e,t){var i=void 0===t?[]:t;if(this.maxAge<1)return e(i);for(var r=+new Date,n=Object.keys(this._HashMap),o=0;o<n.length;o++)r-this._HashMap[n[o]].Metadata.Created>=this.maxAge&&i.push(this.expire(n[o]));e(i)}},{key:"pruneBasedOnLength",value:function(e,t){var i=void 0===t?[]:t;if(this.maxLength>0)for(;this._List.length>this.maxLength;)i.push(this._List.pop());return e(i)}},{key:"pruneCustom",value:function(e,t,i){for(var r=void 0===i?[]:i,n=Object.keys(this._HashMap),o=0;o<n.length;o++){var s=this._HashMap[n[o]];t(s.Datum,s.Hash,s)&&r.push(this.expire(n[o]))}e(r)}},{key:"prune",value:function(e){var t=this,i=[];if(this._List.length<1)return e(i);this.pruneBasedOnExpiration((function(r){t.pruneBasedOnLength(e,i)}),i)}},{key:"read",value:function(e){return!!this._HashMap.hasOwnProperty(e)&&this._HashMap[e].Datum}},{key:"getNode",value:function(e){return!!this._HashMap.hasOwnProperty(e)&&this._HashMap[e]}}]),i}(r);t.exports=o},{"./LinkedList.js":6,"fable-serviceproviderbase":2}],5:[function(e,t,i){var r=_createClass((function e(){_classCallCheck(this,e),this.Hash=!1,this.Datum=!1,this.Metadata={},this.LeftNode=!1,this.RightNode=!1,this.__ISNODE=!0}));t.exports=r},{}],6:[function(e,t,i){var r=e("./LinkedList-Node.js"),n=function(){function e(){_classCallCheck(this,e),this.totalNodes=0,this.length=0,this.head=!1,this.tail=!1}return _createClass(e,[{key:"initializeNode",value:function(e,t){if(void 0===e)return!1;this.totalNodes++;var i=void 0!==t?t:"NODE[".concat(this.totalNodes,"]"),n=new r;return n.Hash=i,n.Datum=e,n}},{key:"append",value:function(e,t){var i=this.initializeNode(e,t);return!!i&&(this.length++,1==this.length?(this.head=i,this.tail=i,i):(this.tail.RightNode=i,i.LeftNode=this.tail,this.tail=i,i))}},{key:"push",value:function(e,t){return this.append(e,t)}},{key:"prepend",value:function(e,t){var i=this.initializeNode(e,t);return!!i&&(this.length++,1==this.length?(this.head=i,this.tail=i,i):(this.head.LeftNode=i,i.RightNode=this.head,this.head=i,i))}},{key:"remove",value:function(e){return void 0!==e&&(!!e.__ISNODE&&(this.length--,this.length<1?(this.head=!1,this.tail=!1,e):e.LeftNode&&e.RightNode?(e.LeftNode.RightNode=e.RightNode,e.RightNode.LeftNode=e.LeftNode,e.RightNode=!1,e.LeftNode=!1,e):e.LeftNode?(e.LeftNode.RightNode=!1,this.tail=e.LeftNode,e.LeftNode=!1,e):(e.RightNode.LeftNode=!1,this.head=e.RightNode,e.RightNode=!1,e)))}},{key:"pop",value:function(){return this.remove(this.head)}},{key:"each",value:function(e,t){var i=this;if(this.length<1)return t();var r=!1;return function n(o){if(o)return t(o);if(r){if(!r.RightNode)return t();r=r.RightNode}else r=i.head;e(r.Datum,r.Hash,n)}()}},{key:"seek",value:function(e){if(!e)return!1;if(this.length<1)return!1;if(e>=this.length)return!1;for(var t=this.head,i=0;i<e;i++)t=t.RightNode;return t}}]),e}();t.exports=n},{"./LinkedList-Node.js":5}]},{},[3])(3)})); | ||
//# sourceMappingURL=cachetrax.compatible.min.js.map |
"use strict"; | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
(function (f) { | ||
@@ -50,2 +53,56 @@ if (typeof exports === "object" && typeof module !== "undefined") { | ||
1: [function (require, module, exports) { | ||
/** | ||
* Fable Core Pre-initialization Service Base | ||
* | ||
* For a couple services, we need to be able to instantiate them before the Fable object is fully initialized. | ||
* This is a base class for those services. | ||
* | ||
* @author <steven@velozo.com> | ||
*/ | ||
class FableCoreServiceProviderBase { | ||
constructor(pOptions, pServiceHash) { | ||
this.fable = false; | ||
this.options = typeof pOptions === 'object' ? pOptions : {}; | ||
this.serviceType = 'Unknown'; | ||
// The hash will be a non-standard UUID ... the UUID service uses this base class! | ||
this.UUID = "CORESVC-".concat(Math.floor(Math.random() * (99999 - 10000) + 10000)); | ||
this.Hash = typeof pServiceHash === 'string' ? pServiceHash : "".concat(this.UUID); | ||
} | ||
// After fable is initialized, it would be expected to be wired in as a normal service. | ||
connectFable(pFable) { | ||
this.fable = pFable; | ||
return true; | ||
} | ||
} | ||
_defineProperty(FableCoreServiceProviderBase, "isFableService", true); | ||
module.exports = FableCoreServiceProviderBase; | ||
}, {}], | ||
2: [function (require, module, exports) { | ||
/** | ||
* Fable Service Base | ||
* @author <steven@velozo.com> | ||
*/ | ||
class FableServiceProviderBase { | ||
constructor(pFable, pOptions, pServiceHash) { | ||
this.fable = pFable; | ||
this.options = typeof pOptions === 'object' ? pOptions : typeof pFable === 'object' && !pFable.isFable ? pFable : {}; | ||
this.serviceType = 'Unknown'; | ||
if (typeof pFable.getUUID == 'function') { | ||
this.UUID = pFable.getUUID(); | ||
} else { | ||
this.UUID = "NoFABLESVC-".concat(Math.floor(Math.random() * (99999 - 10000) + 10000)); | ||
} | ||
this.Hash = typeof pServiceHash === 'string' ? pServiceHash : "".concat(this.UUID); | ||
} | ||
} | ||
_defineProperty(FableServiceProviderBase, "isFableService", true); | ||
module.exports = FableServiceProviderBase; | ||
module.exports.CoreServiceProviderBase = require('./Fable-ServiceProviderBase-Preinit.js'); | ||
}, { | ||
"./Fable-ServiceProviderBase-Preinit.js": 1 | ||
}], | ||
3: [function (require, module, exports) { | ||
var libNPMModuleWrapper = require('./CacheTrax.js'); | ||
@@ -57,5 +114,5 @@ if (typeof window === 'object' && !window.hasOwnProperty('CacheTrax')) { | ||
}, { | ||
"./CacheTrax.js": 2 | ||
"./CacheTrax.js": 4 | ||
}], | ||
2: [function (require, module, exports) { | ||
4: [function (require, module, exports) { | ||
/** | ||
@@ -75,18 +132,15 @@ * Cache data structure with: | ||
* | ||
* @license MIT | ||
* | ||
* @author Steven Velozo <steven@velozo.com> | ||
* @module CashMoney | ||
*/ | ||
const libFableServiceProviderBase = require('fable-serviceproviderbase'); | ||
const libLinkedList = require("./LinkedList.js"); | ||
class CashMoney extends libFableServiceProviderBase { | ||
constructor(pFable, pManifest, pServiceHash) { | ||
if (pFable === undefined) { | ||
super({}); | ||
} else { | ||
super(pFable, pManifest, pServiceHash); | ||
} | ||
this.serviceType = 'ObjectCache'; | ||
/** | ||
* Quality Cache Goodness | ||
* | ||
* @class CashMoney | ||
* @constructor | ||
*/ | ||
const libLinkedList = require("./LinkedList.js"); | ||
class CashMoney { | ||
constructor() { | ||
// The map of node objects by hash because Reasons. | ||
@@ -218,5 +272,6 @@ this._HashMap = {}; | ||
}, { | ||
"./LinkedList.js": 4 | ||
"./LinkedList.js": 6, | ||
"fable-serviceproviderbase": 2 | ||
}], | ||
3: [function (require, module, exports) { | ||
5: [function (require, module, exports) { | ||
/** | ||
@@ -252,3 +307,3 @@ * Double Linked List Node | ||
}, {}], | ||
4: [function (require, module, exports) { | ||
6: [function (require, module, exports) { | ||
"use strict"; | ||
@@ -423,5 +478,5 @@ | ||
}, { | ||
"./LinkedList-Node.js": 3 | ||
"./LinkedList-Node.js": 5 | ||
}] | ||
}, {}, [1])(1); | ||
}, {}, [3])(3); | ||
}); |
@@ -1,22 +0,2 @@ | ||
"use strict";!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).CacheTrax=t()}}((function(){return function t(e,i,s){function h(r,n){if(!i[r]){if(!e[r]){var o="function"==typeof require&&require;if(!n&&o)return o(r,!0);if(a)return a(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var u=i[r]={exports:{}};e[r][0].call(u.exports,(function(t){return h(e[r][1][t]||t)}),u,u.exports,t,e,i,s)}return i[r].exports}for(var a="function"==typeof require&&require,r=0;r<s.length;r++)h(s[r]);return h}({1:[function(t,e,i){var s=t("./CacheTrax.js");"object"!=typeof window||window.hasOwnProperty("CacheTrax")||(window.CacheTrax=s),e.exports=s},{"./CacheTrax.js":2}],2:[function(t,e,i){ | ||
/** | ||
* Cache data structure with: | ||
* - enumerable items | ||
* - unique hash item access (if none is passed in, one is generated) | ||
* - size (length) expiration | ||
* - controllable expiration (e.g. keep in cache longer if older/less likely to change) | ||
* - time-based expiration | ||
* - custom expiration based on passed-in function | ||
* | ||
* Also: | ||
* - built to work well with browserify | ||
* - no dependencies at all | ||
* - pet friendly | ||
* | ||
* @license MIT | ||
* | ||
* @author Steven Velozo <steven@velozo.com> | ||
* @module CashMoney | ||
*/ | ||
const s=t("./LinkedList.js");e.exports=class{constructor(){this._HashMap={},this._List=new s,this.maxLength=0,this.maxAge=0}put(t,e){if(this._HashMap.hasOwnProperty(e))return this._HashMap[e].Datum=t,this._HashMap[e].Datum;let i=this._List.push(t,e);return this._HashMap[i.Hash]=i,this.maxLength>0&&this._List.length>this.maxLength&&(i=this._List.pop(),delete this._HashMap[i.Hash]),i.Metadata.Created=+new Date,i.Datum}touch(t){if(!this._HashMap.hasOwnProperty(t))return!1;let e=this._List.remove(this._HashMap[t]);return delete this._HashMap[t],this.put(e.Datum,e.Hash)}expire(t){if(!this._HashMap.hasOwnProperty(t))return!1;let e=this._HashMap[t];return e=this._List.remove(e),delete this._HashMap[e.Hash],e}pruneBasedOnExpiration(t,e){let i=void 0===e?[]:e;if(this.maxAge<1)return t(i);let s=+new Date,h=Object.keys(this._HashMap);for(let t=0;t<h.length;t++)s-this._HashMap[h[t]].Metadata.Created>=this.maxAge&&i.push(this.expire(h[t]));t(i)}pruneBasedOnLength(t,e){let i=void 0===e?[]:e;if(this.maxLength>0)for(;this._List.length>this.maxLength;)i.push(this._List.pop());return t(i)}pruneCustom(t,e,i){let s=void 0===i?[]:i,h=Object.keys(this._HashMap);for(let t=0;t<h.length;t++){let i=this._HashMap[h[t]];e(i.Datum,i.Hash,i)&&s.push(this.expire(h[t]))}t(s)}prune(t){let e=[];if(this._List.length<1)return t(e);this.pruneBasedOnExpiration((i=>{this.pruneBasedOnLength(t,e)}),e)}read(t){return!!this._HashMap.hasOwnProperty(t)&&this._HashMap[t].Datum}getNode(t){return!!this._HashMap.hasOwnProperty(t)&&this._HashMap[t]}}},{"./LinkedList.js":4}],3:[function(t,e,i){e.exports=class{constructor(){this.Hash=!1,this.Datum=!1,this.Metadata={},this.LeftNode=!1,this.RightNode=!1,this.__ISNODE=!0}}},{}],4:[function(t,e,i){const s=t("./LinkedList-Node.js");e.exports=class{constructor(){this.totalNodes=0,this.length=0,this.head=!1,this.tail=!1}initializeNode(t,e){if(void 0===t)return!1;this.totalNodes++;let i=void 0!==e?e:"NODE[".concat(this.totalNodes,"]"),h=new s;return h.Hash=i,h.Datum=t,h}append(t,e){let i=this.initializeNode(t,e);return!!i&&(this.length++,1==this.length?(this.head=i,this.tail=i,i):(this.tail.RightNode=i,i.LeftNode=this.tail,this.tail=i,i))}push(t,e){return this.append(t,e)}prepend(t,e){let i=this.initializeNode(t,e);return!!i&&(this.length++,1==this.length?(this.head=i,this.tail=i,i):(this.head.LeftNode=i,i.RightNode=this.head,this.head=i,i))}remove(t){return void 0!==t&&(!!t.__ISNODE&&(this.length--,this.length<1?(this.head=!1,this.tail=!1,t):t.LeftNode&&t.RightNode?(t.LeftNode.RightNode=t.RightNode,t.RightNode.LeftNode=t.LeftNode,t.RightNode=!1,t.LeftNode=!1,t):t.LeftNode?(t.LeftNode.RightNode=!1,this.tail=t.LeftNode,t.LeftNode=!1,t):(t.RightNode.LeftNode=!1,this.head=t.RightNode,t.RightNode=!1,t)))}pop(){return this.remove(this.head)}each(t,e){if(this.length<1)return e();let i=!1,s=h=>{if(h)return e(h);if(i){if(!i.RightNode)return e();i=i.RightNode}else i=this.head;t(i.Datum,i.Hash,s)};return s()}seek(t){if(!t)return!1;if(this.length<1)return!1;if(t>=this.length)return!1;let e=this.head;for(let i=0;i<t;i++)e=e.RightNode;return e}}},{"./LinkedList-Node.js":3}]},{},[1])(1)})); | ||
"use strict";function _defineProperty(t,e,i){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==typeof e?e:String(e)}function _toPrimitive(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).CacheTrax=t()}}((function(){return function t(e,i,s){function r(o,n){if(!i[o]){if(!e[o]){var a="function"==typeof require&&require;if(!n&&a)return a(o,!0);if(h)return h(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var u=i[o]={exports:{}};e[o][0].call(u.exports,(function(t){return r(e[o][1][t]||t)}),u,u.exports,t,e,i,s)}return i[o].exports}for(var h="function"==typeof require&&require,o=0;o<s.length;o++)r(s[o]);return r}({1:[function(t,e,i){class s{constructor(t,e){this.fable=!1,this.options="object"==typeof t?t:{},this.serviceType="Unknown",this.UUID="CORESVC-".concat(Math.floor(89999*Math.random()+1e4)),this.Hash="string"==typeof e?e:"".concat(this.UUID)}connectFable(t){return this.fable=t,!0}}_defineProperty(s,"isFableService",!0),e.exports=s},{}],2:[function(t,e,i){class s{constructor(t,e,i){this.fable=t,this.options="object"==typeof e?e:"object"!=typeof t||t.isFable?{}:t,this.serviceType="Unknown","function"==typeof t.getUUID?this.UUID=t.getUUID():this.UUID="NoFABLESVC-".concat(Math.floor(89999*Math.random()+1e4)),this.Hash="string"==typeof i?i:"".concat(this.UUID)}}_defineProperty(s,"isFableService",!0),e.exports=s,e.exports.CoreServiceProviderBase=t("./Fable-ServiceProviderBase-Preinit.js")},{"./Fable-ServiceProviderBase-Preinit.js":1}],3:[function(t,e,i){var s=t("./CacheTrax.js");"object"!=typeof window||window.hasOwnProperty("CacheTrax")||(window.CacheTrax=s),e.exports=s},{"./CacheTrax.js":4}],4:[function(t,e,i){const s=t("fable-serviceproviderbase"),r=t("./LinkedList.js");e.exports=class extends s{constructor(t,e,i){void 0===t?super({}):super(t,e,i),this.serviceType="ObjectCache",this._HashMap={},this._List=new r,this.maxLength=0,this.maxAge=0}put(t,e){if(this._HashMap.hasOwnProperty(e))return this._HashMap[e].Datum=t,this._HashMap[e].Datum;let i=this._List.push(t,e);return this._HashMap[i.Hash]=i,this.maxLength>0&&this._List.length>this.maxLength&&(i=this._List.pop(),delete this._HashMap[i.Hash]),i.Metadata.Created=+new Date,i.Datum}touch(t){if(!this._HashMap.hasOwnProperty(t))return!1;let e=this._List.remove(this._HashMap[t]);return delete this._HashMap[t],this.put(e.Datum,e.Hash)}expire(t){if(!this._HashMap.hasOwnProperty(t))return!1;let e=this._HashMap[t];return e=this._List.remove(e),delete this._HashMap[e.Hash],e}pruneBasedOnExpiration(t,e){let i=void 0===e?[]:e;if(this.maxAge<1)return t(i);let s=+new Date,r=Object.keys(this._HashMap);for(let t=0;t<r.length;t++)s-this._HashMap[r[t]].Metadata.Created>=this.maxAge&&i.push(this.expire(r[t]));t(i)}pruneBasedOnLength(t,e){let i=void 0===e?[]:e;if(this.maxLength>0)for(;this._List.length>this.maxLength;)i.push(this._List.pop());return t(i)}pruneCustom(t,e,i){let s=void 0===i?[]:i,r=Object.keys(this._HashMap);for(let t=0;t<r.length;t++){let i=this._HashMap[r[t]];e(i.Datum,i.Hash,i)&&s.push(this.expire(r[t]))}t(s)}prune(t){let e=[];if(this._List.length<1)return t(e);this.pruneBasedOnExpiration((i=>{this.pruneBasedOnLength(t,e)}),e)}read(t){return!!this._HashMap.hasOwnProperty(t)&&this._HashMap[t].Datum}getNode(t){return!!this._HashMap.hasOwnProperty(t)&&this._HashMap[t]}}},{"./LinkedList.js":6,"fable-serviceproviderbase":2}],5:[function(t,e,i){e.exports=class{constructor(){this.Hash=!1,this.Datum=!1,this.Metadata={},this.LeftNode=!1,this.RightNode=!1,this.__ISNODE=!0}}},{}],6:[function(t,e,i){const s=t("./LinkedList-Node.js");e.exports=class{constructor(){this.totalNodes=0,this.length=0,this.head=!1,this.tail=!1}initializeNode(t,e){if(void 0===t)return!1;this.totalNodes++;let i=void 0!==e?e:"NODE[".concat(this.totalNodes,"]"),r=new s;return r.Hash=i,r.Datum=t,r}append(t,e){let i=this.initializeNode(t,e);return!!i&&(this.length++,1==this.length?(this.head=i,this.tail=i,i):(this.tail.RightNode=i,i.LeftNode=this.tail,this.tail=i,i))}push(t,e){return this.append(t,e)}prepend(t,e){let i=this.initializeNode(t,e);return!!i&&(this.length++,1==this.length?(this.head=i,this.tail=i,i):(this.head.LeftNode=i,i.RightNode=this.head,this.head=i,i))}remove(t){return void 0!==t&&(!!t.__ISNODE&&(this.length--,this.length<1?(this.head=!1,this.tail=!1,t):t.LeftNode&&t.RightNode?(t.LeftNode.RightNode=t.RightNode,t.RightNode.LeftNode=t.LeftNode,t.RightNode=!1,t.LeftNode=!1,t):t.LeftNode?(t.LeftNode.RightNode=!1,this.tail=t.LeftNode,t.LeftNode=!1,t):(t.RightNode.LeftNode=!1,this.head=t.RightNode,t.RightNode=!1,t)))}pop(){return this.remove(this.head)}each(t,e){if(this.length<1)return e();let i=!1,s=r=>{if(r)return e(r);if(i){if(!i.RightNode)return e();i=i.RightNode}else i=this.head;t(i.Datum,i.Hash,s)};return s()}seek(t){if(!t)return!1;if(this.length<1)return!1;if(t>=this.length)return!1;let e=this.head;for(let i=0;i<t;i++)e=e.RightNode;return e}}},{"./LinkedList-Node.js":5}]},{},[3])(3)})); | ||
//# sourceMappingURL=cachetrax.min.js.map |
{ | ||
"name": "cachetrax", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Caching.", | ||
@@ -59,3 +59,5 @@ "main": "source/CacheTrax.js", | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"fable-serviceproviderbase": "^3.0.4" | ||
} | ||
} |
@@ -15,21 +15,23 @@ /** | ||
* | ||
* @license MIT | ||
* | ||
* @author Steven Velozo <steven@velozo.com> | ||
* @module CashMoney | ||
*/ | ||
const libFableServiceProviderBase = require('fable-serviceproviderbase'); | ||
/** | ||
* Quality Cache Goodness | ||
* | ||
* @class CashMoney | ||
* @constructor | ||
*/ | ||
const libLinkedList = require(`./LinkedList.js`); | ||
class CashMoney | ||
class CashMoney extends libFableServiceProviderBase | ||
{ | ||
constructor() | ||
constructor(pFable, pManifest, pServiceHash) | ||
{ | ||
if (pFable === undefined) | ||
{ | ||
super({}); | ||
} | ||
else | ||
{ | ||
super(pFable, pManifest, pServiceHash); | ||
} | ||
this.serviceType = 'ObjectCache'; | ||
// The map of node objects by hash because Reasons. | ||
@@ -36,0 +38,0 @@ this._HashMap = {}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
172925
2131
1
+ Addedfable-serviceproviderbase@3.0.15(transitive)