Socket
Socket
Sign inDemoInstall

doublearray

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

doublearray

JavaScript implementation of Double-Array trie


Version published
Maintainers
1
Weekly downloads
38,462
decreased by-5.51%

Weekly downloads

Readme

Source

Double-Array

JavaScript implementation of Double-Array trie.

Usage

Build

Node.js example

var doublearray = require('./doublearray.js');

var words = [
    { k: 'a', v: 1 },
    { k: 'abc', v: 2 },
    { k: '奈良', v: 3 },
    { k: '奈良先端', v: 4 },
    { k: '奈良先端科学技術大学院大学', v: 5 }
];

var trie = doublearray.builder().build(words);

Browser example

var words = [
    { k: 'a', v: 1 },
    { k: 'abc', v: 2 },
    { k: '奈良', v: 3 },
    { k: '奈良先端', v: 4 },
    { k: '奈良先端科学技術大学院大学', v: 5 }
];

var trie = doublearray.builder().build(words);

Method chaining

var trie = doublearray
       .builder()
       .append('a', 1)
       .append('abc', 2)
       .append('奈良', 3)
       .append('奈良先端', 4)
       .append('奈良先端科学技術大学院大学', 5)
       .build();
trie.contain('a');  // -> true

trie.lookup('abc');  // -> 2

trie.commonPrefixSearch('奈良先端科学技術大学院大学');
// -> [ { v: 3, k: '奈良' },
//      { v: 4, k: '奈良先端' },
//      { v: 5, k: '奈良先端科学技術大学院大学' } ]

Load

Get BASE or CHECK buffer as Int32Array of typed array

var base_buffer = trie.bc.getBaseBuffer();
var check_buffer = trie.bc.getCheckBuffer();

Load and create a new DoubleArray object from original buffers

var loaded_trie = doublearray.load(base_buffer, check_buffer);

Copyright (c) 2014 Takuya Asano All Rights Reserved.

This software is released under the MIT License. See LICENSE.txt

Keywords

FAQs

Last updated on 24 Sep 2014

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc