1.0.2 • Published 9 years ago

sfilter v1.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

SFilterJS

SFilter is lightweight (1.5KB) javascript library for searching through array with fault tolerant.

Example

<script src="/dist/sfilter.js"></script>
<script>
		SFilter.setResources(["Javascript", "Hack-lang", "Go-lang", "Coffeescript", "PHP", "Ruby", "Swift", "Python", "Perl", "Java", "Scala", "Clojure", "Erlang", "Elixir", "C", "C++", "C#"]);
		SFilter.find("jvscript");
		// Return should be ["Javascript", "Coffeescript", "Swift", "C", "Java"]
		// Sorted by most similar words
		
</script>

Installation

using NPM

npm install sfilter --save

On NodeJS you have to initialize the SFilter object before you can use it.

var sfilter = new SFilter();
sfilter.setResource(["a","b"]);

using Browser

git clone git@github.com:alileza/sfilter.git
cd sfilter
open example.html

Docs

Set Resources

Array list is called as Resources, for the array of object will be supported soon.

// all resources must be string, and not an object
SFilter.setResources(["Javascript", "Hack-lang", "Go-lang"]);

Set Limit

Limit the response of SFilter find

// Set response limit
SFilter.setLimit(2);

Find

Find similar string on the resources

// Get the response
SFilter.find("Jvscrpth");

Test

coming soon

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago