link-types
Advanced tools
Comparing version 1.1.0 to 2.0.0
31
index.js
@@ -5,12 +5,5 @@ "use strict"; | ||
function isNotEmpty(value) | ||
{ | ||
return value !== ""; | ||
} | ||
function linkTypes(attrValue) | ||
{ | ||
return split(attrValue).filter(isNotEmpty); | ||
return split(attrValue).filter(type => type !== ""); | ||
} | ||
@@ -22,20 +15,12 @@ | ||
{ | ||
var i,numValues,value,result; | ||
attrValue = split(attrValue); | ||
numValues = attrValue.length; | ||
result = {}; | ||
for (i=0; i<numValues; i++) | ||
return split(attrValue).reduce( function(result, type) | ||
{ | ||
value = attrValue[i]; | ||
if (value !== "") | ||
if (type !== "") | ||
{ | ||
result[value] = true; | ||
result[type] = true; | ||
} | ||
} | ||
return result; | ||
return result; | ||
}, {}); | ||
} | ||
@@ -42,0 +27,0 @@ |
{ | ||
"name": "link-types", | ||
"description": "Parse an HTML attribute value containing link types.", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
"homepage": "https://github.com/stevenvachon/link-types", | ||
"author": { | ||
"name": "Steven Vachon", | ||
"email": "contact@svachon.com", | ||
"url": "http://www.svachon.com/" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/stevenvachon/link-types.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/stevenvachon/link-types/issues" | ||
}, | ||
"author": "Steven Vachon <contact@svachon.com> (https://www.svachon.com/)", | ||
"repository": "stevenvachon/link-types", | ||
"devDependencies": { | ||
"chai": "^3.4.1", | ||
"mocha": "^2.3.4" | ||
"chai": "^3.5.0", | ||
"mocha": "^3.3.0" | ||
}, | ||
"engines": { | ||
"node": ">= 0.10" | ||
"node": ">= 6" | ||
}, | ||
"scripts": { | ||
"test": "mocha test.js --reporter spec --check-leaks --bail" | ||
"test": "mocha test.js --reporter=spec --check-leaks --bail" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"license" | ||
], | ||
"files": ["index.js"], | ||
"keywords": [ | ||
@@ -34,0 +20,0 @@ "html", |
@@ -11,3 +11,3 @@ # link-types [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] | ||
[Node.js](http://nodejs.org/) `>= 0.10` is required. To install, type this at the command line: | ||
[Node.js](http://nodejs.org/) `>= 6` is required. To install, type this at the command line: | ||
```shell | ||
@@ -20,12 +20,12 @@ npm install link-types | ||
```js | ||
var linkTypes = require("link-types"); | ||
const linkTypes = require('link-types'); | ||
linkTypes("nofollow"); | ||
//=> ["nofollow"] | ||
linkTypes('nofollow'); | ||
//-> ['nofollow'] | ||
linkTypes(" tag NOFOLLOW "); | ||
//=> ["tag", "nofollow"] | ||
linkTypes(' tag NOFOLLOW '); | ||
//-> ['tag', 'nofollow'] | ||
linkTypes.map(" tag NOFOLLOW "); | ||
//=> { tag:true, nofollow:true } | ||
linkTypes.map(' tag NOFOLLOW '); | ||
//-> { tag:true, nofollow:true } | ||
``` | ||
@@ -32,0 +32,0 @@ |
2967
22