Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
587 bytes
|
Line | |
---|
1 | var utils = require('../utils');
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Return length of the given `expr`.
|
---|
5 | *
|
---|
6 | * @param {Expression} expr
|
---|
7 | * @return {Unit}
|
---|
8 | * @api public
|
---|
9 | */
|
---|
10 |
|
---|
11 | (module.exports = function length(expr){
|
---|
12 | if (expr) {
|
---|
13 | if (expr.nodes) {
|
---|
14 | var nodes = utils.unwrap(expr).nodes;
|
---|
15 | if (1 == nodes.length && 'object' == nodes[0].nodeName) {
|
---|
16 | return nodes[0].length;
|
---|
17 | } else if (1 == nodes.length && 'string' == nodes[0].nodeName) {
|
---|
18 | return nodes[0].val.length;
|
---|
19 | } else {
|
---|
20 | return nodes.length;
|
---|
21 | }
|
---|
22 | } else {
|
---|
23 | return 1;
|
---|
24 | }
|
---|
25 | }
|
---|
26 | return 0;
|
---|
27 | }).raw = true;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.