
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@typinghare/warehouse
Advanced tools
Just as the CPU fetches data from memory through an address, Warehouse fetches a piece of data via a specified address. The difference between the two is that a warehouse's address is a string and consists of two parts—namespace and label.
When we step into a warehouse, we see plenty of racks, and there may be some same type of goods on different racks. That is because some racks are for newly purchased items and some are not. When replenishment clerks are preparing for replenishment, they will fetch items from those old racks rather than new ones. However, if there are no goods on the old racks, they have to go for the new ones.
So namespaces are racks, and each namespace contains the same type of data; labels are identifiers of items. You can fetch an item from a namespace with a specified label, or fetch an item to a namespace.
The two-part of an address are separated with a colon (:). The followings are legal addresses:
me:username - Namespace is me and label is username.home:env.debug - Namespace is home and label is env.debug.database.type - In this case, the namespace is omitted, and will be replaced by the default namespace of the warehouse.You can create a warehouse as follows:
const warehouse = new Warehouse();
A warehouse can contains multiple namespaces. When a warehouse is created, a default namespace instance will be created at the same time. If not specified, the default namespace is called convention. You can get a namespace by getNamespace().
const defaultNamespace = warehouse.getNamespace('convention');
You can also create a new namespace by createNamespace(), or delete a namespace by deleteNamespace(). Notice that you can never delete the default namespace.
const myNamespace = warehouse.createNamespace('mySpace');
warehouse.deleteNamespace('mySpace');
A more powerful function of warehouse is fetcher. Generate a fetcher by passing an array of namespaces. See fetcher for detailed specification of it.
const fetcher = warehouse.getFetcher(['convention', 'mySpace']);
After you creating a namespace in a warehouse, you get a namespace instance. You can store an item by method store().
const myNamespace = warehouse.createNamespace('mySpace');
myNamespace.store('username', 'typinghare');
You can store multiple items by passing an object.
myNamespace.store({
city: 'Quincy',
state: 'MA',
auto: 'Toyota'
});
Then, you can fetch items by their labels.
myNamespace.fetch('username'); // >> typinghare
myNamespace.fetch('city'); // >> Quincy
Notice that if you store two items with the same label, the latter will cover the former.
myNamespace.store('username', 'typinghare');
myNamespace.store('username', 'jameschan');
myNamespace.fetch('username'); // >> jameschan
First we create a warehouse and a customed namespace, and store some items.
const warehouse = new Warehouse();
const defaultNamespace = warehouse.getDefaultNamespace();
const myNamespace = warehouse.createNamespace('mySpace');
defaultNamespace.store({
city: 'Chicago',
state: 'IL',
auto: 'Toyota'
});
myNamespace.store({
city: 'Quincy',
state: 'MA',
})
Then we create a fetcher, and try to get some items with it. You can see the values of city and state come from mySpace namespace, and the value of auto comes from the default namespace. This is how the fetcher work: it scans label from the last item of the given array backwards. If the label exists in one of the namespace, returns its value directly without continuing searching.
const fetcher = warehouse.getFetcher(['convention', 'mySpace']);
fetcher.fetch('city'); // >> Quincy
fetcher.fetch('state'); // >> MA
fetcher.fetch('auto'); // >> Toyota
FAQs
A warehouse of configurations.
We found that @typinghare/warehouse 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.