@pnp/common
Advanced tools
Comparing version 2.1.0-beta8 to 2.1.0-beta9
@@ -5,3 +5,3 @@ import { isFunc, objectDefinedNotNull } from "./util.js"; | ||
*/ | ||
var objectEntries = isFunc(Object.entries) ? Object.entries : function (o) { return Object.keys(o).map(function (k) { return [k, o[k]]; }); }; | ||
const objectEntries = isFunc(Object.entries) ? Object.entries : (o) => Object.keys(o).map((k) => [k, o[k]]); | ||
/** | ||
@@ -24,9 +24,5 @@ * Converts the supplied object to a map | ||
*/ | ||
export function mergeMaps(target) { | ||
var maps = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
maps[_i - 1] = arguments[_i]; | ||
} | ||
for (var i = 0; i < maps.length; i++) { | ||
maps[i].forEach(function (v, k) { | ||
export function mergeMaps(target, ...maps) { | ||
for (let i = 0; i < maps.length; i++) { | ||
maps[i].forEach((v, k) => { | ||
// let's not run the spfx context through Object.assign :) | ||
@@ -33,0 +29,0 @@ if ((typeof k === "string" && k !== "spfxContext") && Object.prototype.toString.call(v) === "[object Object]") { |
@@ -54,3 +54,3 @@ import { ITypedHash } from "./collections.js"; | ||
} | ||
export declare let DefaultRuntime: Runtime; | ||
export declare const DefaultRuntime: Runtime; | ||
//# sourceMappingURL=libconfig.d.ts.map |
@@ -1,9 +0,7 @@ | ||
import { __read, __values } from "tslib"; | ||
import { mergeMaps, objectToMap } from "./collections.js"; | ||
export function setup(config, runtime) { | ||
if (runtime === void 0) { runtime = DefaultRuntime; } | ||
export function setup(config, runtime = DefaultRuntime) { | ||
runtime.assign(config); | ||
} | ||
// lable mapping for known config values | ||
var s = [ | ||
const s = [ | ||
"defaultCachingStore", | ||
@@ -17,3 +15,3 @@ "defaultCachingTimeoutSeconds", | ||
]; | ||
var runtimeCreateHooks = []; | ||
const runtimeCreateHooks = []; | ||
export function onRuntimeCreate(hook) { | ||
@@ -26,10 +24,8 @@ if (runtimeCreateHooks.indexOf(hook) < 0) { | ||
} | ||
var Runtime = /** @class */ (function () { | ||
function Runtime(_v) { | ||
var _this = this; | ||
if (_v === void 0) { _v = new Map(); } | ||
export class Runtime { | ||
constructor(_v = new Map()) { | ||
this._v = _v; | ||
var defaulter = function (key, def) { | ||
if (!_this._v.has(key)) { | ||
_this._v.set(key, def); | ||
const defaulter = (key, def) => { | ||
if (!this._v.has(key)) { | ||
this._v.set(key, def); | ||
} | ||
@@ -45,3 +41,3 @@ }; | ||
defaulter(s[6], false); | ||
runtimeCreateHooks.forEach(function (hook) { return hook(_this); }); | ||
runtimeCreateHooks.forEach(hook => hook(this)); | ||
} | ||
@@ -52,5 +48,5 @@ /** | ||
*/ | ||
Runtime.prototype.assign = function (config) { | ||
assign(config) { | ||
this._v = mergeMaps(this._v, objectToMap(config)); | ||
}; | ||
} | ||
/** | ||
@@ -61,34 +57,21 @@ * Gets a runtime value using T to define the available keys, and R to define the type returned by that key | ||
*/ | ||
Runtime.prototype.get = function (key) { | ||
get(key) { | ||
return this._v.get(key); | ||
}; | ||
} | ||
/** | ||
* Exports the internal Map representing this runtime | ||
*/ | ||
Runtime.prototype.export = function () { | ||
var e_1, _a; | ||
var expt = new Map(); | ||
try { | ||
for (var _b = __values(this._v), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var _d = __read(_c.value, 2), key = _d[0], value = _d[1]; | ||
if (key !== "__isDefault__") { | ||
expt.set(key, value); | ||
} | ||
export() { | ||
const expt = new Map(); | ||
for (const [key, value] of this._v) { | ||
if (key !== "__isDefault__") { | ||
expt.set(key, value); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return expt; | ||
}; | ||
return Runtime; | ||
}()); | ||
export { Runtime }; | ||
} | ||
} | ||
// default runtime used globally | ||
var _runtime = new Runtime(new Map([["__isDefault__", true]])); | ||
export var DefaultRuntime = _runtime; | ||
const _runtime = new Runtime(new Map([["__isDefault__", true]])); | ||
export const DefaultRuntime = _runtime; | ||
//# sourceMappingURL=libconfig.js.map |
118
net.js
@@ -1,2 +0,2 @@ | ||
import { __awaiter, __extends, __generator } from "tslib"; | ||
import { __awaiter } from "tslib"; | ||
import { assign, objectDefinedNotNull } from "./util.js"; | ||
@@ -6,4 +6,4 @@ import { safeGlobal } from "./safe-global.js"; | ||
if (objectDefinedNotNull(source)) { | ||
var temp = new Request("", { headers: source }); | ||
temp.headers.forEach(function (value, name) { | ||
const temp = new Request("", { headers: source }); | ||
temp.headers.forEach((value, name) => { | ||
target.append(name, value); | ||
@@ -15,3 +15,3 @@ }); | ||
if (objectDefinedNotNull(source)) { | ||
var headers = assign(target.headers || {}, source.headers); | ||
const headers = assign(target.headers || {}, source.headers); | ||
target = assign(target, source); | ||
@@ -27,4 +27,4 @@ target.headers = headers; | ||
export function getADALResource(url) { | ||
var u = new URL(url); | ||
return u.protocol + "//" + u.hostname; | ||
const u = new URL(url); | ||
return `${u.protocol}//${u.hostname}`; | ||
} | ||
@@ -34,47 +34,33 @@ /** | ||
*/ | ||
var FetchClient = /** @class */ (function () { | ||
function FetchClient() { | ||
export class FetchClient { | ||
fetch(url, options) { | ||
return safeGlobal.fetch(url, options); | ||
} | ||
FetchClient.prototype.fetch = function (url, options) { | ||
return safeGlobal.fetch(url, options); | ||
}; | ||
return FetchClient; | ||
}()); | ||
export { FetchClient }; | ||
} | ||
/** | ||
* Makes requests using the fetch API adding the supplied token to the Authorization header | ||
*/ | ||
var BearerTokenFetchClient = /** @class */ (function (_super) { | ||
__extends(BearerTokenFetchClient, _super); | ||
function BearerTokenFetchClient(_token) { | ||
var _this = _super.call(this) || this; | ||
_this._token = _token; | ||
return _this; | ||
export class BearerTokenFetchClient extends FetchClient { | ||
constructor(_token) { | ||
super(); | ||
this._token = _token; | ||
} | ||
Object.defineProperty(BearerTokenFetchClient.prototype, "token", { | ||
get: function () { | ||
return this._token || ""; | ||
}, | ||
set: function (token) { | ||
this._token = token; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
BearerTokenFetchClient.prototype.fetch = function (url, options) { | ||
if (options === void 0) { options = {}; } | ||
var headers = new Headers(); | ||
get token() { | ||
return this._token || ""; | ||
} | ||
set token(token) { | ||
this._token = token; | ||
} | ||
fetch(url, options = {}) { | ||
const headers = new Headers(); | ||
mergeHeaders(headers, options.headers); | ||
headers.set("Authorization", "Bearer " + this._token); | ||
headers.set("Authorization", `Bearer ${this._token}`); | ||
options.headers = headers; | ||
return _super.prototype.fetch.call(this, url, options); | ||
}; | ||
return BearerTokenFetchClient; | ||
}(FetchClient)); | ||
export { BearerTokenFetchClient }; | ||
return super.fetch(url, options); | ||
} | ||
} | ||
/** | ||
* Client wrapping the aadTokenProvider available from SPFx >= 1.6 | ||
*/ | ||
var SPFxAdalClient = /** @class */ (function (_super) { | ||
__extends(SPFxAdalClient, _super); | ||
export class SPFxAdalClient extends BearerTokenFetchClient { | ||
/** | ||
@@ -84,6 +70,5 @@ * | ||
*/ | ||
function SPFxAdalClient(context) { | ||
var _this = _super.call(this, null) || this; | ||
_this.context = context; | ||
return _this; | ||
constructor(context) { | ||
super(null); | ||
this.context = context; | ||
} | ||
@@ -96,16 +81,12 @@ /** | ||
*/ | ||
SPFxAdalClient.prototype.fetch = function (url, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var token; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.getToken(getADALResource(url))]; | ||
case 1: | ||
token = _a.sent(); | ||
this.token = token; | ||
return [2 /*return*/, _super.prototype.fetch.call(this, url, options)]; | ||
} | ||
}); | ||
fetch(url, options) { | ||
const _super = Object.create(null, { | ||
fetch: { get: () => super.fetch } | ||
}); | ||
}; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const token = yield this.getToken(getADALResource(url)); | ||
this.token = token; | ||
return _super.fetch.call(this, url, options); | ||
}); | ||
} | ||
/** | ||
@@ -116,18 +97,9 @@ * Gets an AAD token for the provided resource using the SPFx AADTokenProvider | ||
*/ | ||
SPFxAdalClient.prototype.getToken = function (resource) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var provider; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.context.aadTokenProviderFactory.getTokenProvider()]; | ||
case 1: | ||
provider = _a.sent(); | ||
return [2 /*return*/, provider.getToken(resource)]; | ||
} | ||
}); | ||
getToken(resource) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const provider = yield this.context.aadTokenProviderFactory.getTokenProvider(); | ||
return provider.getToken(resource); | ||
}); | ||
}; | ||
return SPFxAdalClient; | ||
}(BearerTokenFetchClient)); | ||
export { SPFxAdalClient }; | ||
} | ||
} | ||
//# sourceMappingURL=net.js.map |
{ | ||
"name": "@pnp/common", | ||
"version": "2.1.0-beta8", | ||
"version": "2.1.0-beta9", | ||
"description": "pnp - provides shared functionality across all pnp libraries", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
// export either window or global | ||
export var safeGlobal = typeof global === "undefined" ? window : global; | ||
export const safeGlobal = typeof global === "undefined" ? window : global; | ||
//# sourceMappingURL=safe-global.js.map |
217
storage.js
@@ -1,2 +0,2 @@ | ||
import { __awaiter, __generator } from "tslib"; | ||
import { __awaiter } from "tslib"; | ||
import { dateAdd, getCtxCallback, jsS, objectDefinedNotNull } from "./util.js"; | ||
@@ -8,3 +8,3 @@ import { DefaultRuntime } from "./libconfig.js"; | ||
*/ | ||
var PnPClientStorageWrapper = /** @class */ (function () { | ||
export class PnPClientStorageWrapper { | ||
/** | ||
@@ -15,4 +15,3 @@ * Creates a new instance of the PnPClientStorageWrapper class | ||
*/ | ||
function PnPClientStorageWrapper(store, defaultTimeoutMinutes) { | ||
if (defaultTimeoutMinutes === void 0) { defaultTimeoutMinutes = -1; } | ||
constructor(store, defaultTimeoutMinutes = -1) { | ||
this.store = store; | ||
@@ -27,5 +26,5 @@ this.defaultTimeoutMinutes = defaultTimeoutMinutes; | ||
} | ||
PnPClientStorageWrapper.bind = function (store) { | ||
static bind(store) { | ||
return new PnPClientStorageWrapper(typeof (store) === "undefined" ? new MemoryStorage() : store); | ||
}; | ||
} | ||
/** | ||
@@ -36,11 +35,11 @@ * Get a value from storage, or null if that value does not exist | ||
*/ | ||
PnPClientStorageWrapper.prototype.get = function (key) { | ||
get(key) { | ||
if (!this.enabled) { | ||
return null; | ||
} | ||
var o = this.store.getItem(key); | ||
const o = this.store.getItem(key); | ||
if (!objectDefinedNotNull(o)) { | ||
return null; | ||
} | ||
var persistable = JSON.parse(o); | ||
const persistable = JSON.parse(o); | ||
if (new Date(persistable.expiration) <= new Date()) { | ||
@@ -53,3 +52,3 @@ this.delete(key); | ||
} | ||
}; | ||
} | ||
/** | ||
@@ -62,7 +61,7 @@ * Adds a value to the underlying storage | ||
*/ | ||
PnPClientStorageWrapper.prototype.put = function (key, o, expire) { | ||
put(key, o, expire) { | ||
if (this.enabled) { | ||
this.store.setItem(key, this.createPersistable(o, expire)); | ||
} | ||
}; | ||
} | ||
/** | ||
@@ -73,7 +72,7 @@ * Deletes a value from the underlying storage | ||
*/ | ||
PnPClientStorageWrapper.prototype.delete = function (key) { | ||
delete(key) { | ||
if (this.enabled) { | ||
this.store.removeItem(key); | ||
} | ||
}; | ||
} | ||
/** | ||
@@ -86,61 +85,40 @@ * Gets an item from the underlying storage, or adds it if it does not exist using the supplied getter function | ||
*/ | ||
PnPClientStorageWrapper.prototype.getOrPut = function (key, getter, expire) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var o; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!this.enabled) { | ||
return [2 /*return*/, getter()]; | ||
} | ||
o = this.get(key); | ||
if (!(o === null)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, getter()]; | ||
case 1: | ||
o = _a.sent(); | ||
this.put(key, o, expire); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, o]; | ||
} | ||
}); | ||
getOrPut(key, getter, expire) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.enabled) { | ||
return getter(); | ||
} | ||
let o = this.get(key); | ||
if (o === null) { | ||
o = yield getter(); | ||
this.put(key, o, expire); | ||
} | ||
return o; | ||
}); | ||
}; | ||
} | ||
/** | ||
* Deletes any expired items placed in the store by the pnp library, leaves other items untouched | ||
*/ | ||
PnPClientStorageWrapper.prototype.deleteExpired = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var i, key; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!this.enabled) { | ||
return [2 /*return*/]; | ||
} | ||
i = 0; | ||
_a.label = 1; | ||
case 1: | ||
if (!(i < this.store.length)) return [3 /*break*/, 4]; | ||
key = this.store.key(i); | ||
if (!(key !== null)) return [3 /*break*/, 3]; | ||
if (!/["|']?pnp["|']? ?: ?1/i.test(this.store.getItem(key))) return [3 /*break*/, 3]; | ||
deleteExpired() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.enabled) { | ||
return; | ||
} | ||
for (let i = 0; i < this.store.length; i++) { | ||
const key = this.store.key(i); | ||
if (key !== null) { | ||
// test the stored item to see if we stored it | ||
if (/["|']?pnp["|']? ?: ?1/i.test(this.store.getItem(key))) { | ||
// get those items as get will delete from cache if they are expired | ||
return [4 /*yield*/, this.get(key)]; | ||
case 2: | ||
// get those items as get will delete from cache if they are expired | ||
_a.sent(); | ||
_a.label = 3; | ||
case 3: | ||
i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [2 /*return*/]; | ||
yield this.get(key); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
}; | ||
} | ||
/** | ||
* Used to determine if the wrapped storage is available currently | ||
*/ | ||
PnPClientStorageWrapper.prototype.test = function () { | ||
var str = "t"; | ||
test() { | ||
const str = "t"; | ||
try { | ||
@@ -154,10 +132,10 @@ this.store.setItem(str, str); | ||
} | ||
}; | ||
} | ||
/** | ||
* Creates the persistable to store | ||
*/ | ||
PnPClientStorageWrapper.prototype.createPersistable = function (o, expire) { | ||
createPersistable(o, expire) { | ||
if (expire === undefined) { | ||
// ensure we are by default inline with the global library setting | ||
var defaultTimeout = DefaultRuntime.get("defaultCachingTimeoutSeconds"); | ||
let defaultTimeout = DefaultRuntime.get("defaultCachingTimeoutSeconds"); | ||
if (this.defaultTimeoutMinutes > 0) { | ||
@@ -169,55 +147,46 @@ defaultTimeout = this.defaultTimeoutMinutes * 60; | ||
return jsS({ pnp: 1, expiration: expire, value: o }); | ||
}; | ||
} | ||
/** | ||
* Deletes expired items added by this library in this.store and sets a timeout to call itself | ||
*/ | ||
PnPClientStorageWrapper.prototype.cacheExpirationHandler = function () { | ||
var _this = this; | ||
cacheExpirationHandler() { | ||
if (!this.enabled) { | ||
return; | ||
} | ||
this.deleteExpired().then(function (_) { | ||
this.deleteExpired().then(() => { | ||
// call ourself in the future | ||
setTimeout(getCtxCallback(_this, _this.cacheExpirationHandler), DefaultRuntime.get("cacheExpirationIntervalMilliseconds")); | ||
setTimeout(getCtxCallback(this, this.cacheExpirationHandler), DefaultRuntime.get("cacheExpirationIntervalMilliseconds")); | ||
}).catch(console.error); | ||
}; | ||
return PnPClientStorageWrapper; | ||
}()); | ||
export { PnPClientStorageWrapper }; | ||
} | ||
} | ||
/** | ||
* A thin implementation of in-memory storage for use in nodejs | ||
*/ | ||
var MemoryStorage = /** @class */ (function () { | ||
function MemoryStorage(_store) { | ||
if (_store === void 0) { _store = new Map(); } | ||
class MemoryStorage { | ||
constructor(_store = new Map()) { | ||
this._store = _store; | ||
} | ||
Object.defineProperty(MemoryStorage.prototype, "length", { | ||
get: function () { | ||
return this._store.size; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
MemoryStorage.prototype.clear = function () { | ||
get length() { | ||
return this._store.size; | ||
} | ||
clear() { | ||
this._store.clear(); | ||
}; | ||
MemoryStorage.prototype.getItem = function (key) { | ||
} | ||
getItem(key) { | ||
return this._store.get(key); | ||
}; | ||
MemoryStorage.prototype.key = function (index) { | ||
} | ||
key(index) { | ||
return Array.from(this._store)[index][0]; | ||
}; | ||
MemoryStorage.prototype.removeItem = function (key) { | ||
} | ||
removeItem(key) { | ||
this._store.delete(key); | ||
}; | ||
MemoryStorage.prototype.setItem = function (key, data) { | ||
} | ||
setItem(key, data) { | ||
this._store.set(key, data); | ||
}; | ||
return MemoryStorage; | ||
}()); | ||
} | ||
} | ||
/** | ||
* A class that will establish wrappers for both local and session storage | ||
*/ | ||
var PnPClientStorage = /** @class */ (function () { | ||
export class PnPClientStorage { | ||
/** | ||
@@ -228,37 +197,25 @@ * Creates a new instance of the PnPClientStorage class | ||
*/ | ||
function PnPClientStorage(_local, _session) { | ||
if (_local === void 0) { _local = null; } | ||
if (_session === void 0) { _session = null; } | ||
constructor(_local = null, _session = null) { | ||
this._local = _local; | ||
this._session = _session; | ||
} | ||
Object.defineProperty(PnPClientStorage.prototype, "local", { | ||
/** | ||
* Provides access to the local storage of the browser | ||
*/ | ||
get: function () { | ||
if (this._local === null) { | ||
this._local = new PnPClientStorageWrapper(typeof (localStorage) === "undefined" ? new MemoryStorage() : localStorage); | ||
} | ||
return this._local; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PnPClientStorage.prototype, "session", { | ||
/** | ||
* Provides access to the session storage of the browser | ||
*/ | ||
get: function () { | ||
if (this._session === null) { | ||
this._session = new PnPClientStorageWrapper(typeof (sessionStorage) === "undefined" ? new MemoryStorage() : sessionStorage); | ||
} | ||
return this._session; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
return PnPClientStorage; | ||
}()); | ||
export { PnPClientStorage }; | ||
/** | ||
* Provides access to the local storage of the browser | ||
*/ | ||
get local() { | ||
if (this._local === null) { | ||
this._local = new PnPClientStorageWrapper(typeof (localStorage) === "undefined" ? new MemoryStorage() : localStorage); | ||
} | ||
return this._local; | ||
} | ||
/** | ||
* Provides access to the session storage of the browser | ||
*/ | ||
get session() { | ||
if (this._session === null) { | ||
this._session = new PnPClientStorageWrapper(typeof (sessionStorage) === "undefined" ? new MemoryStorage() : sessionStorage); | ||
} | ||
return this._session; | ||
} | ||
} | ||
//# sourceMappingURL=storage.js.map |
53
util.js
@@ -9,7 +9,4 @@ /** | ||
*/ | ||
export function getCtxCallback(context, method) { | ||
var params = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
params[_i - 2] = arguments[_i]; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export function getCtxCallback(context, method, ...params) { | ||
return function () { | ||
@@ -29,3 +26,3 @@ method.apply(context, params); | ||
export function dateAdd(date, interval, units) { | ||
var ret = new Date(date.toString()); // don't change original date | ||
let ret = new Date(date.toString()); // don't change original date | ||
switch (interval.toLowerCase()) { | ||
@@ -67,10 +64,6 @@ case "year": | ||
*/ | ||
export function combine() { | ||
var paths = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
paths[_i] = arguments[_i]; | ||
} | ||
export function combine(...paths) { | ||
return paths | ||
.filter(function (path) { return !stringIsNullOrEmpty(path); }) | ||
.map(function (path) { return path.replace(/^[\\|\/]/, "").replace(/[\\|\/]$/, ""); }) | ||
.filter(path => !stringIsNullOrEmpty(path)) | ||
.map(path => path.replace(/^[\\|/]/, "").replace(/[\\|/]$/, "")) | ||
.join("/") | ||
@@ -87,4 +80,4 @@ .replace(/\\/g, "/"); | ||
export function getRandomString(chars) { | ||
var text = new Array(chars); | ||
for (var i = 0; i < chars; i++) { | ||
const text = new Array(chars); | ||
for (let i = 0; i < chars; i++) { | ||
text[i] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(Math.random() * 62)); | ||
@@ -99,7 +92,7 @@ } | ||
*/ | ||
/* tslint:disable no-bitwise */ | ||
/* eslint-disable no-bitwise */ | ||
export function getGUID() { | ||
var d = Date.now(); | ||
let d = Date.now(); | ||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { | ||
var r = (d + Math.random() * 16) % 16 | 0; | ||
const r = (d + Math.random() * 16) % 16 | 0; | ||
d = Math.floor(d / 16); | ||
@@ -109,3 +102,3 @@ return (c === "x" ? r : (r & 0x3 | 0x8)).toString(16); | ||
} | ||
/* tslint:enable */ | ||
/* eslint-enable no-bitwise */ | ||
/** | ||
@@ -141,5 +134,3 @@ * Determines if a given value is a function | ||
*/ | ||
export function assign(target, source, noOverwrite, filter) { | ||
if (noOverwrite === void 0) { noOverwrite = false; } | ||
if (filter === void 0) { filter = function () { return true; }; } | ||
export function assign(target, source, noOverwrite = false, filter = () => true) { | ||
if (!objectDefinedNotNull(source)) { | ||
@@ -149,8 +140,8 @@ return target; | ||
// ensure we don't overwrite things we don't want overwritten | ||
var check = noOverwrite ? function (o, i) { return !(i in o); } : function () { return true; }; | ||
const check = noOverwrite ? (o, i) => !(i in o) : () => true; | ||
// final filter we will use | ||
var f = function (v) { return check(target, v) && filter(v); }; | ||
const f = (v) => check(target, v) && filter(v); | ||
return Object.getOwnPropertyNames(source) | ||
.filter(f) | ||
.reduce(function (t, v) { | ||
.reduce((t, v) => { | ||
t[v] = source[v]; | ||
@@ -185,3 +176,3 @@ return t; | ||
} | ||
var matches = /([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})/i.exec(guid); | ||
const matches = /([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})/i.exec(guid); | ||
return matches === null ? guid : matches[1]; | ||
@@ -211,10 +202,10 @@ } | ||
*/ | ||
// tslint:disable:no-bitwise | ||
/* eslint-disable no-bitwise */ | ||
export function getHashCode(s) { | ||
var hash = 0; | ||
let hash = 0; | ||
if (s.length === 0) { | ||
return hash; | ||
} | ||
for (var i = 0; i < s.length; i++) { | ||
var chr = s.charCodeAt(i); | ||
for (let i = 0; i < s.length; i++) { | ||
const chr = s.charCodeAt(i); | ||
hash = ((hash << 5) - hash) + chr; | ||
@@ -225,3 +216,3 @@ hash |= 0; // Convert to 32bit integer | ||
} | ||
// tslint:enable:no-bitwise | ||
/* eslint-enable no-bitwise */ | ||
//# sourceMappingURL=util.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
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
Sorry, the diff of this file is not supported yet
62776
1037