Skip to content

Commit 6b1131a

Browse files
committed
Initial commit
0 parents  commit 6b1131a

File tree

14 files changed

+536
-0
lines changed

14 files changed

+536
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{json,remarkrc,eslintrc,sh}]
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage/
2+
example.js
3+
hast-util-is-element.js
4+
hast-util-is-element.min.js

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"rules": {
4+
"quotes": [2, "single"]
5+
}
6+
}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
*.log
3+
coverage/
4+
node_modules/
5+
hast-util-is-element.js
6+
hast-util-is-element.min.js

.jscs.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"excludeFiles": [
3+
"coverage/",
4+
"node_modules/",
5+
"hast-util-is-element.js",
6+
"hast-util-is-element.min.js"
7+
],
8+
"preset": "crockford",
9+
"requireMultipleVarDecl": false,
10+
"disallowDanglingUnderscores": false,
11+
"requireQuotedKeysInObjects": true,
12+
"disallowKeywords": [
13+
"with"
14+
],
15+
"maximumLineLength": {
16+
"value": 79,
17+
"allExcept": [
18+
"regex",
19+
"urlComments"
20+
]
21+
},
22+
"jsDoc": {
23+
"checkAnnotations": "jsdoc3",
24+
"checkParamExistence": true,
25+
"checkParamNames": true,
26+
"checkRedundantAccess": true,
27+
"checkRedundantParams": true,
28+
"checkRedundantReturns": true,
29+
"checkReturnTypes": true,
30+
"checkTypes": "strictNativeCase",
31+
"enforceExistence": true,
32+
"requireHyphenBeforeDescription": true,
33+
"requireNewlineAfterDescription": true,
34+
"requireParamDescription": true,
35+
"requireParamTypes": true,
36+
"requireReturnDescription": true,
37+
"requireReturnTypes": true
38+
}
39+
}

.remarkrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"output": true,
3+
"plugins": [
4+
"lint",
5+
"github",
6+
"comment-config",
7+
"usage",
8+
"validate-links"
9+
],
10+
"settings": {
11+
"bullet": "*"
12+
}
13+
}

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: node_js
2+
node_js:
3+
- '0.10'
4+
- '0.11'
5+
- '0.12'
6+
- '4.0'
7+
- '5.0'
8+
sudo: false
9+
after_script: npm install codecov.io && cat ./coverage/lcov.info | codecov
10+
deploy:
11+
- provider: npm
12+
email: tituswormer@gmail.com
13+
api_key:
14+
secure: bqEgaHxepascYbC/rR11EUuQFiQsPidc4F0kPE7FItDPRA9r/rl3yaKLPHD8BORDH9jihmYOPcH3ueBi5OFdUfRMJzJQE9GH7qi4IbuAFRh2D5RUGb0Bn1/Nmpzq5UC0Wc9B5IjFwbw8XkNRDvwrpCGF7r4pdvp0WUSJCCzik56rAMNLZUlO7aouqODwQuaKs6py1FCZfaKOKCoxsV4SJ5liGamBgVqUmoWIxNDx02Qf5Jb1E5SGNzvRLtVQiKrR9gHLhg31qTgyTSqZlPQlcvdSvTfFrZbJWKqds5k8fyzk7V82pePq97PH+8mBItCJZjpa+ACRzavTEIr+EkkA8y+Ep43rdGfAFUGmJaD7rC3igY0AUt/7NuqZzUwK5oSKM4qpWokML/SVysmaqTjn94SUdXCEnQQOkyAKsxL1kaxDol8rhZhHLys1g6T/ENJLHo7ci86xl5Y7Ew3Uiv83Qv8da6OWssx6qMiI0gm7e5rViUOmqHIwAwPmfsLd1EHWChzems4Y+Dxp2oAQ8njvObNun90BU4V9FQUPUOUSYZzFyzZb2I/JUOER440AS1v5Y+DYX/rH8ufQIdiAEVetZPp6MmFmCoWF4f71kCrPGgNeFTGrvTaOduWn7jA5+9Sy/53nZaEwsupD5xMqOEAh4NXKQtPVm7awF/Hs1cIVOqs=
15+
on:
16+
tags: true
17+
node: '5.0'
18+
- provider: releases
19+
api_key:
20+
secure: eSsk7MN9PGXfXZxBAT/uD+tMPqqsBDE6mpTVZMfzeGnugZSy2f72JTIRrN5VI0AlWb3pxBt7ezF5QFOs/h+cFYoLPgbgtROac2ToLGS033j9b6XUNjBDn/fRdDLCrcYmVkHZsoW+F0Fk9ErmN8R1IdK+uMOEqM+/3SodH75teCCeao23nuNjuFeLkKT4ZshNMFjfC+gVSkblvcNHOr5OlAdQrpzpSyBxyT5KsfNzbJgPD1l3PzNsfJu1KWlghoysx04iiuWzF81ykhI3MGg2ancygXj2MhJQg3njt+8KoI5ts+Ufp/4GWxH217wGVFMPH/bCD7WKJWeI/e60ZqDJrO1VwPOFF/xisldKKSyRAf8oYL2Es6jntWG1yHb/HxydTP/j/vm8MrzS+dVG1DUUZwB/Ya6ze/qLNEdbOOUHF8meaG/nL09iJXDEf2jjRNcvAMGvXv54Qzqme8Z/PmAEbIlEaFwRtkXS6ysbMXhV7CTkkQ4q8BpjnV+gB5kCh34iCEM5m8zkv/m+dIIl6HmmPpQBlfN6mEk241pfe96ypDAeZSjC/6o62sQJlF79xDH00LpjRCJBsk+ZOEsgCQ8/2ocTSyxtZX5SD04GluPqkjSdDnYnNun8Nh1O3X5eT/TJsu2HWreTA52L6wbc0fflLR+RXzcgts34Mug3L8heCrI=
21+
file:
22+
- "hast-util-is-element.js"
23+
- "hast-util-is-element.min.js"
24+
on:
25+
tags: true

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

example.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Dependencies:
2+
var isElement = require('./index.js');
3+
4+
// Given a non-element:
5+
var result = isElement({
6+
'type': 'text',
7+
'value': 'foo'
8+
});
9+
10+
// Yields:
11+
console.log('js', String(result));
12+
13+
// Given a matching element:
14+
result = isElement({
15+
'type': 'element',
16+
'tagName': 'a'
17+
}, 'a');
18+
19+
// Yields:
20+
console.log('js', String(result));
21+
22+
// Given multiple tagNames:
23+
result = isElement({
24+
'type': 'element',
25+
'tagName': 'a'
26+
}, ['a', 'area']);
27+
28+
// Yields:
29+
console.log('js', String(result));

history.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!--remark setext-->
2+
3+
<!--lint disable no-multiple-toplevel-headings-->
4+
5+
0.0.0 / 2016-04-17
6+
==================

index.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* @author Titus Wormer
3+
* @copyright 2016 Titus Wormer
4+
* @license MIT
5+
* @module rehype:lint:util:is-element
6+
*/
7+
8+
'use strict';
9+
10+
/* eslint-env commonjs */
11+
12+
/**
13+
* Check if a node is a (certain) element.
14+
*
15+
* @param {*} node - Thing to check.
16+
* @param {string|Array.<string>?} [tagNames] - Name of element.
17+
* @return {boolean} - Whether a node is a (certain) element.
18+
* @throws {Error} - When `tagNames` is given but invalid.
19+
*/
20+
function isElement(node, tagNames) {
21+
var name;
22+
23+
if (
24+
!(
25+
tagNames === null ||
26+
tagNames === undefined ||
27+
typeof tagNames === 'string' ||
28+
(typeof tagNames === 'object' && tagNames.length)
29+
)
30+
) {
31+
throw new Error(
32+
'Expected `string` or `Array.<string>` for ' +
33+
'`tagNames`, not `' + tagNames + '`'
34+
);
35+
}
36+
37+
if (
38+
!node ||
39+
typeof node !== 'object' ||
40+
node.type !== 'element' ||
41+
typeof node.tagName !== 'string'
42+
) {
43+
return false;
44+
}
45+
46+
if (tagNames === null || tagNames === undefined) {
47+
return true;
48+
}
49+
50+
name = node.tagName;
51+
52+
if (typeof tagNames === 'string') {
53+
return name === tagNames;
54+
}
55+
56+
return tagNames.indexOf(name) !== -1;
57+
}
58+
59+
/*
60+
* Expose.
61+
*/
62+
63+
module.exports = isElement;

package.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "hast-util-is-element",
3+
"version": "0.0.0",
4+
"description": "Check if a node is a (certain) element",
5+
"license": "MIT",
6+
"keywords": [
7+
"hast",
8+
"html",
9+
"is",
10+
"element",
11+
"util",
12+
"utility"
13+
],
14+
"dependencies": {},
15+
"files": [
16+
"index.js"
17+
],
18+
"repository": {
19+
"type": "git",
20+
"url": "https://github.com/wooorm/hast-util-is-element.git"
21+
},
22+
"bugs": "https://github.com/wooorm/hast-util-is-element/issues",
23+
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
24+
"contributors": [
25+
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
26+
],
27+
"devDependencies": {
28+
"browserify": "^13.0.0",
29+
"eslint": "^2.0.0",
30+
"esmangle": "^1.0.1",
31+
"istanbul": "^0.4.0",
32+
"jscs": "^3.0.0",
33+
"jscs-jsdoc": "^2.0.0",
34+
"remark": "^4.0.0",
35+
"remark-comment-config": "^3.0.0",
36+
"remark-github": "^4.0.1",
37+
"remark-lint": "^3.0.0",
38+
"remark-usage": "^3.0.0",
39+
"remark-validate-links": "^3.0.0",
40+
"tape": "^4.4.0"
41+
},
42+
"scripts": {
43+
"build-md": "remark . --quiet --frail",
44+
"build-bundle": "browserify index.js --bare -s hastUtilIsElement > hast-util-is-element.js",
45+
"build-mangle": "esmangle hast-util-is-element.js > hast-util-is-element.min.js",
46+
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
47+
"lint-api": "eslint .",
48+
"lint-style": "jscs --reporter inline .",
49+
"lint": "npm run lint-api && npm run lint-style",
50+
"test-api": "node test.js",
51+
"test-coverage": "istanbul cover test.js",
52+
"test": "npm run build && npm run lint && npm run test-coverage"
53+
}
54+
}

0 commit comments

Comments
 (0)