UNPKG

@cloudinary/url-gen

Version:

Cloudinary URL-Gen SDK ========================= [![Build Status](https://api.travis-ci.com/cloudinary/js-url-gen.svg?branch=master)](https://app.travis-ci.com/github/cloudinary/js-url-gen) ## About The Cloudinary URL-Gen SDK allows you to quickly and eas

34 lines (30 loc) 1.06 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); /** * Sort a map by key * @private * @param map <string, any> * @Return array of map's values sorted by key */ function mapToSortedArray(map, flags) { var array = Array.from(map.entries()); // objects from the Array.from() method above are stored in array of arrays: // [[qualifierKey, QualifierObj], [qualifierKey, QualifierObj]] // Flags is an array of FlagQualifierObj // We need to convert it to the same form: [flagQualifier] => ['fl', flagQualifier] flags.forEach(function (flag) { array.push(['fl', flag]); // push ['fl', flagQualifier] }); return array.sort().map(function (v) { return v[1]; }); } /** * Checks if `value` is a string. * @private * @param {*} value The value to check. * @return {boolean} `true` if `value` is a string, else `false`. */ function isString(value) { return (typeof value === 'string' || value instanceof String); } exports.isString = isString; exports.mapToSortedArray = mapToSortedArray;