
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@usig-gcba/autocompleter
Advanced tools
Librería que devuelve una lista de sugerencias dado un texto determinado.
Warning: Version 2.0.0 contains potentially breaking changes for frontend projects. Please refer to the demo to see how to implement the newest version.
This autocompleter is a library which gives a list of suggestions given a certain text. This is done using a list of suggesters, which can be loaded dinamically, in case you don't want to use one of the defaults. A set of callbacks should be set so the autocompleter can call them after certain events.
A simple create-react-app can be found in demo/react-demo with an example showing how the module can be used in a React environment.
Also, an Angular CLI app can be found in demo/angular-demo showing integration in this framework.
npm install @usig-gcba/autocompleter
command in your project root.import {Autocompleter} from '@usig-gcba/autocompleter'
new
command to create a new instance const autocompleter = new Autocompleter(callbacks, options)
. You can save it in a variable for further use.Creates a new instance of the autocompleter.
Parameters:
Object
containing the callbacks for event handling. Here's a list of all the possible callbacks:
Note: If a suggester brings 0 results, the onSuggestions callback won't be called.
Object
containing default options to be overwritten. Available options:Parameter | Description | Default |
---|---|---|
inputPause | Time each suggester waits before looking for suggestions | 200 |
maxSuggestions | Total limit of suggestions | 10 |
serverTiemout | Timeout in case an http call is made | 3000 |
minTextLength | Minimun text length in order to start looking for suggestions | 3 |
maxRetries | Maximum retries in case of failure | 1 |
flushTimeout | Time to wait before flushing results from suggesters. | 0 |
const autocompleter = new Autocompleter(
{
onSuggestions: suggestionsCallback,
onUpdate: updateCallback,
onError: errorCallback,
onMessage: messageCallback
},
{
inputPause: 400,
maxRetries: 2
}
);
By default, the autocompleter initializes empty. This method adds a suggester for the autocompleter to use when updating suggestions.
Parameters:
String
name of the suggester.The name must be a valid suggester name. By default, 4 suggesters are registered in the autocompleter:
Calls the getSuggestions function in all the active suggesters.
Parameters:
String
to be searched.Calls the coordinates of an endpoint of normalized directions for CABA and AMBA suggestions.
Parameters:
String
to be searched.Removes a suggester from the autocompleter. This suggester will still be a valid one, but the autocompleter won't take it into account when updating suggestions.
Parameters:
String
name of the suggester.The suggesters contain the core functionality of the autocompleter. They are in charge of looking for suggestions. Up next is a list of the suggesters available by default.
This suggester looks for directions inside the City of Buenos Aires. So, for the input text we give to the autocompleter, the suggester looks for directions matching that text.
This suggester looks for directions inside AMBA.
This suggester looks for places inside the City of Buenos Aires (airports, museums, parks, entertainment).
This suggester looks for vulnerable areas inside the City of Buenos Aires.
This suggester allows locating a coordinates from its smp, in format: seccion-manzana-parcela, inside the City of Buenos Aires.
It allows locating addresses of vulnerable areas by searching for street and height. Eg "alpaca 1000".
You can see an example of a suggester that can be used as a template here
Custom suggesters can be added via de addSuggester
function. This function can take either a String
or an Object
as parameters.
String
containing the name of the suggester to be added. In this case, the suggester should be already registered in the
autocompleter.Object
containing the suggester to be added. In this case, we are registering a new type of sugester to the autocompleter.Any new suggester added should implement all the Suggester methods. The library exports the Suggester interface, so a custom class can be created extending from this one.
import {Suggester} from '@usig-gcba/autocompleter'
class MySuggester extends Suggester {
getSuggestions(text, callback, maxSuggestions){
callback([...results]);
}
}
If you are trying to implement Autocompleter in an Angular project, you will have to install @babel/polyfill
and import it at your app.component.ts file as can be seen in the angular demo.
FAQs
Librería que devuelve una lista de sugerencias dado un texto determinado.
We found that @usig-gcba/autocompleter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.