@rimbu/hashed
Advanced tools
Comparing version 0.8.11 to 0.8.12
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./hashed-custom"), exports); | ||
tslib_1.__exportStar(require("./hashed-custom"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./hasher"), exports); | ||
tslib_1.__exportStar(require("./hasher"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -15,5 +15,5 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("../common"), exports); | ||
(0, tslib_1.__exportStar)(require("@rimbu/hashed/map"), exports); | ||
(0, tslib_1.__exportStar)(require("@rimbu/hashed/set"), exports); | ||
tslib_1.__exportStar(require("../common"), exports); | ||
tslib_1.__exportStar(require("@rimbu/hashed/map"), exports); | ||
tslib_1.__exportStar(require("@rimbu/hashed/set"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -12,8 +12,9 @@ "use strict"; | ||
var HashMapBlockBuilder = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashMapBlockBuilder, _super); | ||
tslib_1.__extends(HashMapBlockBuilder, _super); | ||
function HashMapBlockBuilder(context, source, _entries, _entrySets, size, level) { | ||
if (size === void 0) { size = (_a = source === null || source === void 0 ? void 0 : source.size) !== null && _a !== void 0 ? _a : 0; } | ||
if (level === void 0) { level = (_b = source === null || source === void 0 ? void 0 : source.level) !== null && _b !== void 0 ? _b : 0; } | ||
var _this = this; | ||
var _a, _b; | ||
var _this = _super.call(this) || this; | ||
_this = _super.call(this) || this; | ||
_this.context = context; | ||
@@ -70,3 +71,3 @@ _this.source = source; | ||
var currentEntry = _this.entries[keyIndex]; | ||
var _a = (0, tslib_1.__read)(currentEntry, 2), currentKey = _a[0], currentValue = _a[1]; | ||
var _a = tslib_1.__read(currentEntry, 2), currentKey = _a[0], currentValue = _a[1]; | ||
if (_this.context.eq(key, currentKey)) { | ||
@@ -323,3 +324,3 @@ // exact match | ||
var HashMapCollisionBuilder = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashMapCollisionBuilder, _super); | ||
tslib_1.__extends(HashMapCollisionBuilder, _super); | ||
function HashMapCollisionBuilder(context, source, _entries) { | ||
@@ -326,0 +327,0 @@ var _this = _super.call(this) || this; |
@@ -11,3 +11,3 @@ "use strict"; | ||
var HashMapContext = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashMapContext, _super); | ||
tslib_1.__extends(HashMapContext, _super); | ||
function HashMapContext(hasher, eq, blockSizeBits, listContext) { | ||
@@ -14,0 +14,0 @@ var _this = _super.call(this) || this; |
@@ -11,3 +11,3 @@ "use strict"; | ||
var HashMapEmpty = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashMapEmpty, _super); | ||
tslib_1.__extends(HashMapEmpty, _super); | ||
function HashMapEmpty(context) { | ||
@@ -79,3 +79,3 @@ var _this = _super.call(this) || this; | ||
var HashMapNonEmptyBase = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashMapNonEmptyBase, _super); | ||
tslib_1.__extends(HashMapNonEmptyBase, _super); | ||
function HashMapNonEmptyBase() { | ||
@@ -171,3 +171,3 @@ return _super !== null && _super.apply(this, arguments) || this; | ||
var HashMapBlock = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashMapBlock, _super); | ||
tslib_1.__extends(HashMapBlock, _super); | ||
function HashMapBlock(context, entries, entrySets, size, level) { | ||
@@ -413,3 +413,3 @@ var _this = _super.call(this) || this; | ||
var HashMapCollision = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashMapCollision, _super); | ||
tslib_1.__extends(HashMapCollision, _super); | ||
function HashMapCollision(context, entries) { | ||
@@ -416,0 +416,0 @@ var _this = _super.call(this) || this; |
@@ -5,8 +5,8 @@ "use strict"; | ||
// pure interfaces | ||
(0, tslib_1.__exportStar)(require("./interface"), exports); | ||
tslib_1.__exportStar(require("./interface"), exports); | ||
// pure classes and files | ||
(0, tslib_1.__exportStar)(require("./implementation/immutable"), exports); | ||
(0, tslib_1.__exportStar)(require("./implementation/builder"), exports); | ||
tslib_1.__exportStar(require("./implementation/immutable"), exports); | ||
tslib_1.__exportStar(require("./implementation/builder"), exports); | ||
// circular dependencies | ||
(0, tslib_1.__exportStar)(require("./implementation/context"), exports); | ||
tslib_1.__exportStar(require("./implementation/context"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -11,4 +11,3 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("../common"), exports); | ||
(0, tslib_1.__exportStar)(require("./interface"), exports); | ||
tslib_1.__exportStar(require("./interface"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
var _defaultContext = (0, map_custom_1.createHashMapContext)(); | ||
exports.HashMap = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, _defaultContext), { createContext: map_custom_1.createHashMapContext, defaultContext: function () { | ||
exports.HashMap = tslib_1.__assign(tslib_1.__assign({}, _defaultContext), { createContext: map_custom_1.createHashMapContext, defaultContext: function () { | ||
return _defaultContext; | ||
} }); | ||
//# sourceMappingURL=index.js.map |
@@ -11,8 +11,9 @@ "use strict"; | ||
var HashSetBlockBuilder = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashSetBlockBuilder, _super); | ||
tslib_1.__extends(HashSetBlockBuilder, _super); | ||
function HashSetBlockBuilder(context, source, _entries, _entrySets, size, level) { | ||
if (size === void 0) { size = (_a = source === null || source === void 0 ? void 0 : source.size) !== null && _a !== void 0 ? _a : 0; } | ||
if (level === void 0) { level = (_b = source === null || source === void 0 ? void 0 : source.level) !== null && _b !== void 0 ? _b : 0; } | ||
var _this = this; | ||
var _a, _b; | ||
var _this = _super.call(this) || this; | ||
_this = _super.call(this) || this; | ||
_this.context = context; | ||
@@ -180,8 +181,9 @@ _this.source = source; | ||
var preSize = entrySet.size; | ||
var changed = entrySet.removeInternal(value, hash); | ||
if (changed) | ||
this.source = undefined; | ||
if (!entrySet.removeInternal(value, hash)) { | ||
return false; | ||
} | ||
this.source = undefined; | ||
this.size += entrySet.size - preSize; | ||
if (entrySet.size > 1) | ||
return changed; | ||
return true; | ||
// single entry needs to be pulled up | ||
@@ -199,2 +201,11 @@ var first = undefined; | ||
delete this.entrySets[index]; | ||
// if the sparse emptySets array is empty, set it to an empty array | ||
var hasEntrySets = false; | ||
for (var _ in this.entrySets) { | ||
hasEntrySets = true; | ||
break; | ||
} | ||
if (!hasEntrySets) { | ||
this.entrySets.length = 0; | ||
} | ||
this.entries[index] = first; | ||
@@ -218,3 +229,3 @@ return true; | ||
var HashSetCollisionBuilder = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashSetCollisionBuilder, _super); | ||
tslib_1.__extends(HashSetCollisionBuilder, _super); | ||
function HashSetCollisionBuilder(context, source, _entries) { | ||
@@ -221,0 +232,0 @@ var _this = _super.call(this) || this; |
@@ -11,3 +11,3 @@ "use strict"; | ||
var HashSetContext = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashSetContext, _super); | ||
tslib_1.__extends(HashSetContext, _super); | ||
function HashSetContext(hasher, eq, blockSizeBits, listContext) { | ||
@@ -14,0 +14,0 @@ var _this = _super.call(this) || this; |
@@ -11,3 +11,3 @@ "use strict"; | ||
var HashSetEmpty = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashSetEmpty, _super); | ||
tslib_1.__extends(HashSetEmpty, _super); | ||
function HashSetEmpty(context) { | ||
@@ -64,3 +64,3 @@ var _this = _super.call(this) || this; | ||
var HashSetNonEmptyBase = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashSetNonEmptyBase, _super); | ||
tslib_1.__extends(HashSetNonEmptyBase, _super); | ||
function HashSetNonEmptyBase() { | ||
@@ -153,3 +153,3 @@ return _super !== null && _super.apply(this, arguments) || this; | ||
var HashSetBlock = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashSetBlock, _super); | ||
tslib_1.__extends(HashSetBlock, _super); | ||
function HashSetBlock(context, entries, entrySets, size, level) { | ||
@@ -331,3 +331,3 @@ var _this = _super.call(this) || this; | ||
var HashSetCollision = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(HashSetCollision, _super); | ||
tslib_1.__extends(HashSetCollision, _super); | ||
function HashSetCollision(context, entries) { | ||
@@ -334,0 +334,0 @@ var _this = _super.call(this) || this; |
@@ -5,8 +5,8 @@ "use strict"; | ||
// pure interfaces | ||
(0, tslib_1.__exportStar)(require("./interface"), exports); | ||
tslib_1.__exportStar(require("./interface"), exports); | ||
// pure classes and files | ||
(0, tslib_1.__exportStar)(require("./implementation/immutable"), exports); | ||
(0, tslib_1.__exportStar)(require("./implementation/builder"), exports); | ||
tslib_1.__exportStar(require("./implementation/immutable"), exports); | ||
tslib_1.__exportStar(require("./implementation/builder"), exports); | ||
// circular dependencies | ||
(0, tslib_1.__exportStar)(require("./implementation/context"), exports); | ||
tslib_1.__exportStar(require("./implementation/context"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -11,4 +11,3 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("../common"), exports); | ||
(0, tslib_1.__exportStar)(require("./interface"), exports); | ||
tslib_1.__exportStar(require("./interface"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -7,5 +7,5 @@ "use strict"; | ||
var _defaultContext = (0, set_custom_1.createHashSetContext)(); | ||
exports.HashSet = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, _defaultContext), { createContext: set_custom_1.createHashSetContext, defaultContext: function () { | ||
exports.HashSet = tslib_1.__assign(tslib_1.__assign({}, _defaultContext), { createContext: set_custom_1.createHashSetContext, defaultContext: function () { | ||
return _defaultContext; | ||
} }); | ||
//# sourceMappingURL=index.js.map |
@@ -8,4 +8,3 @@ /** | ||
*/ | ||
export * from '../common'; | ||
export * from './interface'; | ||
//# sourceMappingURL=index.js.map |
@@ -160,8 +160,9 @@ import { Arr, RimbuError } from '@rimbu/base'; | ||
const preSize = entrySet.size; | ||
const changed = entrySet.removeInternal(value, hash); | ||
if (changed) | ||
this.source = undefined; | ||
if (!entrySet.removeInternal(value, hash)) { | ||
return false; | ||
} | ||
this.source = undefined; | ||
this.size += entrySet.size - preSize; | ||
if (entrySet.size > 1) | ||
return changed; | ||
return true; | ||
// single entry needs to be pulled up | ||
@@ -179,2 +180,11 @@ let first = undefined; | ||
delete this.entrySets[index]; | ||
// if the sparse emptySets array is empty, set it to an empty array | ||
let hasEntrySets = false; | ||
for (const _ in this.entrySets) { | ||
hasEntrySets = true; | ||
break; | ||
} | ||
if (!hasEntrySets) { | ||
this.entrySets.length = 0; | ||
} | ||
this.entries[index] = first; | ||
@@ -181,0 +191,0 @@ return true; |
@@ -8,4 +8,3 @@ /** | ||
*/ | ||
export * from '../common'; | ||
export * from './interface'; | ||
//# sourceMappingURL=index.js.map |
import type { RMapBase } from '@rimbu/collection-types/map-custom'; | ||
import type { Eq } from '@rimbu/common'; | ||
import type { List } from '@rimbu/list'; | ||
import type { Hasher, HashMap } from '@rimbu/hashed/map'; | ||
import type { HashMap } from '@rimbu/hashed/map'; | ||
import type { Hasher } from '../common'; | ||
export interface HashMapCreators extends RMapBase.Factory<HashMap.Types> { | ||
@@ -6,0 +7,0 @@ /** |
@@ -8,3 +8,2 @@ /** | ||
*/ | ||
export * from '../common'; | ||
export * from './interface'; |
@@ -5,3 +5,3 @@ import type { RMap } from '@rimbu/collection-types'; | ||
import type { HashMapCreators } from '@rimbu/hashed/map-custom'; | ||
import type { Hasher } from '@rimbu/hashed/map'; | ||
import type { Hasher } from '../../common'; | ||
import type { Eq } from '@rimbu/common'; | ||
@@ -8,0 +8,0 @@ /** |
import type { RSetBase } from '@rimbu/collection-types/set-custom'; | ||
import type { Eq } from '@rimbu/common'; | ||
import type { List } from '@rimbu/list'; | ||
import type { Hasher, HashSet } from '@rimbu/hashed/set'; | ||
import type { HashSet } from '@rimbu/hashed/set'; | ||
import type { Hasher } from '../common'; | ||
export interface HashSetCreators extends RSetBase.Factory<HashSet.Types> { | ||
@@ -6,0 +7,0 @@ /** |
@@ -8,3 +8,2 @@ /** | ||
*/ | ||
export * from '../common'; | ||
export * from './interface'; |
{ | ||
"name": "@rimbu/hashed", | ||
"version": "0.8.11", | ||
"version": "0.8.12", | ||
"description": "Immutable HashMap and HashSet implementations for TypeScript", | ||
@@ -66,3 +66,3 @@ "keywords": [ | ||
"test": "jest", | ||
"test:random": "jest --config jest-random.config.json", | ||
"test:random": "jest --config jest-random.config.json --runInBand", | ||
"test:types": "tsd", | ||
@@ -73,8 +73,8 @@ "typecheck": "tsc" | ||
"dependencies": { | ||
"@rimbu/base": "^0.8.1", | ||
"@rimbu/collection-types": "^0.9.9", | ||
"@rimbu/common": "^0.9.1", | ||
"@rimbu/list": "^0.10.11", | ||
"@rimbu/stream": "^0.10.9", | ||
"tslib": "^2.3.1" | ||
"@rimbu/base": "^0.8.2", | ||
"@rimbu/collection-types": "^0.9.10", | ||
"@rimbu/common": "^0.9.2", | ||
"@rimbu/list": "^0.10.12", | ||
"@rimbu/stream": "^0.10.10", | ||
"tslib": "^2.4.0" | ||
}, | ||
@@ -95,3 +95,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "f44e1b43f07ac973555270806bbdde5f06400941" | ||
"gitHead": "33dd7ca935f19f513586834a2ce1b1f886352ae7" | ||
} |
@@ -16,3 +16,3 @@ <p align="center"> | ||
For complete documentation please visit the [Map](https://rimbu.org/docs/collections/map) or [Set](https://rimbu.org/docs/collections/set) page _[Rimbu Docs](https://rimbu.org)_. | ||
For complete documentation please visit the [Map](https://rimbu.org/docs/collections/map) or [Set](https://rimbu.org/docs/collections/set) page _[Rimbu Docs](https://rimbu.org)_, or directly see the _[Rimbu Hashed API Docs](https://rimbu.org/api/rimbu/hashed)_. | ||
@@ -23,3 +23,3 @@ Or [Try Out Rimbu](https://codesandbox.io/s/github/vitoke/rimbu-sandbox/tree/main?previewwindow=console&view=split&editorsize=65&moduleview=1&module=/src/index.ts) in CodeSandBox. | ||
All types are exported through [`@rimbu/core`](../core). It is recommended to use that package. | ||
For convenience, all main types are also exported through [`@rimbu/core`](../core). | ||
@@ -38,26 +38,37 @@ To install separately: | ||
Create a file called `rimbu.ts` and add the following: | ||
For Deno, the following approach is recommended: | ||
> ```ts | ||
> export * from 'https://deno.land/x/rimbu/hashed/mod.ts'; | ||
> ``` | ||
In the root folder of your project, create or edit a file called `import_map.json` with the following contents (where you should replace `x.y.z` with the desired version of Rimbu): | ||
Or using a pinned version (`x.y.z`): | ||
```json | ||
{ | ||
"imports": { | ||
"@rimbu/": "https://deno.land/x/rimbu@x.y.z/" | ||
} | ||
} | ||
``` | ||
> ```ts | ||
> export * from 'https://deno.land/x/rimbu/hashed@x.y.z/mod.ts'; | ||
> ``` | ||
**Note: The trailing slashes are important!** | ||
Then import what you need from `rimbu.ts`: | ||
In this way you can use relative imports from Rimbu in your code, like so: | ||
```ts | ||
import { HashSet } from './rimbu.ts'; | ||
import { List } from '@rimbu/core/mod.ts'; | ||
import { HashMap } from '@rimbu/hashed/mod.ts'; | ||
``` | ||
Because Rimbu uses complex types, it's recommended to use the `--no-check` flag (your editor should already have checked your code) and to specify a `tsconfig.json` file with the settings described below. | ||
Note that for sub-packages, due to conversion limitations it is needed to import the `index.ts` instead of `mod.ts`, like so: | ||
Running your script then becomes: | ||
```ts | ||
import { HashMap } from '@rimbu/hashed/map/index.ts'; | ||
``` | ||
> `deno run --no-check --config tsconfig.json <your-script>.ts` | ||
To run your script (let's assume the entry point is in `src/main.ts`): | ||
`deno run --import-map import_map.json src/main.ts` | ||
Because Rimbu uses advanced types, this may slow down the type checking part when running your code. If you're able to rely on your code editor to provide type errors, you can skip the Deno type check using the `--no-check` flag: | ||
`deno run --import-map import_map.json --no-check src/main.ts` | ||
## Usage | ||
@@ -81,3 +92,3 @@ | ||
<img src = "https://contrib.rocks/image?repo=vitoke/iternal"/> | ||
<img src = "https://contrib.rocks/image?repo=rimbu-org/rimbu"/> | ||
@@ -84,0 +95,0 @@ Made with [contributors-img](https://contrib.rocks). |
@@ -5,3 +5,4 @@ import type { RMapBase } from '@rimbu/collection-types/map-custom'; | ||
import type { Hasher, HashMap } from '@rimbu/hashed/map'; | ||
import type { HashMap } from '@rimbu/hashed/map'; | ||
import type { Hasher } from '../common'; | ||
@@ -8,0 +9,0 @@ export interface HashMapCreators extends RMapBase.Factory<HashMap.Types> { |
@@ -9,3 +9,2 @@ /** | ||
export * from '../common'; | ||
export * from './interface'; |
@@ -6,3 +6,3 @@ import type { RMap } from '@rimbu/collection-types'; | ||
import type { HashMapCreators } from '@rimbu/hashed/map-custom'; | ||
import type { Hasher } from '@rimbu/hashed/map'; | ||
import type { Hasher } from '../../common'; | ||
import type { Eq } from '@rimbu/common'; | ||
@@ -9,0 +9,0 @@ |
@@ -214,9 +214,12 @@ import { Arr, RimbuError } from '@rimbu/base'; | ||
const preSize = entrySet.size; | ||
const changed = entrySet.removeInternal(value, hash); | ||
if (changed) this.source = undefined; | ||
if (!entrySet.removeInternal(value, hash)) { | ||
return false; | ||
} | ||
this.source = undefined; | ||
this.size += entrySet.size - preSize; | ||
if (entrySet.size > 1) return changed; | ||
if (entrySet.size > 1) return true; | ||
@@ -237,2 +240,14 @@ // single entry needs to be pulled up | ||
delete this.entrySets[index]; | ||
// if the sparse emptySets array is empty, set it to an empty array | ||
let hasEntrySets = false; | ||
for (const _ in this.entrySets) { | ||
hasEntrySets = true; | ||
break; | ||
} | ||
if (!hasEntrySets) { | ||
this.entrySets.length = 0; | ||
} | ||
this.entries[index] = first; | ||
@@ -239,0 +254,0 @@ return true; |
@@ -5,3 +5,4 @@ import type { RSetBase } from '@rimbu/collection-types/set-custom'; | ||
import type { Hasher, HashSet } from '@rimbu/hashed/set'; | ||
import type { HashSet } from '@rimbu/hashed/set'; | ||
import type { Hasher } from '../common'; | ||
@@ -8,0 +9,0 @@ export interface HashSetCreators extends RSetBase.Factory<HashSet.Types> { |
@@ -9,3 +9,2 @@ /** | ||
export * from '../common'; | ||
export * from './interface'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
483064
8519
98
Updated@rimbu/base@^0.8.2
Updated@rimbu/common@^0.9.2
Updated@rimbu/list@^0.10.12
Updated@rimbu/stream@^0.10.10
Updatedtslib@^2.4.0