Socket
Socket
Sign inDemoInstall

@typed/common

Package Overview
Dependencies
1
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

.rpt2_cache/rpt2_f9b73854ffa356798bfdbddd0c4dedea297616d3/code/cache/194f2d056a1991b4818ba93d0eafb3d356cf3fa4

2

esm/addQueryParameters.js

@@ -26,2 +26,2 @@ /**

}
//# sourceMappingURL=addQueryParameters.js.map
//# sourceMappingURL=addQueryParameters.js.map
// Very loose definition of a browser environment
export const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
//# sourceMappingURL=executionEnvironment.js.map
//# sourceMappingURL=executionEnvironment.js.map
{
"name": "@typed/common",
"version": "1.0.1",
"version": "1.0.2",
"description": "Assortment of shared functions & types for Typed libraries",

@@ -19,3 +19,3 @@ "main": "./cjs/index.js",

"author": "Tylor Steinberger <tlsteinberger167@gmail.com>",
"license": "MIT",
"license": "Parity Public Licence 3.0 <https://licensezero.com/ids/52afd698-c5c7-4034-b229-ef1243d4caeb/>",
"bugs": {

@@ -32,4 +32,4 @@ "url": "https://github.com/tylors/typed-prelude/issues"

"sideEffects": false,
"gitHead": "8b2b4a461b095009848d027948f97eae513593a4",
"gitHead": "3f92e2f169fdbbcf4c478b22f50324c714ebad52",
"unpkg": "./umd/index.js"
}

@@ -1,402 +0,2 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory((global.Typed = global.Typed || {}, global.Typed.Common = {})));
}(this, function (exports) { 'use strict';
/**
* Append Query Parameters to a Url
* @param url :: String
* @param queryParams :: Record<string, string | undefined>
* @returns string
*/
function addQueryParameters(url, queryParams) {
if (queryParams === undefined) {
return (queryParams) => __addQueryParameters(url, queryParams);
}
return __addQueryParameters(url, queryParams);
}
function __addQueryParameters(url, queryParams) {
const params = Object.keys(queryParams)
.sort()
.map(queryParam(queryParams))
.join('&');
return encodeURI(`${url}${params ? `?${params}` : ''}`);
}
function queryParam(queryParams) {
return (key) => {
const value = queryParams[key];
return value ? `${key}=${value}` : key;
};
}
function typeOf(value) {
if (value === null) {
return 'Null';
}
if (value === void 0) {
return `Undefined`;
}
return Object.prototype.toString.call(value).slice(8, -1);
}
function clone(value, refFrom, refTo, deep) {
function copy(copiedValue) {
const length = refFrom.length;
let i = 0;
for (; i < length; ++i) {
if (value === refFrom[i]) {
return refTo[i];
}
}
refFrom[i + 1] = value;
refTo[i + 1] = copiedValue;
for (const key in value) {
if (!value.hasOwnProperty(key)) {
continue;
}
copiedValue[key] = deep ? clone(value[key], refFrom, refTo, true) : value[key];
}
return copiedValue;
}
switch (typeOf(value)) {
case 'Object':
return copy({});
case 'Array':
return copy([]);
case 'Date':
return new Date(value.valueOf());
case 'RegExp':
return cloneRegexp(value);
default:
return value;
}
}
function cloneRegexp(pattern) {
return new RegExp(pattern.source, (pattern.global ? 'g' : '') +
(pattern.ignoreCase ? 'i' : '') +
(pattern.multiline ? 'm' : '') +
(pattern.sticky ? 'y' : '') +
(pattern.unicode ? 'u' : ''));
}
const FUNCTION_NAME_REGEX = /^function\s*([\w$]+)/;
const DEFAULT_MATCH = ['', ''];
/**
* Returns the name of a function.
* @name functionName(fn: Function): string
*/
function functionName(fn) {
if (fn.name) {
return fn.name;
}
const [, name] = String(fn).match(FUNCTION_NAME_REGEX) || DEFAULT_MATCH;
return name;
}
function includesWith(pred, x, list) {
let idx = 0;
const len = list.length;
while (idx < len) {
if (pred(x, list[idx], idx)) {
return true;
}
idx += 1;
}
return false;
}
function equals(a, b, stackA = [], stackB = []) {
if (Object.is(a, b)) {
return true;
}
const typeA = typeOf(a);
if (typeA !== typeOf(b)) {
return false;
}
if (a == null || b == null) {
return false;
}
switch (typeA) {
case 'Arguments':
case 'Array':
case 'Object':
if (typeof a.constructor === 'function' && functionName(a.constructor) === 'Promise') {
return a === b;
}
break;
case 'Boolean':
case 'Number':
case 'String':
if (!(typeof a === typeof b && Object.is(a.valueOf(), b.valueOf()))) {
return false;
}
break;
case 'Date':
if (!Object.is(a.valueOf(), b.valueOf())) {
return false;
}
break;
case 'Error':
return a.name === b.name && a.message === b.message;
case 'RegExp':
if (!(a.source === b.source &&
a.global === b.global &&
a.ignoreCase === b.ignoreCase &&
a.multiline === b.multiline &&
a.sticky === b.sticky &&
a.unicode === b.unicode)) {
return false;
}
break;
}
let idx = stackA.length - 1;
while (idx >= 0) {
if (stackA[idx] === a) {
return stackB[idx] === b;
}
idx -= 1;
}
switch (typeA) {
case 'Map':
if (a.size !== b.size) {
return false;
}
return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
case 'Set':
if (a.size !== b.size) {
return false;
}
return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
case 'Arguments':
case 'Array':
case 'Object':
case 'Boolean':
case 'Number':
case 'String':
case 'Date':
case 'Error':
case 'RegExp':
case 'Int8Array':
case 'Uint8Array':
case 'Uint8ClampedArray':
case 'Int16Array':
case 'Uint16Array':
case 'Int32Array':
case 'Uint32Array':
case 'Float32Array':
case 'Float64Array':
case 'ArrayBuffer':
break;
default:
// Values of other types are only equal if identical.
return false;
}
const keysA = Object.keys(a);
if (keysA.length !== Object.keys(b).length) {
return false;
}
const extendedStackA = stackA.concat([a]);
const extendedStackB = stackB.concat([b]);
idx = keysA.length - 1;
while (idx >= 0) {
const key = keysA[idx];
if (!(Object.prototype.hasOwnProperty.call(b, key) &&
equals(b[key], a[key], extendedStackA, extendedStackB))) {
return false;
}
idx -= 1;
}
return true;
}
function _uniqContentEquals(aIterable, bIterable, stackA, stackB) {
const a = Array.from(aIterable);
const b = Array.from(bIterable);
// tslint:disable-next-line:variable-name
function eq(_a, _b) {
return equals(_a, _b, stackA.slice(), stackB.slice());
}
// if *a* array contains any element that is not included in *b*
// tslint:disable-next-line:no-shadowed-variable
return !includesWith((b, aItem) => !includesWith(eq, aItem, b), b, a);
}
// Very loose definition of a browser environment
const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
function indexOf(list, a, idx = 0) {
// Array.prototype.indexOf doesn't exist below IE9
if (typeof list.indexOf === 'function') {
switch (typeof a) {
case 'number':
let inf;
let item;
if (a === 0) {
// manually crawl the list to distinguish between +0 and -0
inf = 1 / a;
while (idx < list.length) {
item = list[idx];
if (item === 0 && 1 / item === inf) {
return idx;
}
idx += 1;
}
return -1;
}
else if (a !== a) {
// NaN
while (idx < list.length) {
item = list[idx];
if (typeof item === 'number' && item !== item) {
return idx;
}
idx += 1;
}
return -1;
}
// non-zero numbers can utilise Set
return list.indexOf(a, idx);
// all these types can utilise Set
case 'string':
case 'boolean':
case 'function':
case 'undefined':
return list.indexOf(a, idx);
case 'object':
if (a === null) {
// null can utilise Set
return list.indexOf(a, idx);
}
}
}
while (idx < list.length) {
if (equals(list[idx], a)) {
return idx;
}
idx += 1;
}
return -1;
}
function mapArrayLike(fn, functor) {
let idx = 0;
const len = functor.length;
const result = Array(len);
while (idx < len) {
result[idx] = fn(functor[idx]);
idx += 1;
}
return result;
}
function mapObj(fn, obj) {
const newObj = {};
// tslint:disable-next-line:forin
for (const key in obj) {
newObj[key] = fn(key, obj[key]);
}
return newObj;
}
const DUPLICATE_PATH_SEPARATOR_REGEX = /\/{2,}/g;
const PATH_SEPARATOR = `/`;
const isString = (x) => typeof x === 'string';
/**
*
* @param paths :: string[] A list of paths to join together
* @param trailingSlash :: boolean whether or not to append a trailing slash
*/
function pathJoin(paths, trailingSlash = false) {
const path = `/${paths.filter(isString).join(PATH_SEPARATOR)}`.replace(DUPLICATE_PATH_SEPARATOR_REGEX, PATH_SEPARATOR);
return !trailingSlash || path[path.length - 1] === '/' ? path : path + '/';
}
const STEPS = [
[/\\/g, '\\\\'],
[/[\b]/g, '\\b'],
[/\f/g, '\\f'],
[/\n/g, '\\n'],
[/\r/g, '\\r'],
[/\t/g, '\\t'],
[/\v/g, '\\v'],
[/\0/g, '\\0'],
];
const LAST_STEP = [/"/g, '\\"'];
function quote(s) {
const escaped = STEPS.reduce(applyStep, s);
return '"' + applyStep(escaped, LAST_STEP) + '"';
}
function applyStep(str, step) {
return str.replace(step[0], step[1]);
}
/**
* Convert anything into a string
* @param x :: any
* @returns a string representation of a value
*/
const toString = (x) => _toString(x, []);
function _toString(x, seen) {
const recur = (y) => {
const xs = seen.concat([x]);
return indexOf(xs, y) > -1 ? '<Circular>' : _toString(y, xs);
};
const mapPairs = (obj, keys) => {
return mapArrayLike((k) => {
return quote(k) + ': ' + recur(obj[k]);
}, keys.slice().sort());
};
switch (Object.prototype.toString.call(x)) {
case '[object Arguments]':
return '(function() { return arguments; }(' + mapArrayLike(recur, x).join(', ') + '))';
case '[object Array]':
return ('[' +
mapArrayLike(recur, x)
.concat(mapPairs(x, Object.keys(x).filter(k => !/^\d+$/.test(k))))
.join(', ') +
']');
case '[object Boolean]':
return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString();
case '[object Date]':
return ('new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : quote(x.toISOString())) + ')');
case '[object Null]':
return 'null';
case '[object Number]':
return typeof x === 'object'
? 'new Number(' + recur(x.valueOf()) + ')'
: 1 / x === -Infinity
? '-0'
: x.toString(10);
case '[object String]':
return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : quote(x);
case '[object Undefined]':
return 'undefined';
default:
if (typeof x.toString === 'function') {
const repr = x.toString();
if (repr !== '[object Object]') {
return repr;
}
}
return '{' + mapPairs(x, Object.keys(x)).join(', ') + '}';
}
}
exports.addQueryParameters = addQueryParameters;
exports.clone = clone;
exports.equals = equals;
exports.functionName = functionName;
exports.includesWith = includesWith;
exports.indexOf = indexOf;
exports.isBrowser = isBrowser;
exports.mapArrayLike = mapArrayLike;
exports.mapObj = mapObj;
exports.pathJoin = pathJoin;
exports.quote = quote;
exports.toString = toString;
exports.typeOf = typeOf;
Object.defineProperty(exports, '__esModule', { value: true });
}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e=e||self).Typed=e.Typed||{},e.Typed.Common={}))}(this,function(e){"use strict";function t(e,t){const n=Object.keys(t).sort().map(function(e){return t=>{const n=e[t];return n?`${t}=${n}`:t}}(t)).join("&");return encodeURI(`${e}${n?`?${n}`:""}`)}function n(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)}const r=/^function\s*([\w$]+)/,c=["",""];function o(e){if(e.name)return e.name;const[,t]=String(e).match(r)||c;return t}function u(e,t,n){let r=0;const c=n.length;for(;r<c;){if(e(t,n[r],r))return!0;r+=1}return!1}function a(e,t,r=[],c=[]){if(Object.is(e,t))return!0;const u=n(e);if(u!==n(t))return!1;if(null==e||null==t)return!1;switch(u){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===o(e.constructor))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!Object.is(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!Object.is(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}let s=r.length-1;for(;s>=0;){if(r[s]===e)return c[s]===t;s-=1}switch(u){case"Map":return e.size===t.size&&i(e.entries(),t.entries(),r.concat([e]),c.concat([t]));case"Set":return e.size===t.size&&i(e.values(),t.values(),r.concat([e]),c.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}const f=Object.keys(e);if(f.length!==Object.keys(t).length)return!1;const l=r.concat([e]),g=c.concat([t]);for(s=f.length-1;s>=0;){const n=f[s];if(!Object.prototype.hasOwnProperty.call(t,n)||!a(t[n],e[n],l,g))return!1;s-=1}return!0}function i(e,t,n,r){const c=Array.from(e);function o(e,t){return a(e,t,n.slice(),r.slice())}return!u((e,t)=>!u(o,t,e),Array.from(t),c)}function s(e,t,n=0){if("function"==typeof e.indexOf)switch(typeof t){case"number":let r,c;if(0===t){for(r=1/t;n<e.length;){if(0===(c=e[n])&&1/c===r)return n;n+=1}return-1}if(t!=t){for(;n<e.length;){if("number"==typeof(c=e[n])&&c!=c)return n;n+=1}return-1}return e.indexOf(t,n);case"string":case"boolean":case"function":case"undefined":return e.indexOf(t,n);case"object":if(null===t)return e.indexOf(t,n)}for(;n<e.length;){if(a(e[n],t))return n;n+=1}return-1}function f(e,t){let n=0;const r=t.length,c=Array(r);for(;n<r;)c[n]=e(t[n]),n+=1;return c}const l=/\/{2,}/g,g="/",y=e=>"string"==typeof e;const b=[[/\\/g,"\\\\"],[/[\b]/g,"\\b"],[/\f/g,"\\f"],[/\n/g,"\\n"],[/\r/g,"\\r"],[/\t/g,"\\t"],[/\v/g,"\\v"],[/\0/g,"\\0"]],p=[/"/g,'\\"'];function d(e){return'"'+j(b.reduce(j,e),p)+'"'}function j(e,t){return e.replace(t[0],t[1])}e.addQueryParameters=function(e,n){return void 0===n?n=>t(e,n):t(e,n)},e.clone=function e(t,r,c,o){function u(n){const u=r.length;let a=0;for(;a<u;++a)if(t===r[a])return c[a];r[a+1]=t,c[a+1]=n;for(const u in t)t.hasOwnProperty(u)&&(n[u]=o?e(t[u],r,c,!0):t[u]);return n}switch(n(t)){case"Object":return u({});case"Array":return u([]);case"Date":return new Date(t.valueOf());case"RegExp":return a=t,new RegExp(a.source,(a.global?"g":"")+(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.sticky?"y":"")+(a.unicode?"u":""));default:return t}var a},e.equals=a,e.functionName=o,e.includesWith=u,e.indexOf=s,e.isBrowser=!0,e.mapArrayLike=f,e.mapObj=function(e,t){const n={};for(const r in t)n[r]=e(r,t[r]);return n},e.pathJoin=function(e,t=!1){const n=`/${e.filter(y).join(g)}`.replace(l,g);return t&&"/"!==n[n.length-1]?n+"/":n},e.quote=d,e.toString=e=>(function e(t,n){const r=r=>{const c=n.concat([t]);return s(c,r)>-1?"<Circular>":e(r,c)},c=(e,t)=>f(t=>d(t)+": "+r(e[t]),t.slice().sort());switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+f(r,t).join(", ")+"))";case"[object Array]":return"["+f(r,t).concat(c(t,Object.keys(t).filter(e=>!/^\d+$/.test(e)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+r(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?r(NaN):d(t.toISOString()))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+r(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object String]":return"object"==typeof t?"new String("+r(t.valueOf())+")":d(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){const e=t.toString();if("[object Object]"!==e)return e}return"{"+c(t,Object.keys(t)).join(", ")+"}"}})(e,[]),e.typeOf=n,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=index.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc