Gathering detailed insights and metrics for @humanwhocodes/object-store
Gathering detailed insights and metrics for @humanwhocodes/object-store
npm install @humanwhocodes/object-store
Typescript
Module System
Min. Node Version
Node Version
NPM Version
74.9
Supply Chain
98.6
Quality
77.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
2,013
Last Day
31
Last Week
50
Last Month
225
Last Year
2,013
Apache-2.0 License
8 Stars
13 Commits
1 Watchers
12 Branches
1 Contributors
Updated on Jul 09, 2024
Minified
Minified + Gzipped
Latest Version
0.2.0
Package Id
@humanwhocodes/object-store@0.2.0
Unpacked Size
82.48 kB
Size
10.60 kB
File Count
8
NPM Version
10.7.0
Node Version
18.20.3
Published on
Jun 20, 2024
Cumulative downloads
Total Downloads
Last Day
0%
31
Compared to previous day
Last Week
6.4%
50
Compared to previous week
Last Month
65.4%
225
Compared to previous month
Last Year
0%
2,013
Compared to previous year
If you find this useful, please consider supporting my work with a donation or nominate me for a GitHub Star.
An implementation of an in-memory object store modeled on cloud drives like Google Drive. This is useful mostly for testing purposes.
Install using [npm][npm] or [yarn][yarn]:
npm install @humanwhocodes/object-store
# or
yarn add @humanwhocodes/object-store
Import into your Node.js project:
1// CommonJS 2const { ObjectStore } = require("@humanwhocodes/object-store"); 3 4// ESM 5import { ObjectStore } from "@humanwhocodes/object-store";
Install using JSR:
1deno add @humanwhocodes/object-store 2 3#or 4 5jsr add @humanwhocodes/object-store
Then import into your Deno project:
1import { ObjectStore } from "@humanwhocodes/object-store";
Install using this command:
bun add @humanwhocodes/object-store
Import into your Bun project:
1import { ObjectStore } from "@humanwhocodes/object-store";
It's recommended to import the minified version to save bandwidth:
1import { ObjectStore } from "https://cdn.skypack.dev/@humanwhocodes/object-store?min";
However, you can also import the unminified version for debugging purposes:
1import { ObjectStore } from "https://cdn.skypack.dev/@humanwhocodes/object-store";
1const store = new ObjectStore(); 2const file = store.createFile("foo.txt", { content: "Foo", parentId: "folder_id" }); 3 4console.log(file); 5/* 6{ 7 id: "file_id", 8 name: "foo.txt", 9 type: "file", 10 parent_id: "parent_id", 11 created_at: "2022-10-20T12:00:00Z", 12 modified_at: "2022-10-20T12:00:00Z", 13} 14*/
Note: When parentId
is omitted, the root folder is used.
1const store = new ObjectStore(); 2const file = store.createFile("foo.txt", { content: "Foo", parentId: "folder_id" }); 3const copiedFile = store.copyFile(file.id, { parentId: "some_other_folder_id", name: "bar.txt"}); 4console.log(copiedFile); 5/* 6{ 7 id: "copy-file-id", 8 name: "bar.txt", 9 type: "file", 10 parent_id: "some_other_folder_id", 11 created_at: "2022-10-20T12:00:00Z", 12 modified_at: "2022-10-20T12:00:00Z" 13} 14*/
Note: name
is optional. When parentId
is not specified, the ID of the original's parent is used.
1const store = new ObjectStore(); 2const file = store.createFile("foo.txt", { content: "Foo", parentId: "folder_id" }); 3const updatedFile = store.updateFile(file.id, { parentId: "some_other_folder_id", name: "bar.txt"}); 4console.log(updatedFile); 5/* 6{ 7 id: "file-id", 8 name: "bar.txt", 9 type: "file", 10 parent_id: "some_other_folder_id", 11 created_at: "2022-10-20T12:00:00Z", 12 modified_at: "2022-10-20T12:00:00Z" 13} 14*/
Note: Both name
and parentId
are optional.
1const store = new ObjectStore(); 2const file = store.createFile("foo.txt", { content: "Foo" }); 3const retrievedFile = store.getFile(file.id); 4console.log(retrievedFile); 5/* 6{ 7 id: "file_id", 8 name: "foo.txt", 9 type: "file", 10 parent_id: "parent_id", 11 created_at: "2022-10-20T12:00:00Z", 12 modified_at: "2022-10-20T12:00:00Z", 13} 14*/
1const store = new ObjectStore(); 2const file = store.createFile("foo.txt", { content: "Foo" }); 3const content = store.getFileContent(file.id); 4console.log(content); // "Foo"
1const store = new ObjectStore(); 2const file = store.createFile("foo.txt", { content: "Foo" }); 3 4store.deleteFile(file.id);
1const store = new ObjectStore(); 2const folder = store.createFolder("my-folder", { parentId: "parent_folder_id" }); 3console.log(folder); 4/* 5{ 6 id: "folder_id", 7 name: "my-folder", 8 type: "folder", 9 parent_id: "parent_id", 10 created_at: "2022-10-20T12:00:00Z", 11 modified_at: "2022-10-20T12:00:00Z", 12 entries: [] 13} 14*/
Note: When parentId
is omitted, the root folder is used.
1const store = new ObjectStore(); 2const folder = store.createFolder("my-folder", { parentId: "parent_folder_id" }); 3const copiedFolder = store.copyFolder(folder.id, { parentId: "some_other_folder_id", name: "my-folder-copy"}); 4console.log(copiedFolder); 5/* 6{ 7 id: "folder_copy_id", 8 name: "my-folder-copy", 9 type: "folder", 10 parent_id: "some_other_folder_id", 11 created_at: "2022-10-20T12:00:00Z", 12 modified_at: "2022-10-20T12:00:00Z", 13 entries: [] 14} 15*/
Note: name
is optional. When parentId
is not specified, the ID of the original's parent is used.
1const store = new ObjectStore(); 2const folder = store.createFolder("my-folder", { parentId: "parent_folder_id" }); 3const updatedFolder = store.updateFolder(file.id, { parentId: "some_other_folder_id", name: "my-new-name"}); 4console.log(updatedFolder); 5/* 6{ 7 id: "folder_id", 8 name: "my-new-name", 9 type: "folder", 10 parent_id: "some_other_folder_id", 11 created_at: "2022-10-20T12:00:00Z", 12 modified_at: "2022-10-20T12:00:00Z", 13 entries: [] 14} 15*/
1const store = new ObjectStore(); 2const folder = store.createFolder("my-folder"); 3 4store.deleteFolder(folder.id);
npm install
to setup dependenciesnpm test
to run testsApache 2.0
No vulnerabilities found.
No security vulnerabilities found.