lowdb
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -19,3 +19,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
read() { | ||
const value = global.localStorage.getItem(__classPrivateFieldGet(this, _LocalStorage_key, "f")); | ||
const value = localStorage.getItem(__classPrivateFieldGet(this, _LocalStorage_key, "f")); | ||
if (value === null) { | ||
@@ -27,5 +27,5 @@ return null; | ||
write(obj) { | ||
global.localStorage.setItem(__classPrivateFieldGet(this, _LocalStorage_key, "f"), JSON.stringify(obj)); | ||
localStorage.setItem(__classPrivateFieldGet(this, _LocalStorage_key, "f"), JSON.stringify(obj)); | ||
} | ||
} | ||
_LocalStorage_key = new WeakMap(); |
@@ -13,3 +13,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
var _TextFile_filename, _TextFile_writer; | ||
import fs from 'fs/promises'; | ||
import fs from 'node:fs/promises'; | ||
import { Writer } from 'steno'; | ||
@@ -16,0 +16,0 @@ export class TextFile { |
@@ -13,4 +13,4 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
var _TextFileSync_tempFilename, _TextFileSync_filename; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
export class TextFileSync { | ||
@@ -17,0 +17,0 @@ constructor(filename) { |
{ | ||
"name": "lowdb", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Tiny local JSON database for Node, Electron and the browser", | ||
@@ -53,6 +53,6 @@ "keywords": [ | ||
"@types/lodash": "^4.14.186", | ||
"@types/node": "^18.11.0", | ||
"@types/node": "^18.11.3", | ||
"@typicode/eslint-config": "^1.1.0", | ||
"del-cli": "^5.0.0", | ||
"eslint": "^8.25.0", | ||
"eslint": "^8.26.0", | ||
"husky": "^8.0.1", | ||
@@ -59,0 +59,0 @@ "lodash": "^4.17.21", |
# lowdb [![](http://img.shields.io/npm/dm/lowdb.svg?style=flat)](https://www.npmjs.org/package/lowdb) [![Node.js CI](https://github.com/typicode/lowdb/actions/workflows/node.js.yml/badge.svg)](https://github.com/typicode/lowdb/actions/workflows/node.js.yml) | ||
> Simple to use local JSON database. Powered by plain JavaScript 🦉 | ||
> Simple to use local JSON database. Use native JavaScript API to query. Written in TypeScript. 🦉 | ||
```js | ||
// Edit db.json content using plain JS | ||
// Edit db.json content using native JS API | ||
db.data | ||
@@ -63,12 +63,13 @@ .posts | ||
_Lowdb 3 is a pure ESM package. If you're having trouble importing it in your project, please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)._ | ||
_Lowdb is a pure ESM package. If you're having trouble importing it in your project, please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)._ | ||
```js | ||
import { join, dirname } from 'path' | ||
import { join, dirname } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
// This will work for a local JSON file, for browser usage see examples/ directory | ||
import { Low, JSONFile } from 'lowdb' | ||
import { fileURLToPath } from 'url' | ||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
// Use JSON file for storage | ||
const file = join(__dirname, 'db.json') | ||
@@ -86,3 +87,3 @@ const adapter = new JSONFile(file) | ||
// Create and query items using plain JS | ||
// Create and query items using native JS API | ||
db.data.posts.push('hello world') | ||
@@ -89,0 +90,0 @@ const firstPost = db.data.posts[0] |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
26855
352
0