Skip to content

Commit 0b8ef95

Browse files
committed
Remove superfluous comments
1 parent e5c6cd9 commit 0b8ef95

File tree

2 files changed

+35
-87
lines changed

2 files changed

+35
-87
lines changed

index.js

Lines changed: 35 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,12 @@
1-
/**
2-
* @author Titus Wormer
3-
* @copyright 2015 Titus Wormer
4-
* @license MIT
5-
* @module unist:util:is
6-
* @fileoverview Utility to check if a node passes a test.
7-
*/
8-
91
'use strict';
102

11-
/* eslint-env commonjs */
123
/* eslint-disable max-params */
134

145
/* Expose. */
156
module.exports = is;
167

17-
/**
18-
* Test.
19-
*
20-
* @typedef {Function} is~test
21-
* @param {Node} node - Node to test.
22-
* @param {number} index - Position of `node` in `parent`.
23-
* @param {Node} parent - Parent of `node`.
24-
* @return {boolean?} - Whether this iteration passes.
25-
*/
26-
27-
/**
28-
* Utility to return true.
29-
*
30-
* @type {is~test}
31-
*/
32-
function first() {
33-
return true;
34-
}
35-
36-
/**
37-
* Utility to convert a string into a function which checks
38-
* a given node’s type for said string.
39-
*
40-
* @param {string} test - Node type to test.
41-
* @return {is~test} - Tester.
42-
*/
43-
function typeFactory(test) {
44-
return function (node) {
45-
return Boolean(node && node.type === test);
46-
};
47-
}
48-
49-
/**
50-
* Utility assert each property in `test` is represented
51-
* in `node`, and each values are strictly equal.
52-
*
53-
* @param {Object} test - Spec.
54-
* @return {is~test} - Tester.
55-
*/
56-
function matchesFactory(test) {
57-
return function (node) {
58-
var key;
59-
60-
for (key in test) {
61-
if (node[key] !== test[key]) {
62-
return false;
63-
}
64-
}
65-
66-
return true;
67-
};
68-
}
69-
70-
/**
71-
* Assert if `test` passes for `node`.
72-
* When a `parent` node is known the `index` of node
73-
*
74-
* @param {(string|Node|is~test)?} test - Tester.
75-
* @param {Node} node - Node to test.
76-
* @param {number?} [index] - Position of `node` in `parent`.
77-
* @param {Node?} [parent] - Parent of `node`.
78-
* @param {*} [context] - Context to invoke `test` with.
79-
* @return {boolean} - Whether `test` passes.
80-
*/
8+
/* Assert if `test` passes for `node`.
9+
* When a `parent` node is known the `index` of node */
8110
function is(test, node, index, parent, context) {
8211
var hasParent = parent !== null && parent !== undefined;
8312
var hasIndex = index !== null && index !== undefined;
@@ -113,3 +42,36 @@ function is(test, node, index, parent, context) {
11342

11443
return Boolean(test.call(context, node, index, parent));
11544
}
45+
46+
/* Utility assert each property in `test` is represented
47+
* in `node`, and each values are strictly equal. */
48+
function matchesFactory(test) {
49+
return matches;
50+
51+
function matches(node) {
52+
var key;
53+
54+
for (key in test) {
55+
if (node[key] !== test[key]) {
56+
return false;
57+
}
58+
}
59+
60+
return true;
61+
}
62+
}
63+
64+
/* Utility to convert a string into a function which checks
65+
* a given node’s type for said string. */
66+
function typeFactory(test) {
67+
return type;
68+
69+
function type(node) {
70+
return Boolean(node && node.type === test);
71+
}
72+
}
73+
74+
/* Utility to return true. */
75+
function first() {
76+
return true;
77+
}

test.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
/**
2-
* @author Titus Wormer
3-
* @copyright 2015 Titus Wormer
4-
* @license MIT
5-
* @module unist:util:is
6-
* @fileoverview Test suite for `unit-util-is`.
7-
*/
8-
91
'use strict';
102

11-
/* eslint-env node */
12-
13-
/* Dependencies. */
143
var test = require('tape');
154
var is = require('./');
165

17-
/* Tests. */
186
test('unist-util-is', function (t) {
197
var node = {type: 'strong'};
208
var parent = {type: 'paragraph', children: []};
@@ -98,7 +86,6 @@ test('unist-util-is', function (t) {
9886
t.notok(is({type: 'paragraph'}, node), 'should match partially (#4)');
9987

10088
t.test('should accept a test', function (st) {
101-
/** Test. */
10289
function test(node, n) {
10390
return n === 5;
10491
}
@@ -115,7 +102,6 @@ test('unist-util-is', function (t) {
115102

116103
st.plan(4);
117104

118-
/** Test. */
119105
function test(a, b, c) {
120106
st.equal(this, context);
121107
st.equal(a, node);

0 commit comments

Comments
 (0)