Projekt

Obecné

Profil

Stáhnout (888 Bajtů) Statistiky
| Větev: | Revize:
1
'use strict';
2

    
3
/**
4
 * Module dependencies
5
 */
6

    
7
exports.extend = require('extend-shallow');
8
exports.SourceMap = require('source-map');
9
exports.sourceMapResolve = require('source-map-resolve');
10

    
11
/**
12
 * Convert backslash in the given string to forward slashes
13
 */
14

    
15
exports.unixify = function(fp) {
16
  return fp.split(/\\+/).join('/');
17
};
18

    
19
/**
20
 * Return true if `val` is a non-empty string
21
 *
22
 * @param {String} `str`
23
 * @return {Boolean}
24
 */
25

    
26
exports.isString = function(str) {
27
  return str && typeof str === 'string';
28
};
29

    
30
/**
31
 * Cast `val` to an array
32
 * @return {Array}
33
 */
34

    
35
exports.arrayify = function(val) {
36
  if (typeof val === 'string') return [val];
37
  return val ? (Array.isArray(val) ? val : [val]) : [];
38
};
39

    
40
/**
41
 * Get the last `n` element from the given `array`
42
 * @param {Array} `array`
43
 * @return {*}
44
 */
45

    
46
exports.last = function(arr, n) {
47
  return arr[arr.length - (n || 1)];
48
};
(5-5/5)