You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

density-trie

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

density-trie

Trie tree implementation with keywords density calcuation functionality

1.1.1
latest
Source
npm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

Density Trie

A trie tree implementation, provide add/remove/lookup and density calcuation over specified text. Eastern/Western languages are supported

Requirement

Node v4.0+

Installation

npm install density-trie --save

Usage

var Trie = require('density-trie');
var should = require('should');

describe('Demo', function() {
  var western = true;
  var trie = new Trie(western);

  trie.add('He');
  trie.add('Hell');
  trie.add('Hello');

  console.log(trie.dump());

  var text = 'here is a fragment of text with "Hello World", "Hello" should be 2, "Hell" should be 1, no matter if "eHell" or eHello presented';

  trie.density(text).should.be.deepEqual({
    Hello: 2, 
    World: 1,
    Hell: 1
  });

  should(trie.remove('Hello').lookup('Hello')).not.be.ok();

  trie.check('check method will return immediately when any keyword is found, like Hello').should.be.ok();
  trie.replace('replace KEYWORD with *******').be.exactly('replace ******* with *******');
});

Keywords

trie

FAQs

Package last updated on 08 Mar 2018

Did you know?

Socket

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.

Install

Related posts