Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
a prefix/suffix trie-based data-structure optimised for compression of english words
based on mckoss/lookups by Mike Koss and bits.js by Steve Hanov it can compress a wordlist/dictionary into a very compact form, so that filesize/http/bandwidth is low.
clients though can query from the compressed form ultra-quick, with performance that's comparable to a straight-up javascript obj.
By doing the fancy stuff ahead-of-time, efrt
lets you ship much bigger word-lists to the client-side, while ensuring there's no big unpacking step - so that users are always on the critical path.
var efrt = require('efrt')//
var words = [
'coolage', //must boring, lowercase, non-unicode
'cool',
'cool cat',
'cool.com',
'coolamungo'
];
//pack these words as tightly as possible
var compressed = efrt.pack(words);
//cool0;! cat,.com,a0;ge,mungo
//pull it apart into a lookup-trie
var trie = efrt.unpack(compressed);
//hit it!
console.log(trie.has('cool'));//true
console.log(trie.has('miles davis'));//false
if you're doing the second step in the client, you can load only the unpack-half of the library(~3k):
<script src="./builds/efrt-unpack.min.js"></script>
<script>
$.get('./compressedStuff.txt', (str)=>{
var trie=unpack(str);
trie.has('miles davis');
})
</script>
the words you input should be pretty normalized. Spaces and unicode are good, but numbers, case-sensitivity, and some punctuation are not (yet) supported.
FAQs
neato compression of key-value data
The npm package efrt receives a total of 44,806 weekly downloads. As such, efrt popularity was classified as popular.
We found that efrt 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new license scanner with an improved suite of features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.