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

nlcst-normalize

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nlcst-normalize - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

5

history.md

@@ -5,3 +5,8 @@ <!--remark setext-->

1.1.0 / 2016-01-18
==================
* Add support for `allowApostrophes` ([9f169d5](https://github.com/wooorm/nlcst-normalize/commit/9f169d5))
1.0.0 / 2016-01-14
==================

22

index.js

@@ -23,3 +23,6 @@ /**

var EXPRESSION_REMOVE = /['’-]/g;
var ALL = /[-'’]/g;
var DASH = /-/g;
var APOSTROPHE = /’/g;
var QUOTE = '\'';
var EMPTY = '';

@@ -31,8 +34,17 @@

* @param {string} value - Value to normalize.
* @param {boolean} allowApostrophes - Do not strip
* apostrophes.
* @return {string} - Normalized `value`.
*/
function normalize(value) {
return (typeof value === 'string' ? value : toString(value))
.toLowerCase()
.replace(EXPRESSION_REMOVE, EMPTY);
function normalize(value, allowApostrophes) {
var result = (typeof value === 'string' ? value : toString(value))
.toLowerCase();
if (allowApostrophes) {
return result
.replace(APOSTROPHE, QUOTE)
.replace(DASH, EMPTY);
}
return result.replace(ALL, EMPTY);
}

@@ -39,0 +51,0 @@

{
"name": "nlcst-normalize",
"version": "1.0.0",
"version": "1.1.0",
"description": "Normalize a word for easier comparison",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -24,2 +24,3 @@ # nlcst-normalize [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

normalize('Block-level'); // 'blocklevel'
normalize('Don’t', true); // 'don\'t'

@@ -47,3 +48,3 @@ normalize({

### `normalize(value)`
### `normalize(value[, allowApostrophes])`

@@ -55,4 +56,7 @@ Quote a value.

* `value` ([`Node`][nlcst-node], `Array.<Node>`, or `string`)
— Value to normalize.
— Value to normalize;
* `allowApostrophes` (`boolean`, default: `false`)
— Do not strip apostrophes (but do normalize them).
**Returns**: `string` — Normalized value.

@@ -59,0 +63,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