Skip to content

Commit

Permalink
Tweak docs to explain other things changed
Browse files Browse the repository at this point in the history
  • Loading branch information
eslachance committed Apr 2, 2024
1 parent bac1611 commit 747b8d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions UpgradeV6.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,6 @@ These were already planned, and indicated as deprecated for a while now, but the

- The use of `'::memory::` as a name is removed, you can use `inMemory: true` instead. That means `new Enmap('::memory::')` is now `new Enmap({ inMemory: true })`.
- In all loop methods like `every`, `some`, `map` and `filter`, the **value** now comes first, and **key** second. This matches array methods closer.
- Methods will no longer return the enmap upon executing an action. It's always felt weird to me that some methods returned the enmap and others returned data.
- The `destroy` method is removed, since it doesn't make much sense to delete all the db tables. You can still delete all your stuff with `clear()` though.
-
21 changes: 14 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { existsSync, readFileSync, mkdirSync } from 'fs';
import { resolve, sep } from 'path';

import {
get as _get,
set as _set,
Expand All @@ -11,13 +8,21 @@ import {
cloneDeep,
merge,
} from 'lodash-es';
import Database from 'better-sqlite3/lib/database';
import { stringify, parse } from 'better-serialize';
import onChange from 'on-change';

import { stringify, parse } from 'better-serialize';
// Custom error codes with stack support.
import Err from './error.js';

// Native imports
import { existsSync, readFileSync, mkdirSync } from 'fs';
import { resolve, sep } from 'path';

// Package.json
const pkgdata = JSON.parse(readFileSync('./package.json', 'utf8'));

import Database from 'better-sqlite3/lib/database';

const NAME_REGEX = /^([\w-]+)$/;

/**
Expand Down Expand Up @@ -93,7 +98,6 @@ class Enmap {

this.#init();
}


/**
* Sets a value in Enmap.
Expand Down Expand Up @@ -597,7 +601,7 @@ class Enmap {
throw new Err('Importing data from enmap v5 or lower is not supported', 'EnmapDataError');
}

if (clear) this.deleteAll();
if (clear) this.clear();
for (const entry of data.keys) {
const { key, value } = entry;
if (!overwrite && this.has(key)) continue;
Expand Down Expand Up @@ -764,6 +768,7 @@ class Enmap {
}
return null;
}
// TODO: RE-ADD findIndex

/**
* Searches for the key of a single item where its specified property's value is identical to the given value
Expand Down Expand Up @@ -880,6 +885,8 @@ class Enmap {
this.#changedCB = cb;
}

// TODO: RE-ADD forEach (ugh). (partition, merge?)

// INTERNAL METHODS

/*
Expand Down

0 comments on commit 747b8d7

Please sign in to comment.