source: trip-planner-front/node_modules/snapdragon/lib/utils.js@ 76712b2

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

initial commit

  • Property mode set to 100644
File size: 888 bytes
RevLine 
[6a3a178]1'use strict';
2
3/**
4 * Module dependencies
5 */
6
7exports.extend = require('extend-shallow');
8exports.SourceMap = require('source-map');
9exports.sourceMapResolve = require('source-map-resolve');
10
11/**
12 * Convert backslash in the given string to forward slashes
13 */
14
15exports.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
26exports.isString = function(str) {
27 return str && typeof str === 'string';
28};
29
30/**
31 * Cast `val` to an array
32 * @return {Array}
33 */
34
35exports.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
46exports.last = function(arr, n) {
47 return arr[arr.length - (n || 1)];
48};
Note: See TracBrowser for help on using the repository browser.