Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
A library for quick insert and retrieval of JavaScript objects, keyed by prefix strings.
triever
is a compact, dependency-free library that allows for quick insertion and retrieval of values, keyed by prefix strings.
const Trie = require("triever");
const testData = [
{
id: 0,
name: "dog"
},
{
id: 1,
name: "doge"
},
{
id: 2,
name: "duck"
},
{
id: 3,
name: "book"
},
{
id: 4,
name: "shelf"
},
{
id: 5,
name: "bookshelf"
},
{
id: 6,
name: "water"
},
{
id: 7,
name: "delightful"
}
];
const testTrie = new Trie();
testData.forEach(x => testTrie.add(x.name, x));
const bookEntries = testTrie.getData("book");
console.log(bookEntries); // prints #3, #5
const trie = new Trie()
Creates a new Trie with no data.
trie.add(key, value)
Adds the value
to the listing stored at location key
. key
must be a string.
trie.getNode(key)
Gets the node at location key
in the tree. key
must be a string. Returns null
if no nodes exist at that location. Useful for storing / caching partial parts of the tree in your application (ie, for livesearching).
trie.getData(key)
Gets an array of entries that have keys starting with the key
prefix. Returns null
if the key does not exist.
npm install triever
And in your file:
const Trie = require("triever");
const trie = new Trie();
trie.add("key", { value: 1 });
Adding a script reference to the file /dist/triever.min.js
to your page will expose a global variable of Trie
:
const trie = new Trie();
trie.add("key", { value: 1 });
Naturally, triever is named after the trie
data structure (also known as a radix tree, prefix tree, digital tree); however, equally important, it is named in honor of one of the best dog breeds in the world: the Labrador Retriever.
FAQs
A library for quick insert and retrieval of JavaScript objects, keyed by prefix strings.
The npm package triever receives a total of 0 weekly downloads. As such, triever popularity was classified as not popular.
We found that triever 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.