Skip to content

Commit c1611f0

Browse files
committed
Externalise size
1 parent 03b0f69 commit c1611f0

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

index.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var array = require('x-is-array');
44
var object = require('is-object');
55
var proto = require('getprototypeof');
6+
var size = require('unist-util-size');
67

78
var objectProto = Object.prototype;
89

@@ -287,19 +288,6 @@ function syntheticKey(node) {
287288
return node.type + ':' + JSON.stringify(props);
288289
}
289290

290-
function size(node) {
291-
var children = node && node.children;
292-
var length = (children && children.length) || 0;
293-
var index = -1;
294-
var count = 0;
295-
296-
while (++index < length) {
297-
count = count + 1 + size(children[index]);
298-
}
299-
300-
return count;
301-
}
302-
303291
function parent(value) {
304292
return node(value) && 'children' in value;
305293
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"dependencies": {
2121
"getprototypeof": "^1.0.0",
2222
"is-object": "^1.0.1",
23+
"unist-util-size": "^1.0.0",
2324
"x-is-array": "^0.1.0"
2425
},
2526
"files": [

0 commit comments

Comments
 (0)