Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

normalize-for-search

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalize-for-search - npm Package Compare versions

Comparing version 0.1.3 to 1.0.0

bower.json

4

package.json
{
"name": "normalize-for-search",
"version": "0.1.3",
"version": "1.0.0",
"description": "Un-accents and un-umlauts charecters in a string. Also preliminary converts the string to lower case. We use it for autocomplete: both for the matched strings -- on the server side, when indexing; and for the strings the user types into a text input in the browser.",
"main": "src/normalize.js",
"scripts": {
"pretest": "jshint ./src ./tests ./package.json component.json",
"pretest": "jshint ./src ./tests ./package.json bower.json",
"test": "mocha ./tests/*.test.js"

@@ -9,0 +9,0 @@ },

@@ -18,3 +18,3 @@ # About

var normalizeForSearch = require("normalize-for-search");
var normalizeForSearch = require('normalize-for-search');

@@ -24,8 +24,8 @@ ## In CouchDB

Just drop the `src/normalize.js` contents into your CouchDB design document -- for example, into
`{views: {lib: {normalize: "JSON-ENCODED src/normalize.js CODE HERE"}}}`, and then `require` it
`{views: {lib: {normalize: 'JSON-ENCODED src/normalize.js CODE HERE'}}}`, and then `require` it
elsewhere:
var normalizeForSearch = require("views/lib/normalize");
var normalizeForSearch = require('views/lib/normalize');
## In the browser
## In the browser, with AngularJS

@@ -39,9 +39,15 @@ $ bower install --save normalize-for-search

<script>
var normalizeForSearch = window['normalize-for-search'];
var injector = angular.injector(['normalizeForSearch']);
injector.invoke(function (normalizeForSearchFilter) { ... });
</script>
<p>{{ text | normalizeForSearch }}</p>
Thus, the Angular module `normalizeForSearch` declares a filter function available both in the
HTML partials, and in the controllers' code.
# API
normalizeForSearch("Dät ist naïve und ÜBERCOOL, ё-маё!");
// Results in "dat ist naive und ubercool, е-мае!"
normalizeForSearch('Dät ist naïve und ÜBERCOOL, ё-маё!');
// Results in 'dat ist naive und ubercool, е-мае!'

@@ -48,0 +54,0 @@ # License: MIT

(function (window, undefined) {
"use strict";
'use strict';

@@ -7,45 +7,45 @@ var normalizeForSearch = function (s) {

switch (c) {
case "ä":
return "ae";
case 'ä':
return 'ae';
case "á":
case "à":
case "ã":
return "a";
case 'á':
case 'à':
case 'ã':
return 'a';
case "ç":
case "č":
return "c";
case 'ç':
case 'č':
return 'c';
case "é":
case "ê":
return "e";
case 'é':
case 'ê':
return 'e';
case "ï":
case "í":
return "i";
case 'ï':
case 'í':
return 'i';
case "ö":
return "oe";
case 'ö':
return 'oe';
case "ó":
case "õ":
case "ô":
return "o";
case 'ó':
case 'õ':
case 'ô':
return 'o';
case "ś":
case "š":
return "s";
case 'ś':
case 'š':
return 's';
case "ü":
return "ue";
case 'ü':
return 'ue';
case "ú":
return "u";
case 'ú':
return 'u';
case "ß":
return "ss";
case 'ß':
return 'ss';
case "ё":
return "е";
case 'ё':
return 'е';

@@ -55,16 +55,13 @@ default:

}
}).join("");
}).join('');
};
if (typeof exports !== "undefined") {
if (typeof module !== "undefined" && module.exports) {
module.exports = normalizeForSearch;
}
else {
exports["normalize-for-search"] = normalizeForSearch;
}
if (typeof module !== 'undefined' && module.exports) {
module.exports = normalizeForSearch;
}
else {
window["normalize-for-search"] = normalizeForSearch;
else if (typeof angular !== 'undefined' && angular.module) {
angular.module('normalizeForSearch', []).filter('normalizeForSearch', function () {
return normalizeForSearch;
});
}
}(this));
(function (undefined) {
"use strict";
'use strict';
var assert = require("assert"),
normalizeForSearch = require("../src/normalize");
var assert = require('assert'),
normalizeForSearch = require('../src/normalize');
describe("normalizeForSearch", function () {
it("converts the passed string to lower case", function () {
assert.strictEqual(normalizeForSearch("Ack"), "ack");
describe('normalizeForSearch', function () {
it('converts the passed string to lower case', function () {
assert.strictEqual(normalizeForSearch('Ack'), 'ack');
});
it("normalizes ä", function () {
assert.strictEqual(normalizeForSearch("ä"), "ae");
it('normalizes ä', function () {
assert.strictEqual(normalizeForSearch('ä'), 'ae');
});
it("normalizes ö", function () {
assert.strictEqual(normalizeForSearch("ö"), "oe");
it('normalizes ö', function () {
assert.strictEqual(normalizeForSearch('ö'), 'oe');
});
it("normalizes ô", function () {
assert.strictEqual(normalizeForSearch("ô"), "o");
it('normalizes ô', function () {
assert.strictEqual(normalizeForSearch('ô'), 'o');
});
it("normalizes ü", function () {
assert.strictEqual(normalizeForSearch("ü"), "ue");
it('normalizes ü', function () {
assert.strictEqual(normalizeForSearch('ü'), 'ue');
});
it("normalizes ß", function () {
assert.strictEqual(normalizeForSearch("Straße"), "strasse");
it('normalizes ß', function () {
assert.strictEqual(normalizeForSearch('Straße'), 'strasse');
});
it("normalizes ё", function () {
assert.strictEqual(normalizeForSearch("ё"), "е");
it('normalizes ё', function () {
assert.strictEqual(normalizeForSearch('ё'), 'е');
});
it("satisfies the end-to-end test from the README", function () {
it('satisfies the end-to-end test from the README', function () {
assert.strictEqual(
normalizeForSearch("Dät ist naïve und ÜBERCOOL, ё-маё!"),
"daet ist naive und uebercool, е-мае!"
normalizeForSearch('Dät ist naïve und ÜBERCOOL, ё-маё!'),
'daet ist naive und uebercool, е-мае!'
);

@@ -41,0 +41,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc