![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
base-storage
Advanced tools
Provides easy way to get / set and check the existence of a paths in the objects
Provides easy way to get / set and check the existence of a paths in the objects
npm install --save base-storage
import BaseStorage from 'base-storage';
const storage = new BaseStorage({
a: {
b: {
c: {
d: 1,
e: 2
}
}
},
f: 2
});
// has method
expect(storage.has('a')).to.be.equal(true);
expect(storage.has('A')).to.be.equal(false);
// get method
expect(storage.get('f')).to.be.equal(2);
expect(storage.get('a.b.c.d')).to.be.equal(1);
expect(storage.get('a.b.c')).to.be.equal({
d: 1,
e: 2
});
// set method
storage.set('x.y.z', 100500);
expect(storage.get('x')).to.be.equal({
y: {
z: 100500
}
});
import BaseStorage from 'base-storage';
class CustomStorage extends BaseStorage {
constructor(config) {
super(config);
}
set() {
throw new Error('"set" method is denied')
}
}
Very useful for using as config storage with presets (shortcuts)
import BaseStorage from 'base-storage';
class AppConfig extends BaseStorage {
routing: {
add: (path, action) => {
let routes = this.get('routing.actions', []);
routes.push({path, action});
this.set('routing.actions', routes);
},
enableHistoryApi: () => {
this.set('routing.isHistoryApiEnabled', true);
},
disableHistoryApi: () => {
this.set('routing.isHistoryApiEnabled', false);
}
};
exceptions: {
handler: (handler) => {
let handlers = this.get('exceptions.handlers', []);
handlers.push(handler);
this.set('exceptions.handlers', handlers);
}
};
api: {
setHost: host => this.set('api.host', host),
setPort: port => this.set('api.port', port),
setPrefix: prefix => this.set('api.prefix', prefix),
};
google: {
setAuthClientId: clientId => this.set('google.auth.clientId', clientId),
getAuthClientId: () => this.get('google.auth.clientId'),
setAnalyticsId: analyticsId => this.set('google.analyticsId.id', analyticsId),
}
constructor(config) {
super(config);
}
}
let config = new AppConfig();
// ....
config.google.setAuthClientId('xxx');
config.google.setAnalyticsId('zzz');
expect(config.get('google')).to.be.equal({
auth: {
clientId: 'xxx',
},
analyticsId: {
id: 'zzz'
}
});
expect(config.get('google.auth.clientId')).to.be.equal('xxx');
expect(config.getAuthClientId()).to.be.equal('xxx');
constructor(object)
- constructor takes object with which get / set / has methods will work
get(path, defaultValue)
- gets the value at path of object. If the resolved value is undefined the defaultValue is used in its place. (lodash/get)
set(path, value)
- sets the value at path of object. (lodash/set)
has(path)
- returns true is path exists and false - if not. (lodash/has)
You are always welcome for ideas and pull requests :)
FAQs
Provides easy way to get / set and check the existence of a paths in the objects
The npm package base-storage receives a total of 1 weekly downloads. As such, base-storage popularity was classified as not popular.
We found that base-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.