Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

clean-search

clean-search is an utility library which has the following 3 methods:

.removeValues()
.lowerCase()
.searchFor()

Setup

var cleanWords = new cleanSearch([*values*]); 

.removeValues([values])

Removes all the following unwanted values:

undefined
NaN
null

By default the values which you use for the setup are automatically cleaned

var cleanWords = new cleanSearch([
	123,
	null,
	{
	a: NaN,
	b: {
		c: [null,undefined,NaN,"abc"]
		}
	}
]);

console.log(cleanWords.values);

// The output: [123,{ a: "", b: { c: ["abc"] }}]
 
// Another example

console.log(cleanWords.cleanValues(["def",123,null]));

// The output: ["def",123]

NOTE: The unwanted values in Object's are replaced with "" (empty quotes)

.lowerCase([values=this.values])

.lowerCase() method replaces all string values with lower case versions of that values. If you use it without a parameter it lowerCases its own values

var cleanWords = new cleanSearch(["ABC","SES", {
	a: "HEY",
	b: {
		c: ["LUL",["DEF", {
			d: "FOO"
		}]]
	}
}]);

// ["abc", "ses", { a:"hey", b:{c:["lul", ["def", {d:"foo" }]]}}]

.searchFor(searchValue, [values=this.values])

Searches for the given value, returns true if the value exists

var cleanWords = new cleanSearch(["ABC","SES", {
	a: "HEY",
	b: {
		c: ["LUL",["DEF", {
			d: "FOO"
		}]]
	}
}]);

console.log(cleanWords.searchFor("foo")); // true

NOTE: .searchFor() function executes .lowerCase() before starting the search

About

removes undefined,null and NaN values

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages