![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
An in-memory node.js autocomplete package based on the trie data structure, based off the autocomplete module
Modernized Trie-search based on Node Autocomplete is an autocomplete library for node.js.
TODO: Cleanup test suite, use chai. Add all them missing semi-colons...
npm install triesearch
var data = ['fruit', 'app', 'apple', 'banana']
// instatiate a new autocomplete object
var Autocomplete = require('autocomplete')
var auto = new Autocomplete()
auto.initialize(data)
// results will be an array with 0 or more elements
var results = auto.search('ap')
// here results will be an array of key-value pairs
console.dir(results)
The output of the search is an array of objects with key and value properties. In the example above, results
looks like
[
{
key: 'app',
value: 'app'
},
{
key: 'apple',
value: 'apple',
}
]
If you are just searching for strings you can get an array of matching strings by mapping the results and returning just the key
var data = ['fruit', 'app', 'apple', 'banana']
// instatiate a new autocomplete object
var Autocomplete = require('autocomplete')
var auto = new Autocomplete()
auto.initialize(data)
// results will be an array with 0 or more elements
var results = auto.search('ap')
// here results will be an array of key-value pairs
console.dir(results)
var stringMatches = results.map(function (result) {
return result.key
})
// stringMatches is ['app', 'apple']
console.dir(stringMatches)
You can add to the list of candidate elements after the autocomplete object has been initialized
var Autocomplete = require('autocomplete')
var auto = new Autocomplete()
var data = []
auto.initialize(data)
auto.addElement('cheeseburger')
You can remove from the list of candidate elements after the autocomplete object has been initialized
var Autocomplete = require('autocomplete')
var auto = new Autocomplete()
var data = ['app', 'apple', 'apples']
auto.initialize(data)
auto.removeElement('apple')
You can also add key value pairs as an array of 2 elements
var Autocomplete = require('autocomplete')
var auto = new Autocomplete()
var data = ['app', 'apple', ['apples', 'yummy'], 'banana' ]
auto.initialize(data)
var results = app.search('ap')
// in the results, there will be an element with the key *apples* and the value *yummy*
console.dir(results)
In the example above, results
looks like
[
{ key: 'app', value: 'app' },
{ key: 'apple', value: 'apple' },
{ key: 'apples', value: 'yummy' }
]
Install development dependencies:
npm install
Then:
npm test
Actively tested with node:
Original source code based on https://github.com/marccampbell/node-autocomplete
(The MIT License)
Copyright (c) 2011 Marc Campbell <marc.e.campbell@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
An in-memory node.js autocomplete package based on the trie data structure, based off the autocomplete module
We found that triesearch 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.