@thi.ng/idgen
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -6,3 +6,3 @@ # Change Log | ||
## [0.2.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/idgen@0.2.4...@thi.ng/idgen@0.2.5) (2020-03-06) | ||
## [0.2.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/idgen@0.2.5...@thi.ng/idgen@0.2.6) (2020-03-28) | ||
@@ -15,26 +15,2 @@ **Note:** Version bump only for package @thi.ng/idgen | ||
## [0.2.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/idgen@0.2.3...@thi.ng/idgen@0.2.4) (2020-02-26) | ||
**Note:** Version bump only for package @thi.ng/idgen | ||
## [0.2.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/idgen@0.2.2...@thi.ng/idgen@0.2.3) (2020-02-26) | ||
**Note:** Version bump only for package @thi.ng/idgen | ||
## [0.2.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/idgen@0.2.1...@thi.ng/idgen@0.2.2) (2020-02-25) | ||
**Note:** Version bump only for package @thi.ng/idgen | ||
# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/idgen@0.1.0...@thi.ng/idgen@0.2.0) (2020-01-24) | ||
@@ -41,0 +17,0 @@ |
@@ -1,7 +0,2 @@ | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
import { __decorate } from "tslib"; | ||
import { assert, INotifyMixin } from "@thi.ng/api"; | ||
@@ -8,0 +3,0 @@ export const EVENT_ADDED = "added"; |
@@ -5,10 +5,5 @@ 'use strict'; | ||
var tslib = require('tslib'); | ||
var api = require('@thi.ng/api'); | ||
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
const EVENT_ADDED = "added"; | ||
@@ -114,3 +109,3 @@ const EVENT_REMOVED = "removed"; | ||
}; | ||
exports.IDGen = __decorate([ | ||
exports.IDGen = tslib.__decorate([ | ||
api.INotifyMixin | ||
@@ -117,0 +112,0 @@ ], exports.IDGen); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@thi.ng/api")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/api"],e):e(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.idgen={}),t.thi.ng.api)}(this,(function(t,e){"use strict";var i=function(t,e,i,s){var r,n=arguments.length,h=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(h=(n<3?r(h):n>3?r(e,i,h):r(e,i))||h);return n>3&&h&&Object.defineProperty(e,i,h),h};t.IDGen=class{constructor(t=32,i=32-t,s=Math.pow(2,t),r=0){const n=Math.pow(2,t);e.assert(t>0&&t+i<=32,"wrong total bit size [1..32]"),e.assert(s<=n,`requested capacity too large for bit size (max. ${n})`),this.ids=[],this.nextID=r,this.start=r,this._capacity=s,this.num=0,this.mask=n-1,this.vmask=(1<<i)-1,this.shift=t,this._freeID=-1}id(t){return t&this.mask}version(t){return t>>>this.shift&this.vmask}get capacity(){return this._capacity}set capacity(t){if(e.assert(!this.vmask,"can't change capacity w/ versioning enabled"),!(t>=this.mask+1))throw new Error("can't reduce capacity");{const i=Math.ceil(Math.log2(t));e.assert(i>0&&i<=32,"wrong bit size for new capacity [1..32]"),this._capacity=t,this.mask=Math.pow(2,i)-1,this.shift=i}}get available(){return this._capacity-this.num-this.start}get used(){return this.num}get freeID(){return this._freeID}*[Symbol.iterator](){for(let t=this.nextID;--t>=0;){const e=this.ids[t];(e&this.mask)===t&&(yield e)}}clear(){this.ids.length=0,this.nextID=this.start,this.num=0,this._freeID=-1}next(){let t;if(-1!==this._freeID){t=this._freeID;const e=this.id(t);this._freeID=this.ids[e],this.ids[e]=t}else e.assert(this.nextID<this._capacity,"max capacity reached"),t=this.nextID++,this.ids[t]=t;return this.num++,this.notify({id:"added",target:this,value:t}),t}free(t){return!!this.has(t)&&(this.ids[this.id(t)]=this._freeID,this._freeID=this.nextVersion(t),this.num--,this.notify({id:"removed",target:this,value:t}),!0)}has(t){const e=this.id(t);return t>=0&&e<this.nextID&&this.ids[e]===t}addListener(t,e,i){}removeListener(t,e,i){}notify(t){}nextVersion(t){return(t&this.mask|(this.version(t)+1&this.vmask)<<this.shift)>>>0}},t.IDGen=i([e.INotifyMixin],t.IDGen);t.EVENT_ADDED="added",t.EVENT_REMOVED="removed",t.idgen=(e,i,s,r)=>new t.IDGen(e,i,s,r),Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("tslib"),require("@thi.ng/api")):"function"==typeof define&&define.amd?define(["exports","tslib","@thi.ng/api"],i):i(((t=t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.idgen={}),t.thi.ng[""],t.thi.ng.api)}(this,(function(t,i,e){"use strict";t.IDGen=class{constructor(t=32,i=32-t,s=Math.pow(2,t),h=0){const r=Math.pow(2,t);e.assert(t>0&&t+i<=32,"wrong total bit size [1..32]"),e.assert(s<=r,`requested capacity too large for bit size (max. ${r})`),this.ids=[],this.nextID=h,this.start=h,this._capacity=s,this.num=0,this.mask=r-1,this.vmask=(1<<i)-1,this.shift=t,this._freeID=-1}id(t){return t&this.mask}version(t){return t>>>this.shift&this.vmask}get capacity(){return this._capacity}set capacity(t){if(e.assert(!this.vmask,"can't change capacity w/ versioning enabled"),!(t>=this.mask+1))throw new Error("can't reduce capacity");{const i=Math.ceil(Math.log2(t));e.assert(i>0&&i<=32,"wrong bit size for new capacity [1..32]"),this._capacity=t,this.mask=Math.pow(2,i)-1,this.shift=i}}get available(){return this._capacity-this.num-this.start}get used(){return this.num}get freeID(){return this._freeID}*[Symbol.iterator](){for(let t=this.nextID;--t>=0;){const i=this.ids[t];(i&this.mask)===t&&(yield i)}}clear(){this.ids.length=0,this.nextID=this.start,this.num=0,this._freeID=-1}next(){let t;if(-1!==this._freeID){t=this._freeID;const i=this.id(t);this._freeID=this.ids[i],this.ids[i]=t}else e.assert(this.nextID<this._capacity,"max capacity reached"),t=this.nextID++,this.ids[t]=t;return this.num++,this.notify({id:"added",target:this,value:t}),t}free(t){return!!this.has(t)&&(this.ids[this.id(t)]=this._freeID,this._freeID=this.nextVersion(t),this.num--,this.notify({id:"removed",target:this,value:t}),!0)}has(t){const i=this.id(t);return t>=0&&i<this.nextID&&this.ids[i]===t}addListener(t,i,e){}removeListener(t,i,e){}notify(t){}nextVersion(t){return(t&this.mask|(this.version(t)+1&this.vmask)<<this.shift)>>>0}},t.IDGen=i.__decorate([e.INotifyMixin],t.IDGen);t.EVENT_ADDED="added",t.EVENT_REMOVED="removed",t.idgen=(i,e,s,h)=>new t.IDGen(i,e,s,h),Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@thi.ng/idgen", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "Generator of opaque numeric identifiers with optional support for ID versioning and efficient re-use", | ||
@@ -24,3 +24,3 @@ "module": "./index.js", | ||
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", | ||
"doc:readme": "../../scripts/generate-readme", | ||
"doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts", | ||
"doc": "node_modules/.bin/typedoc --mode modules --out doc src", | ||
@@ -42,3 +42,4 @@ "doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose", | ||
"dependencies": { | ||
"@thi.ng/api": "^6.8.3" | ||
"@thi.ng/api": "^6.9.0", | ||
"tslib": "^1.11.1" | ||
}, | ||
@@ -61,3 +62,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "18014ee1e4978dac7eb2e5d51d0a6ff7d82e9ffc" | ||
"gitHead": "202477e312cf26869f0421e42a9a5fd80ff6adc8" | ||
} |
<!-- This file is generated - DO NOT EDIT! --> | ||
# ![@thi.ng/idgen](https://media.thi.ng/umbrella/banners/thing-idgen.svg?1582660655) | ||
# ![@thi.ng/idgen](https://media.thi.ng/umbrella/banners/thing-idgen.svg?1585427322) | ||
@@ -18,3 +18,3 @@ [![npm version](https://img.shields.io/npm/v/@thi.ng/idgen.svg)](https://www.npmjs.com/package/@thi.ng/idgen) | ||
- [ID generator with 16 bit range and no versioning](#id-generator-with-16-bit-range-and-no-versioning) | ||
- [ID generator w/ 24 bit range & 8 bit version range](#id-generator-w-24-bit-range--8-bit-version-range) | ||
- [ID generator w/ 24 bit range & 8 bit version range](#id-generator-w--24-bit-range--8-bit-version-range) | ||
- [IDGen is iterable](#idgen-is-iterable) | ||
@@ -57,3 +57,3 @@ - [Authors](#authors) | ||
Package sizes (gzipped): ESM: 1.0KB / CJS: 1.0KB / UMD: 1.1KB | ||
Package sizes (gzipped): ESM: 847 bytes / CJS: 895 bytes / UMD: 985 bytes | ||
@@ -63,2 +63,3 @@ ## Dependencies | ||
- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api) | ||
- [tslib](https://github.com/thi-ng/umbrella/tree/develop/packages/undefined) | ||
@@ -65,0 +66,0 @@ ## API |
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
171
32139
2
9
269
+ Addedtslib@^1.11.1
+ Addedtslib@1.14.1(transitive)
Updated@thi.ng/api@^6.9.0