@graffy/memory 0.19.1-alpha.1 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ const common = require("@graffy/common");
3
+ function index() {
4
+ return (store) => {
5
+ const state = [{ key: common.MIN_KEY, end: common.MAX_KEY, version: 0 }];
6
+ const watcher = common.makeWatcher();
7
+ store.on("read", [], async (query) => {
8
+ return common.setVersion(common.slice(state, query).known, Date.now());
9
+ });
10
+ store.on("watch", [], () => watcher.watch(void 0));
11
+ store.on("write", [], async (change) => {
12
+ common.merge(state, change);
13
+ watcher.write(change);
14
+ return change;
15
+ });
16
+ };
17
+ }
18
+ module.exports = index;
package/index.mjs ADDED
@@ -0,0 +1,19 @@
1
+ import { makeWatcher, setVersion, slice, MAX_KEY, MIN_KEY, merge } from "@graffy/common";
2
+ function index() {
3
+ return (store) => {
4
+ const state = [{ key: MIN_KEY, end: MAX_KEY, version: 0 }];
5
+ const watcher = makeWatcher();
6
+ store.on("read", [], async (query) => {
7
+ return setVersion(slice(state, query).known, Date.now());
8
+ });
9
+ store.on("watch", [], () => watcher.watch(void 0));
10
+ store.on("write", [], async (change) => {
11
+ merge(state, change);
12
+ watcher.write(change);
13
+ return change;
14
+ });
15
+ };
16
+ }
17
+ export {
18
+ index as default
19
+ };
package/package.json CHANGED
@@ -2,25 +2,20 @@
2
2
  "name": "@graffy/memory",
3
3
  "description": "Graffy module providing a simple in-memory store.",
4
4
  "author": "aravind (https://github.com/aravindet)",
5
- "version": "0.19.1-alpha.1",
6
- "main": "./cjs/index.js",
5
+ "version": "0.19.1",
6
+ "main": "./index.cjs",
7
7
  "exports": {
8
- ".": {
9
- "import": "./index.js",
10
- "types": "./index.d.ts"
11
- },
12
- "./*": {
13
- "import": "./*.js",
14
- "types": "./*.d.ts"
15
- }
8
+ "import": "./index.mjs",
9
+ "require": "./index.cjs"
16
10
  },
17
- "types": "./index.d.ts",
11
+ "module": "./index.mjs",
12
+ "types": "./types/index.d.ts",
18
13
  "repository": {
19
14
  "type": "git",
20
15
  "url": "git+https://github.com/usegraffy/graffy.git"
21
16
  },
22
17
  "license": "Apache-2.0",
23
18
  "dependencies": {
24
- "@graffy/common": "0.19.1-alpha.1"
19
+ "@graffy/common": "0.19.1"
25
20
  }
26
21
  }
@@ -0,0 +1 @@
1
+ export default function _default(): (store: any) => void;
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export default function (): (store: any) => void;
package/index.js DELETED
@@ -1,16 +0,0 @@
1
- import { MAX_KEY, MIN_KEY, makeWatcher, merge, setVersion, slice, } from '@graffy/common';
2
- export default function () {
3
- return (store) => {
4
- const state = [{ key: MIN_KEY, end: MAX_KEY, version: 0 }];
5
- const watcher = makeWatcher();
6
- store.on('read', [], async (query) => {
7
- return setVersion(slice(state, query).known, Date.now());
8
- });
9
- store.on('watch', [], () => watcher.watch(undefined));
10
- store.on('write', [], async (change) => {
11
- merge(state, change);
12
- watcher.write(change);
13
- return change;
14
- });
15
- };
16
- }