data-structure-js
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -1,1 +0,231 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var f=r[n]={i:n,l:!1,exports:{}};return e[n].call(f.exports,f,f.exports,t),f.l=!0,f.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),f=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=f.default,e.exports=t.default},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var f=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=function(){function e(){n(this,e),this._cached=new Map,this._buffer=new Map,this._mapKeys=new Map}return f(e,[{key:"set",value:function(t,r){this._buffer||(this._buffer=new Map);var n=e.normalizeParentKey(t);return this._mapKeys.has(n)?this._cached.set(n,r):this._mapKeys.has(t)?(this._cached.get(n).set(t,r),this._buffer=this._cached.get(n)):void this._buffer.set(t,r)}},{key:"get",value:function(t){if(this._buffer&&this._buffer.has(t))return this._buffer.get(t);var r=e.normalizeParentKey(t);if(!this._mapKeys.has(t)&&!this._mapKeys.has(r))return null;if(this._mapKeys.has(r))return this._buffer=this._cached.get(r),this._buffer.set("parentKey",r),this._buffer;if(!this._mapKeys.has(r)){var n=this._mapKeys.get(t);return this._buffer=this._cached.get(n),this._buffer.set("parentKey",n),this._buffer.get(t)}}},{key:"commit",value:function(t){if(!t)throw new Error("`key` param is required for `commit` function");var r=e.normalizeParentKey(t);if(!this._buffer.has(r)){this._cached.set(r,this._buffer);var n=!0,f=!1,i=void 0;try{for(var u,s=this._buffer.keys()[Symbol.iterator]();!(n=(u=s.next()).done);n=!0){var a=u.value;this._mapKeys.set(a,r)}}catch(e){f=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(f)throw i}}return this._mapKeys.set(r,null),void(this._buffer=null)}if(this._buffer.get("parentKey")!==r)throw new Error("You should use `clear` method first, and then `set` with `[key, value]`");this._buffer=null}}],[{key:"normalizeParentKey",value:function(e){return"pkey-"+e}}]),e}();t.default=i,e.exports=t.default}])}); | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else { | ||
var a = factory(); | ||
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; | ||
} | ||
})(typeof self !== 'undefined' ? self : this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _CachedMap = __webpack_require__(1); | ||
var _CachedMap2 = _interopRequireDefault(_CachedMap); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = _CachedMap2.default; | ||
module.exports = exports['default']; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var CachedMap = function () { | ||
function CachedMap() { | ||
_classCallCheck(this, CachedMap); | ||
this._cached = new Map(); | ||
this._buffer = new Map(); | ||
this._mapKeys = new Map(); | ||
} | ||
_createClass(CachedMap, [{ | ||
key: 'set', | ||
value: function set(key, v) { | ||
if (!this._buffer) { | ||
this._buffer = new Map(); | ||
} | ||
var parentKey = CachedMap.normalizeParentKey(key); | ||
if (this._mapKeys.has(parentKey)) { | ||
return this._cached.set(parentKey, v); | ||
} | ||
if (this._mapKeys.has(key)) { | ||
this._cached.get(parentKey).set(key, v); | ||
return this._buffer = this._cached.get(parentKey); | ||
} | ||
this._buffer.set(key, v); | ||
} | ||
}, { | ||
key: 'get', | ||
value: function get(key) { | ||
// first, get from buffer; | ||
if (this._buffer && this._buffer.has(key)) { | ||
return this._buffer.get(key); | ||
} | ||
var parentKey = CachedMap.normalizeParentKey(key); | ||
if (!this._mapKeys.has(key) && !this._mapKeys.has(parentKey)) { | ||
return null; | ||
} | ||
if (this._mapKeys.has(parentKey)) { | ||
this._buffer = this._cached.get(parentKey); | ||
this._buffer.set('parentKey', parentKey); | ||
return this._buffer; | ||
} | ||
if (!this._mapKeys.has(parentKey)) { | ||
var _parentKey = this._mapKeys.get(key); | ||
this._buffer = this._cached.get(_parentKey); | ||
this._buffer.set('parentKey', _parentKey); | ||
return this._buffer.get(key); | ||
} | ||
} | ||
}, { | ||
key: 'commit', | ||
value: function commit(key) { | ||
if (!key) { | ||
throw new Error('`key` param is required for `commit` function'); | ||
} | ||
var parentKey = CachedMap.normalizeParentKey(key); | ||
if (!this._buffer.has(parentKey)) { | ||
this._cached.set(parentKey, this._buffer); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = this._buffer.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var childKey = _step.value; | ||
this._mapKeys.set(childKey, parentKey); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
this._mapKeys.set(parentKey, null); | ||
this._buffer = null; | ||
return; | ||
} | ||
if (this._buffer.get('parentKey') !== parentKey) { | ||
throw new Error('You should use `clear` method first, and then `set` with `[key, value]`'); | ||
} | ||
this._buffer = null; | ||
} | ||
}], [{ | ||
key: 'normalizeParentKey', | ||
value: function normalizeParentKey(key) { | ||
return 'pkey-' + key; | ||
} | ||
}]); | ||
return CachedMap; | ||
}(); | ||
exports.default = CachedMap; | ||
module.exports = exports['default']; | ||
/***/ }) | ||
/******/ ]); | ||
}); |
{ | ||
"name": "data-structure-js", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Provide the basic and frequently used data structure implementation in js.", | ||
@@ -5,0 +5,0 @@ "main": "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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
8183
197