New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 7.0.3-build-flowzone-appvoyer-8971feccdd769237080f9dd69a15735c19f6a7a1-1 to 8.0.0-build-browser-cd151cd730442cb2c83ff667b869f30fe314d651-1

appveyor.yml

19

build/storage.d.ts

@@ -1,3 +0,6 @@

import { BalenaSettingsStorage } from './types';
/**
* @module storage
*/
import { BalenaSettingsStorage, StorageLike } from './types';
/**
* @summary Get an instance of storage module

@@ -13,9 +16,11 @@ * @function

* @example
* const storage = require('balena-settings-storage')({
* // with es6 imports
* import { getStorage } from 'balena-settings-storage';
* // or with node require
* const { getStorage } = require('balena-settings-storage');
*
* const storage = getStorage({
* dataDirectory: '/opt/cache/balena'
* })
* });
*/
declare const getStorage: ({ dataDirectory, }?: {
dataDirectory?: string | undefined;
}) => BalenaSettingsStorage;
export = getStorage;
export declare const getStorage: (store: StorageLike) => BalenaSettingsStorage;
"use strict";
/*
Copyright 2016 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const tslib_1 = require("tslib");
/**
* @module storage
*/
const local_storage_1 = require("./local-storage");
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStorage = void 0;
const tslib_1 = require("tslib");
const balena_errors_1 = require("balena-errors");

@@ -34,8 +20,12 @@ /**

* @example
* const storage = require('balena-settings-storage')({
* // with es6 imports
* import { getStorage } from 'balena-settings-storage';
* // or with node require
* const { getStorage } = require('balena-settings-storage');
*
* const storage = getStorage({
* dataDirectory: '/opt/cache/balena'
* })
* });
*/
const getStorage = ({ dataDirectory, } = {}) => {
const localStorage = (0, local_storage_1.createStorage)(dataDirectory);
const getStorage = (store) => {
/**

@@ -58,3 +48,3 @@ * @summary Set a value

}
return localStorage.setItem(name, value);
return store.setItem(name, value);
});

@@ -77,3 +67,3 @@ /**

try {
const result = yield localStorage.getItem(name);
const result = yield store.getItem(name);
if (result == null) {

@@ -133,3 +123,3 @@ return undefined;

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

@@ -146,6 +136,6 @@ * @summary Remove all values

*/
const clear = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return localStorage.clear(); });
const clear = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return store.clear(); });
return { set, get, has, remove, clear };
};
module.exports = getStorage;
exports.getStorage = getStorage;
//# sourceMappingURL=storage.js.map

@@ -8,1 +8,8 @@ export interface BalenaSettingsStorage {

}
export interface StorageLike {
clear(): PromiseLike<void> | void;
getItem(key: string): PromiseLike<string | null> | string | null;
setItem(key: string, data: string): PromiseLike<void> | void;
removeItem(key: string): PromiseLike<void> | void;
}
export type StorageFactory = (dataDirectory?: string) => StorageLike;

@@ -7,6 +7,9 @@ # Change Log

# v7.0.3
## (2023-01-19)
# v8.0.0
## (2023-07-24)
* Replace appveyor with flowzone [JSReds]
* Specify a browser entry point [Thodoris Greasidis]
* Use es6 exports [Thodoris Greasidis]
* Update TypeScript to 5.1.6 [Thodoris Greasidis]
* Drop support for nodejs < 14 [Thodoris Greasidis]

@@ -13,0 +16,0 @@ # v7.0.2

@@ -1,17 +0,1 @@

/*
Copyright 2016 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**

@@ -21,4 +5,3 @@ * @module storage

import { createStorage } from './local-storage';
import { BalenaSettingsStorage } from './types';
import { BalenaSettingsStorage, StorageLike } from './types';
import { BalenaSettingsPermissionError } from 'balena-errors';

@@ -37,11 +20,12 @@

* @example
* const storage = require('balena-settings-storage')({
* // with es6 imports
* import { getStorage } from 'balena-settings-storage';
* // or with node require
* const { getStorage } = require('balena-settings-storage');
*
* const storage = getStorage({
* dataDirectory: '/opt/cache/balena'
* })
* });
*/
const getStorage = ({
dataDirectory,
}: { dataDirectory?: string } = {}): BalenaSettingsStorage => {
const localStorage = createStorage(dataDirectory);
export const getStorage = (store: StorageLike): BalenaSettingsStorage => {
/**

@@ -64,3 +48,3 @@ * @summary Set a value

}
return localStorage.setItem(name, value);
return store.setItem(name, value);
};

@@ -86,3 +70,3 @@

try {
const result = await localStorage.getItem(name);
const result = await store.getItem(name);

@@ -147,3 +131,3 @@ if (result == null) {

*/
const remove = async (name: string) => localStorage.removeItem(name);
const remove = async (name: string) => store.removeItem(name);

@@ -161,7 +145,5 @@ /**

*/
const clear = async () => localStorage.clear();
const clear = async () => store.clear();
return { set, get, has, remove, clear };
};
export = getStorage;

@@ -15,1 +15,10 @@ /* TODO:

}
export interface StorageLike {
clear(): PromiseLike<void> | void;
getItem(key: string): PromiseLike<string | null> | string | null;
setItem(key: string, data: string): PromiseLike<void> | void;
removeItem(key: string): PromiseLike<void> | void;
}
export type StorageFactory = (dataDirectory?: string) => StorageLike;
{
"name": "balena-settings-storage",
"version": "7.0.3-build-flowzone-appvoyer-8971feccdd769237080f9dd69a15735c19f6a7a1-1",
"version": "8.0.0-build-browser-cd151cd730442cb2c83ff667b869f30fe314d651-1",
"description": "Balena settings storage utilities",
"main": "build/storage.js",
"types": "build/storage.d.ts",
"main": "build/index.js",
"types": "build/index.d.ts",
"browser": {
"build/index.js": "./build/index.browser.js"
},
"homepage": "https://github.com/balena-io-modules/balena-settings-storage",

@@ -29,3 +32,3 @@ "repository": {

"prettify": "balena-lint --typescript --fix lib tests",
"readme": "jsdoc2md --template doc/README.hbs build/storage.js > README.md"
"readme": "jsdoc2md --template doc/README.hbs build/index.js build/storage.js > README.md"
},

@@ -50,3 +53,3 @@ "author": "Juan Cruz Viotti <juan@balena.io>",

"ts-node": "^10.9.1",
"typescript": "^4.8.4"
"typescript": "^5.1.6"
},

@@ -59,7 +62,7 @@ "dependencies": {

"engines": {
"node": ">=10.17.0"
"node": ">=14.0"
},
"versionist": {
"publishedAt": "2023-01-19T14:42:30.220Z"
"publishedAt": "2023-07-24T13:03:39.076Z"
}
}

@@ -57,5 +57,10 @@ balena-settings-storage

```js
const storage = require('balena-settings-storage')({
// with es6 imports
import { getStorage } from 'balena-settings-storage';
// or with node require
const { getStorage } = require('balena-settings-storage');
const storage = getStorage({
dataDirectory: '/opt/cache/balena'
})
});
```

@@ -62,0 +67,0 @@

import { expect } from 'chai';
import * as BalenaSettingsClientModule from 'balena-settings-client';
import { createStorage } from '../lib/local-storage';
import { createStorage } from '../lib/stores/local-storage';

@@ -10,4 +9,5 @@ const IS_BROWSER = typeof window !== 'undefined';

if (!IS_BROWSER) {
// tslint:disable-next-line no-var-requires
const settings: typeof BalenaSettingsClientModule = require('balena-settings-client');
const settings =
// tslint:disable-next-line no-var-requires
require('balena-settings-client') as typeof import('balena-settings-client');
dataDirectory = settings.get<string>('dataDirectory');

@@ -14,0 +14,0 @@ }

@@ -5,10 +5,7 @@ import * as chai from 'chai';

import * as chaiAsPromised from 'chai-as-promised';
import * as BalenaSettingsClientModule from 'balena-settings-client';
import * as FsModule from 'fs';
import * as path from 'path';
import { BalenaSettingsPermissionError } from 'balena-errors';
chai.use(chaiAsPromised);
import { createStorage } from '../lib/local-storage';
import getStorage = require('../lib/storage');
import { createStorage } from '../lib/stores/local-storage';
import { getStorage } from '..';

@@ -18,7 +15,10 @@ const IS_BROWSER = typeof window !== 'undefined';

let dataDirectory: string | undefined;
let fs: typeof FsModule;
let fs: typeof import('fs');
let path: typeof import('path');
if (!IS_BROWSER) {
// tslint:disable no-var-requires
fs = require('fs');
const settings: typeof BalenaSettingsClientModule = require('balena-settings-client');
path = require('path');
const settings =
require('balena-settings-client') as typeof import('balena-settings-client');
dataDirectory = settings.get<string>('dataDirectory');

@@ -25,0 +25,0 @@ }

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