async-atomic-store
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -1,2 +0,7 @@ | ||
import AwaitLock from 'await-lock'; | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const await_lock_1 = __importDefault(require("await-lock")); | ||
/** | ||
@@ -6,4 +11,4 @@ * Do a datastore-wide lock when calling any methods. | ||
*/ | ||
export const AsyncAtomicStore = (creationOptions) => { | ||
const lock = new AwaitLock(); | ||
exports.AsyncAtomicStore = (creationOptions) => { | ||
const lock = new await_lock_1.default(); | ||
const { read, write, data } = creationOptions; | ||
@@ -63,5 +68,5 @@ return { | ||
*/ | ||
export const AsyncArray = (array) => { | ||
exports.AsyncArray = (array) => { | ||
const innerArray = array || []; | ||
return AsyncAtomicStore({ | ||
return exports.AsyncAtomicStore({ | ||
data: async () => innerArray, | ||
@@ -77,5 +82,5 @@ read: async (index) => innerArray[index], | ||
*/ | ||
export const AsyncObject = (obj) => { | ||
exports.AsyncObject = (obj) => { | ||
const innerObj = obj || Object.create(null); | ||
return AsyncAtomicStore({ | ||
return exports.AsyncAtomicStore({ | ||
data: async () => innerObj, | ||
@@ -91,5 +96,5 @@ read: async (index) => innerObj[index], | ||
*/ | ||
export const AsyncMap = (map) => { | ||
exports.AsyncMap = (map) => { | ||
const innerMap = map || new Map(); | ||
return AsyncAtomicStore({ | ||
return exports.AsyncAtomicStore({ | ||
data: async () => innerMap, | ||
@@ -96,0 +101,0 @@ read: async (key) => innerMap.get(key), |
{ | ||
"name": "async-atomic-store", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "An agnostic little store abstraction for reading, writing and appending on the same data from multiple sources in a locking manner, that allows concurrent/parallel (like from many async sources) write, append and read", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
17023
137