Socket
Socket
Sign inDemoInstall

efrt

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

efrt - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

package.json

@@ -5,3 +5,3 @@ {

"description": "compressed-trie data-structure",
"version": "0.0.1",
"version": "0.0.2",
"main": "./builds/efrt.js",

@@ -8,0 +8,0 @@ "repository": {

@@ -1,16 +0,32 @@

# efrt
a prefix/suffix [trie](https://en.wikipedia.org/wiki/Trie)-based data-structure optimised for compression of english words
<div align="center">
<img src="https://cloud.githubusercontent.com/assets/399657/23590290/ede73772-01aa-11e7-8915-181ef21027bc.png" />
<div>trie-based compression of word-data</div>
<a href="https://npmjs.org/package/efrt">
<img src="https://img.shields.io/npm/v/efrt.svg?style=flat-square" />
</a>
<a href="https://nodejs.org/api/documentation.html#documentation_stability_index">
<img src="https://img.shields.io/badge/stability-stable-green.svg?style=flat-square" />
</a>
</div>
based on [mckoss/lookups](https://github.com/mckoss/lookups) by [Mike Koss](https://github.com/mckoss)
<div align="center">
<code>npm i efrt</code>
</div>
`efrt` is a prefix/suffix [trie](https://en.wikipedia.org/wiki/Trie) optimised for compression of english words.
it is based on [mckoss/lookups](https://github.com/mckoss/lookups) by [Mike Koss](https://github.com/mckoss)
and [bits.js](http://stevehanov.ca/blog/index.php?id=120) by [Steve Hanov](https://twitter.com/smhanov)
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.
* squeeze a list of words into a very compact form
* reduce filesize/bandwidth a bunch
* ensure unpacking overhead is negligible
* word-lookups are critical-path
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.
By doing the fancy stuff ahead-of-time, **efrt** lets you ship much bigger word-lists to the client-side, without much hassle.
```js
var efrt = require('efrt')//
var efrt = require('efrt')
var words = [
'coolage', //must boring, lowercase, non-unicode
'coolage',
'cool',

@@ -21,2 +37,3 @@ 'cool cat',

];
//pack these words as tightly as possible

@@ -26,3 +43,3 @@ var compressed = efrt.pack(words);

//pull it apart into a lookup-trie
//create a lookup-trie
var trie = efrt.unpack(compressed);

@@ -35,15 +52,26 @@

## [Demo](https://rawgit.com/nlp-compromise/efrt/master/demo/index.html)
<h3 align="center">
<a href="https://rawgit.com/nlp-compromise/efrt/master/demo/index.html">Demo!</a>
</h3>
if you're doing the second step in the client, you can load only the unpack-half of the library(~3k):
the words you input should be pretty normalized. Spaces and unicode are good, but numbers, case-sensitivity, and some punctuation are not (yet) supported.
**IE9+**
```html
<script src="./builds/efrt-unpack.min.js"></script>
<script src="https://unpkg.com/efrt@latest/builds/efrt.min.js"></script>
<script>
$.get('./compressedStuff.txt', (str)=>{
var trie=unpack(str);
trie.has('miles davis');
})
var smaller=efrt.pack(['larry','curly','moe'])
var trie=efrt.unpack(smaller)
console.log(trie.has('moe'))
</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.
if you're doing the second step in the client, you can load just the unpack-half of the library(~3k):
```html
<script src="https://unpkg.com/efrt@latest/builds/efrt-unpack.min.js"></script>
<script>
var trie=unpack(compressedStuff);
trie.has('miles davis');
</script>
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc