source: trip-planner-front/node_modules/stylus/lib/functions/substr.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 607 bytes
Line 
1var utils = require('../utils')
2 , nodes = require('../nodes');
3
4/**
5 * Returns substring of the given `val`.
6 *
7 * @param {String|Ident} val
8 * @param {Number} start
9 * @param {Number} [length]
10 * @return {String|Ident}
11 * @api public
12 */
13
14function substr(val, start, length){
15 utils.assertString(val, 'val');
16 utils.assertType(start, 'unit', 'start');
17 length = length && length.val;
18 var res = val.string.substr(start.val, length);
19 return val instanceof nodes.Ident
20 ? new nodes.Ident(res)
21 : new nodes.String(res);
22}
23substr.params = ['val', 'start', 'length'];
24module.exports = substr;
Note: See TracBrowser for help on using the repository browser.