Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

balena-settings-storage

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balena-settings-storage - npm Package Compare versions

Comparing version 6.0.0-6-x-d01b458423ef67e3f14e30cfc928108fb2cf3153 to 6.0.0

4

build/local-storage.js

@@ -18,2 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createStorage = void 0;
const prefixed = (key) => `balena-${key}`;

@@ -99,2 +100,5 @@ const createVirtualStore = () => {

exports.createStorage = createStorage = (dataDirectory) => {
if (dataDirectory == null) {
throw new Error('dataDirectory must be specified in nodejs');
}
if (!storageCache[dataDirectory]) {

@@ -101,0 +105,0 @@ storageCache[dataDirectory] = new NodeStorage(dataDirectory);

@@ -18,2 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeStorage = void 0;
const tslib_1 = require("tslib");

@@ -20,0 +21,0 @@ const fs_1 = require("fs");

10

build/storage.js

@@ -52,3 +52,3 @@ "use strict";

*/
const set = (name, value) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const set = (name, value) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
if (typeof value !== 'string') {

@@ -73,3 +73,3 @@ value = JSON.stringify(value);

*/
const get = (name) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const get = (name) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
try {

@@ -112,3 +112,3 @@ const result = yield localStorage.getItem(name);

*/
const has = (name) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const has = (name) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const value = yield get(name);

@@ -129,3 +129,3 @@ return value != null;

*/
const remove = (name) => tslib_1.__awaiter(this, void 0, void 0, function* () { return localStorage.removeItem(name); });
const remove = (name) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return localStorage.removeItem(name); });
/**

@@ -142,3 +142,3 @@ * @summary Remove all values

*/
const clear = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return localStorage.clear(); });
const clear = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return localStorage.clear(); });
return { set, get, has, remove, clear };

@@ -145,0 +145,0 @@ };

@@ -10,2 +10,4 @@ # Change Log

* Enable strict type checking [Pagan Gazzard]
* Update typescript [Pagan Gazzard]
* Add engines property to package.json [Pagan Gazzard]

@@ -12,0 +14,0 @@ * Update to @balena/lint 5.x [Pagan Gazzard]

@@ -111,3 +111,6 @@ /*

const storageCache = Object.create(null);
createStorage = (dataDirectory: string) => {
createStorage = (dataDirectory?: string) => {
if (dataDirectory == null) {
throw new Error('dataDirectory must be specified in nodejs');
}
if (!storageCache[dataDirectory]) {

@@ -114,0 +117,0 @@ storageCache[dataDirectory] = new NodeStorage(dataDirectory);

{
"name": "balena-settings-storage",
"version": "6.0.0-6-x-d01b458423ef67e3f14e30cfc928108fb2cf3153",
"version": "6.0.0",
"description": "Balena settings storage utilities",

@@ -47,3 +47,3 @@ "main": "build/storage.js",

"ts-node": "^3.3.0",
"typescript": "3.1.3"
"typescript": "^3.9.6"
},

@@ -50,0 +50,0 @@ "dependencies": {

@@ -107,9 +107,10 @@ import * as BalenaSettingsClientModule from 'balena-settings-client';

describe('given getItem throws an error', () => {
let getItemStub: any;
beforeEach(() => {
this.getItemStub = m.sinon.stub(localStorage, 'getItem');
this.getItemStub.throws(new Error('ENOENT'));
getItemStub = m.sinon.stub(localStorage, 'getItem');
getItemStub.throws(new Error('ENOENT'));
});
afterEach(() => {
this.getItemStub.restore();
getItemStub.restore();
});

@@ -127,9 +128,10 @@

let fooPath: string;
beforeEach(() => {
this.path = path.join(dataDirectory!, 'foo');
fs.writeFileSync(this.path, 'hello world');
fooPath = path.join(dataDirectory!, 'foo');
fs.writeFileSync(fooPath, 'hello world');
});
afterEach(() => {
fs.unlinkSync(this.path);
fs.unlinkSync(fooPath);
});

@@ -136,0 +138,0 @@

@@ -13,3 +13,3 @@ {

"sourceMap": true,
"strictNullChecks": true,
"strict": true,
"typeRoots": [

@@ -16,0 +16,0 @@ "node_modules/@types",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc