🚀 Socket Launch Week 🚀 Day 2: Introducing Repository Labels and Security Policies.Learn More
Socket
Sign inDemoInstall
Socket

d3-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-autocomplete

Small autocomplete written using D3

5.0.1
latest
Source
npm
Version published
Weekly downloads
3
200%
Maintainers
1
Weekly downloads
 
Created
Source

d3-autocomplete

Small autocomplete written using D3

PRs welcome!

Install

npm install d3-autocomplete

Usage

var createAutocomplete = require('d3-autocomplete')

var autocomplete = createAutocomplete({placeholder: 'Søg'}, function (query, cb) {
  cb(null, [
    {label: 'Foo', some: 'key'},
    {label: 'Bar', some: 'key'}
  ])
})

autocomplete.on('change', function (data) {
  console.log(data)
})

autocomplete.on('error', function (err) {
  console.error(err)
})

document.body.appendChild(autocomplete.element)

API

createAutocomplete(attrs, queryCallback)

Returns:

{
  element, // The element to add to the DOM
  on(event, listener), // Listen for either `change` or `error` events

  add(suggestion), // Add a suggestion
  delete(suggestion), // Remove a suggestion
  clear(), // Remove all suggestions

  open(), // Open suggestions
  close(), // Close suggestions
  toggle(), // Toggle suggestions

  query([value]) // Set/get query of autocomplete
}

attrs

Type: Object

Various attributes to change on the elements created. See the source

queryCallback(query, callback)

Type: Function

Called when requesting completions for query. Pass back results through callback(err, result)

License

ISC

Keywords

d3

FAQs

Package last updated on 08 Sep 2016

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