triejs

WebJar for triejs

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

triejs
Последняя версия

Последняя версия

0.1.5
Дата

Дата

Тип

Тип

jar
Описание

Описание

triejs
WebJar for triejs
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/pthurlow/triejs

Скачать triejs

Имя Файла Размер
triejs-0.1.5.pom
triejs-0.1.5.jar 315 KB
triejs-0.1.5-sources.jar 22 bytes
triejs-0.1.5-javadoc.jar 22 bytes
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/triejs/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>triejs</artifactId>
    <version>0.1.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/triejs/
implementation 'org.webjars.npm:triejs:0.1.5'
// https://jarcasting.com/artifacts/org.webjars.npm/triejs/
implementation ("org.webjars.npm:triejs:0.1.5")
'org.webjars.npm:triejs:jar:0.1.5'
<dependency org="org.webjars.npm" name="triejs" rev="0.1.5">
  <artifact name="triejs" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='triejs', version='0.1.5')
)
libraryDependencies += "org.webjars.npm" % "triejs" % "0.1.5"
[org.webjars.npm/triejs "0.1.5"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.webjars.npm » foounit jar [0,)

Модули Проекта

Данный проект не имеет модулей.

#Triejs Build Status A Javascript implementation of a trie data structure with an extensible data model to easily customize to any need. Visit the Triejs page for more info and technical details.

##Usage

You can choose to drop Triejs into your project several ways. You can download the raw source and add it via a script tag in your html. Or if you plan on using it in a node project you can install it via npm install triejs

###Basic Creating a trie is as easy as creating a new object:

> var Triejs = require('triejs');
> var trie = new Triejs();

To add a word with some data associated it call add:

> trie.add(<word>, <data>);

Now given any prefix of letters, you can return results possible words using find:

> trie.find(<word>);
  => <data>

###Advanced

To customize the data just pass optional data, including functions to support data manipulation. These include sort to sort data being entered, insert to customize how data is input, copy for moving data between nodes in the trie, and clip for removing data from the cache layer if it grows too big.

####Example

Options are passed via the constructor as a hash like so:

var trie = new Triejs({
  // sort the data in the context 'this'
  sort: function() {
    this.sort(function(a, b) {
      return b.rank - a.rank;
    });
  }
  // insert data into the target
  , insert: function(target, data) {
    // override for non array implementation
  }
  // clip the data in the context 'this' to length max
  , clip: function(max) {
    this.splice(0, this.length - max);
  }
  // return a copy of data
  , copy: function(data) {
    // override and return new data for non array implementation
  }
  // merge data into target and return target
  , merge: function(target, data) {
    // override and return target with data merged in
  }
});

##Testing

The test suite is built using Bob Remeika's foounit and can be tested in both the browser and in node. To test in node simple run the following command node tests/vendor/suite.js in the root directory or if Triejs was installed using npm then run npm test

To test in a browser you will need to npm install and then run foounit serve in the root directory. Then you can direct your browser to localhost:5057/tests/vendor/runner.html to see the test suite run

##License

Triejs is licensed under the MIT License copyright (c) 2012 Paul Thurlow

Версии библиотеки

Версия
0.1.5