@creuna/utils
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -0,1 +1,6 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function anyToKebab(s) { | ||
@@ -6,9 +11,9 @@ if ('string' !== typeof s) { | ||
let result = '', | ||
i = 0, | ||
len = s.length; | ||
var result = '', | ||
i = 0, | ||
len = s.length; | ||
for (; i < len; i++) { | ||
const lowerCased = s[i].toLowerCase(); | ||
const upperCased = s[i].toUpperCase(); | ||
var lowerCased = s[i].toLowerCase(); | ||
var upperCased = s[i].toUpperCase(); | ||
@@ -25,2 +30,2 @@ if (lowerCased !== upperCased && s[i] === upperCased) { | ||
export default anyToKebab; | ||
exports.default = anyToKebab; |
@@ -0,1 +1,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function clamp(currentValue, minimumValue, maximumValue) { | ||
@@ -5,2 +10,2 @@ return Math.max(Math.min(currentValue, maximumValue), minimumValue); | ||
export default clamp; | ||
exports.default = clamp; |
@@ -1,5 +0,15 @@ | ||
import tryParseJson from './try-parse-json'; | ||
'use strict'; | ||
export default function(object) { | ||
return tryParseJson(JSON.stringify(object)); | ||
} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = function (object) { | ||
return (0, _tryParseJson2.default)(JSON.stringify(object)); | ||
}; | ||
var _tryParseJson = require('./try-parse-json'); | ||
var _tryParseJson2 = _interopRequireDefault(_tryParseJson); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -0,1 +1,6 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function fromQueryString(queryString) { | ||
@@ -6,16 +11,13 @@ if (!queryString) { | ||
return queryString | ||
.replace('?', '') | ||
.split('&') | ||
.reduce((accumulator, currentPair) => { | ||
const data = currentPair.split('='); | ||
return queryString.replace('?', '').split('&').reduce(function (accumulator, currentPair) { | ||
var data = currentPair.split('='); | ||
if (data.length === 2) { | ||
accumulator[decodeURIComponent(data[0])] = decodeURIComponent(data[1]); | ||
} | ||
if (data.length === 2) { | ||
accumulator[decodeURIComponent(data[0])] = decodeURIComponent(data[1]); | ||
} | ||
return accumulator; | ||
}, {}); | ||
return accumulator; | ||
}, {}); | ||
} | ||
export default fromQueryString; | ||
exports.default = fromQueryString; |
@@ -1,12 +0,28 @@ | ||
import anyToKebab from './any-to-kebab'; | ||
import isRunningOnClient from './is-running-on-client'; | ||
import kebabToCamel from './kebab-to-camel'; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _anyToKebab = require('./any-to-kebab'); | ||
var _anyToKebab2 = _interopRequireDefault(_anyToKebab); | ||
var _isRunningOnClient = require('./is-running-on-client'); | ||
var _isRunningOnClient2 = _interopRequireDefault(_isRunningOnClient); | ||
var _kebabToCamel = require('./kebab-to-camel'); | ||
var _kebabToCamel2 = _interopRequireDefault(_kebabToCamel); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function getData(dataAttributeName) { | ||
if (!isRunningOnClient) { | ||
if (!_isRunningOnClient2.default) { | ||
return; | ||
} | ||
const kebabedName = anyToKebab(dataAttributeName); | ||
const node = document.querySelector(`[data-${kebabedName}]`); | ||
var kebabedName = (0, _anyToKebab2.default)(dataAttributeName); | ||
var node = document.querySelector('[data-' + kebabedName + ']'); | ||
@@ -17,5 +33,5 @@ if (!node) { | ||
return node.dataset[kebabToCamel(kebabedName)]; | ||
return node.dataset[(0, _kebabToCamel2.default)(kebabedName)]; | ||
} | ||
export default getData; | ||
exports.default = getData; |
146
index.js
@@ -1,43 +0,105 @@ | ||
// NOTE: Do not edit this file. It is ✨automagically✨ created during the build process. | ||
// NOTE: Generated at Thu, 03 May 2018 18:15:32 GMT. | ||
import AnyToKebab from './any-to-kebab'; | ||
import Clamp from './clamp'; | ||
import DeepClone from './deep-clone'; | ||
import FromQueryString from './from-query-string'; | ||
import GetData from './get-data'; | ||
import IsElementInViewport from './is-element-in-viewport'; | ||
import IsEqual from './is-equal'; | ||
import IsRunningOnClient from './is-running-on-client'; | ||
import KebabToCamel from './kebab-to-camel'; | ||
import KebabToPascal from './kebab-to-pascal'; | ||
import RangeMap from './range-map'; | ||
import ReplaceQueryParameters from './replace-query-parameters'; | ||
import ScrollToElement from './scroll-to-element'; | ||
import ScrollToPosition from './scroll-to-position'; | ||
import ScrollingElement from './scrolling-element'; | ||
import StripPropertiesWithValue from './strip-properties-with-value'; | ||
import StripUndefined from './strip-undefined'; | ||
import ToQueryString from './to-query-string'; | ||
import TryParseJson from './try-parse-json'; | ||
'use strict'; | ||
export { | ||
AnyToKebab, | ||
Clamp, | ||
DeepClone, | ||
FromQueryString, | ||
GetData, | ||
IsElementInViewport, | ||
IsEqual, | ||
IsRunningOnClient, | ||
KebabToCamel, | ||
KebabToPascal, | ||
RangeMap, | ||
ReplaceQueryParameters, | ||
ScrollToElement, | ||
ScrollToPosition, | ||
ScrollingElement, | ||
StripPropertiesWithValue, | ||
StripUndefined, | ||
ToQueryString, | ||
TryParseJson | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TryParseJson = exports.ToQueryString = exports.StripUndefined = exports.StripPropertiesWithValue = exports.ScrollingElement = exports.ScrollToPosition = exports.ScrollToElement = exports.ReplaceQueryParameters = exports.RangeMap = exports.KebabToPascal = exports.KebabToCamel = exports.IsRunningOnClient = exports.IsEqual = exports.IsElementInViewport = exports.GetData = exports.FromQueryString = exports.DeepClone = exports.Clamp = exports.AnyToKebab = undefined; | ||
var _anyToKebab = require('./any-to-kebab'); | ||
var _anyToKebab2 = _interopRequireDefault(_anyToKebab); | ||
var _clamp = require('./clamp'); | ||
var _clamp2 = _interopRequireDefault(_clamp); | ||
var _deepClone = require('./deep-clone'); | ||
var _deepClone2 = _interopRequireDefault(_deepClone); | ||
var _fromQueryString = require('./from-query-string'); | ||
var _fromQueryString2 = _interopRequireDefault(_fromQueryString); | ||
var _getData = require('./get-data'); | ||
var _getData2 = _interopRequireDefault(_getData); | ||
var _isElementInViewport = require('./is-element-in-viewport'); | ||
var _isElementInViewport2 = _interopRequireDefault(_isElementInViewport); | ||
var _isEqual = require('./is-equal'); | ||
var _isEqual2 = _interopRequireDefault(_isEqual); | ||
var _isRunningOnClient = require('./is-running-on-client'); | ||
var _isRunningOnClient2 = _interopRequireDefault(_isRunningOnClient); | ||
var _kebabToCamel = require('./kebab-to-camel'); | ||
var _kebabToCamel2 = _interopRequireDefault(_kebabToCamel); | ||
var _kebabToPascal = require('./kebab-to-pascal'); | ||
var _kebabToPascal2 = _interopRequireDefault(_kebabToPascal); | ||
var _rangeMap = require('./range-map'); | ||
var _rangeMap2 = _interopRequireDefault(_rangeMap); | ||
var _replaceQueryParameters = require('./replace-query-parameters'); | ||
var _replaceQueryParameters2 = _interopRequireDefault(_replaceQueryParameters); | ||
var _scrollToElement = require('./scroll-to-element'); | ||
var _scrollToElement2 = _interopRequireDefault(_scrollToElement); | ||
var _scrollToPosition = require('./scroll-to-position'); | ||
var _scrollToPosition2 = _interopRequireDefault(_scrollToPosition); | ||
var _scrollingElement = require('./scrolling-element'); | ||
var _scrollingElement2 = _interopRequireDefault(_scrollingElement); | ||
var _stripPropertiesWithValue = require('./strip-properties-with-value'); | ||
var _stripPropertiesWithValue2 = _interopRequireDefault(_stripPropertiesWithValue); | ||
var _stripUndefined = require('./strip-undefined'); | ||
var _stripUndefined2 = _interopRequireDefault(_stripUndefined); | ||
var _toQueryString = require('./to-query-string'); | ||
var _toQueryString2 = _interopRequireDefault(_toQueryString); | ||
var _tryParseJson = require('./try-parse-json'); | ||
var _tryParseJson2 = _interopRequireDefault(_tryParseJson); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.AnyToKebab = _anyToKebab2.default; | ||
exports.Clamp = _clamp2.default; | ||
exports.DeepClone = _deepClone2.default; | ||
exports.FromQueryString = _fromQueryString2.default; | ||
exports.GetData = _getData2.default; | ||
exports.IsElementInViewport = _isElementInViewport2.default; | ||
exports.IsEqual = _isEqual2.default; | ||
exports.IsRunningOnClient = _isRunningOnClient2.default; | ||
exports.KebabToCamel = _kebabToCamel2.default; | ||
exports.KebabToPascal = _kebabToPascal2.default; | ||
exports.RangeMap = _rangeMap2.default; | ||
exports.ReplaceQueryParameters = _replaceQueryParameters2.default; | ||
exports.ScrollToElement = _scrollToElement2.default; | ||
exports.ScrollToPosition = _scrollToPosition2.default; | ||
exports.ScrollingElement = _scrollingElement2.default; | ||
exports.StripPropertiesWithValue = _stripPropertiesWithValue2.default; | ||
exports.StripUndefined = _stripUndefined2.default; | ||
exports.ToQueryString = _toQueryString2.default; | ||
exports.TryParseJson = _tryParseJson2.default; // NOTE: Do not edit this file. It is ✨automagically✨ created during the build process. | ||
// NOTE: Generated at Fri, 04 May 2018 13:16:35 GMT. |
@@ -1,19 +0,23 @@ | ||
import isRunningOnClient from './is-running-on-client'; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _isRunningOnClient = require('./is-running-on-client'); | ||
var _isRunningOnClient2 = _interopRequireDefault(_isRunningOnClient); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function isElementInViewport(el) { | ||
if (!isRunningOnClient || !el) { | ||
if (!_isRunningOnClient2.default || !el) { | ||
return false; | ||
} | ||
const rect = el.getBoundingClientRect(); | ||
var rect = el.getBoundingClientRect(); | ||
return ( | ||
rect.top >= 0 && | ||
rect.left >= 0 && | ||
rect.bottom <= | ||
(window.innerHeight || document.documentElement.clientHeight) && | ||
rect.right <= (window.innerWidth || document.documentElement.clientWidth) | ||
); | ||
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth); | ||
} | ||
export default isElementInViewport; | ||
exports.default = isElementInViewport; |
@@ -1,1 +0,9 @@ | ||
export default (a, b) => JSON.stringify(a) === JSON.stringify(b); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = function (a, b) { | ||
return JSON.stringify(a) === JSON.stringify(b); | ||
}; |
@@ -1,4 +0,8 @@ | ||
const isRunningOnClient = | ||
typeof window !== 'undefined' && window.document ? true : false; | ||
'use strict'; | ||
export default isRunningOnClient; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var isRunningOnClient = typeof window !== 'undefined' && window.document ? true : false; | ||
exports.default = isRunningOnClient; |
@@ -1,3 +0,13 @@ | ||
import kebabToPascal from './kebab-to-pascal'; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _kebabToPascal = require('./kebab-to-pascal'); | ||
var _kebabToPascal2 = _interopRequireDefault(_kebabToPascal); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function kebabToCamel(s) { | ||
@@ -8,3 +18,3 @@ if ('string' !== typeof s) { | ||
const p = kebabToPascal(s); | ||
var p = (0, _kebabToPascal2.default)(s); | ||
@@ -14,2 +24,2 @@ return p.substr(0, 1).toLowerCase() + p.substring(1); | ||
export default kebabToCamel; | ||
exports.default = kebabToCamel; |
@@ -0,1 +1,6 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function kebabToPascal(s) { | ||
@@ -6,7 +11,7 @@ if ('string' !== typeof s || s.length === 0) { | ||
let result = s.substr(0, 1).toUpperCase(), | ||
i = 1, | ||
len = s.length; | ||
var result = s.substr(0, 1).toUpperCase(), | ||
i = 1, | ||
len = s.length; | ||
for (; i < len; i++) | ||
for (; i < len; i++) { | ||
if (s[i] === '-' && i + 1 !== len) { | ||
@@ -16,6 +21,5 @@ result += s[i + 1].toUpperCase(); | ||
} else result += s[i].toLowerCase(); | ||
return result[0] !== '-' ? result : result.substr(1); | ||
}return result[0] !== '-' ? result : result.substr(1); | ||
} | ||
export default kebabToPascal; | ||
exports.default = kebabToPascal; |
{ | ||
"name": "@creuna/utils", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Creuna js utils", | ||
@@ -8,4 +8,4 @@ "main": "index.js", | ||
"scripts": { | ||
"build": "node ./build/generate-index.js", | ||
"copy": "node ./build/copy-files.js", | ||
"generate": "node ./build/generate-index.js", | ||
"build": "babel source -d .", | ||
"clean": "node ./build/clean-files.js", | ||
@@ -38,2 +38,3 @@ "test": "ava" | ||
"babel": "^6.23.0", | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^8.2.3", | ||
@@ -40,0 +41,0 @@ "babel-preset-env": "^1.6.1", |
@@ -1,3 +0,9 @@ | ||
export default function(val, inMin, inMax, outMin, outMax) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = function (val, inMin, inMax, outMin, outMax) { | ||
return (val - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; | ||
} | ||
}; |
@@ -1,14 +0,27 @@ | ||
import fromQueryString from './from-query-string'; | ||
import toQueryString from './to-query-string'; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _fromQueryString = require('./from-query-string'); | ||
var _fromQueryString2 = _interopRequireDefault(_fromQueryString); | ||
var _toQueryString = require('./to-query-string'); | ||
var _toQueryString2 = _interopRequireDefault(_toQueryString); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function replaceQueryParameters(url, query) { | ||
const urlFragments = url.split('?'); | ||
const baseUrl = urlFragments[0]; | ||
const originalQueryString = urlFragments[1]; | ||
const originalQuery = fromQueryString(originalQueryString); | ||
const newQuery = Object.assign({}, originalQuery, query); | ||
var urlFragments = url.split('?'); | ||
var baseUrl = urlFragments[0]; | ||
var originalQueryString = urlFragments[1]; | ||
var originalQuery = (0, _fromQueryString2.default)(originalQueryString); | ||
var newQuery = Object.assign({}, originalQuery, query); | ||
return `${baseUrl}${toQueryString(newQuery)}`; | ||
return '' + baseUrl + (0, _toQueryString2.default)(newQuery); | ||
} | ||
export default replaceQueryParameters; | ||
exports.default = replaceQueryParameters; |
@@ -1,16 +0,32 @@ | ||
import scrollingElement from './scrolling-element'; | ||
import scrollToPosition from './scroll-to-position'; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _scrollingElement = require('./scrolling-element'); | ||
var _scrollingElement2 = _interopRequireDefault(_scrollingElement); | ||
var _scrollToPosition = require('./scroll-to-position'); | ||
var _scrollToPosition2 = _interopRequireDefault(_scrollToPosition); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function doScrollToElement(element, offset, duration) { | ||
const scrollPos = | ||
element.getBoundingClientRect().top + scrollingElement.scrollTop - offset; | ||
var scrollPos = element.getBoundingClientRect().top + _scrollingElement2.default.scrollTop - offset; | ||
scrollToPosition(scrollPos, duration); | ||
(0, _scrollToPosition2.default)(scrollPos, duration); | ||
} | ||
function scrollToElement(element, offset = 0, duration = 500, delay = 0) { | ||
function scrollToElement(element) { | ||
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500; | ||
var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; | ||
window.isAutoScrolling = true; | ||
if (delay > 0) { | ||
window.autoScrollingTimoutId = setTimeout(() => { | ||
window.autoScrollingTimoutId = setTimeout(function () { | ||
doScrollToElement(element, offset, duration); | ||
@@ -23,2 +39,2 @@ }, delay); | ||
export default scrollToElement; | ||
exports.default = scrollToElement; |
@@ -1,16 +0,25 @@ | ||
import scrollingElement from './scrolling-element'; | ||
'use strict'; | ||
function doScrollToPosition(y, duration = 500) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _scrollingElement = require('./scrolling-element'); | ||
var _scrollingElement2 = _interopRequireDefault(_scrollingElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function doScrollToPosition(y) { | ||
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500; | ||
clearTimeout(window.autoScrollingTimoutId); | ||
const initialY = scrollingElement.scrollTop; | ||
const baseY = (initialY + y) * 0.5; | ||
const difference = initialY - baseY; | ||
const startTime = performance.now(); | ||
var initialY = _scrollingElement2.default.scrollTop; | ||
var baseY = (initialY + y) * 0.5; | ||
var difference = initialY - baseY; | ||
var startTime = performance.now(); | ||
function step() { | ||
const normalizedTime = Math.min( | ||
(performance.now() - startTime) / duration, | ||
1 | ||
); | ||
var normalizedTime = Math.min((performance.now() - startTime) / duration, 1); | ||
@@ -22,3 +31,3 @@ window.scrollTo(0, baseY + difference * Math.cos(normalizedTime * Math.PI)); | ||
} else { | ||
setTimeout(() => { | ||
setTimeout(function () { | ||
window.isAutoScrolling = false; | ||
@@ -31,7 +40,10 @@ }, 100); | ||
function scrollToPosition(y, duration = 500, delay = 0) { | ||
function scrollToPosition(y) { | ||
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500; | ||
var delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; | ||
window.isAutoScrolling = true; | ||
if (delay > 0) { | ||
window.autoScrollingTimoutId = setTimeout(() => { | ||
window.autoScrollingTimoutId = setTimeout(function () { | ||
doScrollToPosition(y, duration); | ||
@@ -44,2 +56,2 @@ }, delay); | ||
export default scrollToPosition; | ||
exports.default = scrollToPosition; |
@@ -1,8 +0,16 @@ | ||
import isRunningOnClient from './is-running-on-client'; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _isRunningOnClient = require('./is-running-on-client'); | ||
var _isRunningOnClient2 = _interopRequireDefault(_isRunningOnClient); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// NOTE: https://stackoverflow.com/questions/45061901/chrome-61-body-doesnt-scroll | ||
const scrollingElement = isRunningOnClient | ||
? document.scrollingElement || document.documentElement || document.body | ||
: undefined; | ||
var scrollingElement = _isRunningOnClient2.default ? document.scrollingElement || document.documentElement || document.body : undefined; | ||
export default scrollingElement; | ||
exports.default = scrollingElement; |
@@ -0,5 +1,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function stripPropertiesWithValue(object, value) { | ||
return Object.keys(object).reduce((accumulator, key) => { | ||
return Object.keys(object).reduce(function (accumulator, key) { | ||
if (object[key] !== value) { | ||
Object.assign(accumulator, { [key]: object[key] }); | ||
Object.assign(accumulator, _defineProperty({}, key, object[key])); | ||
} | ||
@@ -11,2 +19,2 @@ | ||
export default stripPropertiesWithValue; | ||
exports.default = stripPropertiesWithValue; |
@@ -1,7 +0,17 @@ | ||
import stripPropertiesWithValue from './strip-properties-with-value'; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _stripPropertiesWithValue = require('./strip-properties-with-value'); | ||
var _stripPropertiesWithValue2 = _interopRequireDefault(_stripPropertiesWithValue); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function stripUndefined(object) { | ||
return stripPropertiesWithValue(object, undefined); | ||
return (0, _stripPropertiesWithValue2.default)(object, undefined); | ||
} | ||
export default stripUndefined; | ||
exports.default = stripUndefined; |
@@ -1,18 +0,23 @@ | ||
function toQueryString(queryObject, encode = true) { | ||
return Object.keys(queryObject) | ||
.filter(key => queryObject[key] !== undefined) | ||
.reduce((accumulator, currentKey, currentIndex) => { | ||
const currentValue = queryObject[currentKey]; | ||
const separator = currentIndex === 0 ? '?' : '&'; | ||
'use strict'; | ||
if (currentValue !== undefined) { | ||
accumulator = `${accumulator}${separator}${ | ||
encode ? encodeURIComponent(currentKey) : currentKey | ||
}=${encode ? encodeURIComponent(currentValue) : currentValue}`; | ||
} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function toQueryString(queryObject) { | ||
var encode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
return accumulator; | ||
}, ''); | ||
return Object.keys(queryObject).filter(function (key) { | ||
return queryObject[key] !== undefined; | ||
}).reduce(function (accumulator, currentKey, currentIndex) { | ||
var currentValue = queryObject[currentKey]; | ||
var separator = currentIndex === 0 ? '?' : '&'; | ||
if (currentValue !== undefined) { | ||
accumulator = '' + accumulator + separator + (encode ? encodeURIComponent(currentKey) : currentKey) + '=' + (encode ? encodeURIComponent(currentValue) : currentValue); | ||
} | ||
return accumulator; | ||
}, ''); | ||
} | ||
export default toQueryString; | ||
exports.default = toQueryString; |
@@ -0,1 +1,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function tryParseJson(possiblyJson, defaultValue) { | ||
@@ -9,2 +14,2 @@ try { | ||
export default tryParseJson; | ||
exports.default = tryParseJson; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22341
345
11
1