commit 16ba9b5400e7fc9fb99c3066b28e43d762653116 Author: unknown Date: Sun Jul 18 18:11:37 2021 +0200 init diff --git a/.gh-sync.json b/.gh-sync.json new file mode 100644 index 0000000..33f0571 --- /dev/null +++ b/.gh-sync.json @@ -0,0 +1,11 @@ +{ + "debug": false, + "matching": [ + "*.json", + "*.md", + "*.yaml", + "*.csv", + "*.xls", + "*.html" + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e5b9cf2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# Logs +logs +*.log +npm-debug.log* +yarn.lock +yarn-error.log +credentials.json +gcreds.json +token.json +package-lock.json + + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..47f35aa --- /dev/null +++ b/.npmignore @@ -0,0 +1,5 @@ +datasets +gcreds.json +xcredentials.json +tests +src diff --git a/config.json b/config.json new file mode 100644 index 0000000..1c8b6c9 --- /dev/null +++ b/config.json @@ -0,0 +1,14 @@ +{ + "products_path": "../../products/products", + "fragments_path": "../../products/bazar/fragments", + "vendor_name": "Plastic Hub", + "vendor_website": "www.precious-plastic.org", + "vendor_products_external": "https://github.com/plastic-hub/products/tree/master/products/", + "vendor_instagram": "https://www.instagram.com/plastichubcat", + "vendor_youtube": "https://www.youtube.com/channel/UCuWDxJtV2pf5BefHEy09Cew/featured?view_as=subscriber", + "vendor_github": "https://github.com/plastic-hub", + "vendor_contact_email": "mailto://cgoflyn@gmail.com", + "vendor_whatsapp": "tel://0034666894789", + "vendor_facebook" : "https://precious-plastic.org/library/machines/", + "vendor_blog" : "https://precious-plastic.org/" +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..71058c6 --- /dev/null +++ b/package.json @@ -0,0 +1,112 @@ +{ + "name": "@plastichub/cli", + "version": "1.0.10", + "description": "", + "main": "./build/main.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "help": "node build/main.js --help", + "build": "tsc -p .", + "dev": "tsc -w -p ." + }, + "repository": { + "type": "git", + "url": "git+https://github.com/plastic-hub/lang.git" + }, + "author": "", + "bin": { + "ph-cli": "build/main.js" + }, + "license": "ISC", + "bugs": { + "url": "https://github.com/plastic-hub/lang/issues" + }, + "homepage": "https://github.com/plastic-hub/lang#readme", + "dependencies": { + "@plastichub/fs": "^0.13.21", + "@plastichub/osr-sync": "0.0.22", + "@types/bluebird": "^3.5.29", + "add": "^2.0.6", + "apify": "^0.17.0", + "axios": "^0.21.1", + "bluebird": "^3.7.2", + "chalk": "^2.4.1", + "cheerio": "^1.0.0-rc.3", + "chokidar": "^3.3.1", + "discourser": "^1.0.0", + "download": "^8.0.0", + "duration-timestamp": "^2.3.0", + "errlop": "^2.1.0", + "escape-html": "^1.0.3", + "fast-glob": "^3.1.1", + "filenamify": "^4.1.0", + "googleapis": "^39.2.0", + "inline-css": "^2.6.2", + "isomorphic-unfetch": "^3.0.0", + "js-beautify": "^1.11.0", + "jsome": "^2.5.0", + "json-to-pretty-yaml": "^1.2.2", + "lodash": "^4.17.10", + "markdown-table": "^2.0.0", + "moment": "^2.26.0", + "monocle-ts": "^1.2.0", + "native-promise-pool": "^3.0.0", + "ora": "^2.1.0", + "partial.lenses": "^13.13.2", + "pretty": "^2.0.0", + "puppeteer": "^5.2.1", + "ramda": "^0.25.0", + "readline": "^1.3.0", + "regexp.escape": "^1.1.0", + "sanitize-filename": "^1.6.3", + "showdown": "^1.9.1", + "simple-git": "^2.6.0", + "slash": "^3.0.0", + "slugify": "^1.4.6", + "source-map-support": "^0.5.16", + "ts-node-dev": "^1.0.0-pre.44", + "tslint": "^5.10.0", + "turndown": "^7.0.0", + "typescript": "^3.7.4", + "which": "^2.0.2", + "yargonaut": "^1.1.4", + "yargs": "^15.0.2" + }, + "devDependencies": { + "@bevry/links": "^1.1.1", + "@bevry/update-contributors": "^1.0.1", + "@types/node-fetch": "^2.5.7", + "@typescript-eslint/eslint-plugin": "^2.30.0", + "@typescript-eslint/parser": "^2.30.0", + "@types/chalk": "^2.2.0", + "@types/cheerio": "^0.22.15", + "@types/chokidar": "^2.1.3", + "@types/download": "^6.2.4", + "@types/inline-css": "0.0.32", + "@types/js-beautify": "^1.8.2", + "@types/lodash": "^4.14.110", + "@types/moment": "^2.13.0", + "@types/node": "^13.1.1", + "@types/ora": "^1.3.4", + "@types/pretty": "^2.0.0", + "@types/puppeteer": "^1.5.0", + "@types/ramda": "^0.25.51", + "@types/showdown": "^1.9.3", + "@types/which": "^1.3.2", + "@types/yargs": "^13.0.4", + "@xblox/core": "^0.0.19", + "assert-helpers": "^6.1.0", + "eslint": "^6.8.0", + "eslint-config-bevry": "^3.3.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-prettier": "^3.1.3", + "jsdom": "^16.2.2", + "kava": "^4.4.0", + "prettier": "^2.0.5", + "projectz": "^1.19.1", + "surge": "^0.21.3", + "typedoc": "^0.17.6", + "valid-directory": "^1.6.0", + "valid-module": "^1.0.0" + } +} diff --git a/src/_cli.ts b/src/_cli.ts new file mode 100644 index 0000000..07eda1d --- /dev/null +++ b/src/_cli.ts @@ -0,0 +1,13 @@ +// tweaks and handlers +export const defaults = () => { + // default command + const DefaultCommand = 'summary'; + if (process.argv.length === 2) { + process.argv.push(DefaultCommand); + } + + // currently no default handler, display only : + process.on('unhandledRejection', (reason: string) => { + console.error('Unhandled rejection, reason: ', reason); + }); +}; \ No newline at end of file diff --git a/src/api.ts b/src/api.ts new file mode 100644 index 0000000..4cfd4d7 --- /dev/null +++ b/src/api.ts @@ -0,0 +1,9346 @@ +/** + * Magento Community + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 2.4 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import localVarRequest = require('request'); +import http = require('http'); +import Promise = require('bluebird'); + +let defaultBasePath = 'https://shop.plastic-hub.com/rest/all'; + +// =============================================== +// This file is autogenerated - Please do not edit +// =============================================== + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +class ObjectSerializer { + + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap[expectedType]) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + return data[discriminatorProperty]; // use the type given in the discriminator + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.serialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return data.toString(); + } else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + } + + public static deserialize(data: any, type: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index in data) { + let date = data[index]; + transformedData.push(ObjectSerializer.deserialize(date, subType)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap[type]) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index in attributeTypes) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + } +} + +/** +* +*/ +export class AmazonPaymentDataQuoteLinkInterface { + 'id': string; + /** + * Amazon order reference id + */ + 'amazonOrderReferenceId': string; + /** + * Quote id + */ + 'quoteId': number; + /** + * Sandbox simulation reference + */ + 'sandboxSimulationReference': string; + /** + * Quote confirmed with amazon + */ + 'confirmed': boolean; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "string" + }, + { + "name": "amazonOrderReferenceId", + "baseName": "amazon_order_reference_id", + "type": "string" + }, + { + "name": "quoteId", + "baseName": "quote_id", + "type": "number" + }, + { + "name": "sandboxSimulationReference", + "baseName": "sandbox_simulation_reference", + "type": "string" + }, + { + "name": "confirmed", + "baseName": "confirmed", + "type": "boolean" + } ]; + + static getAttributeTypeMap() { + return AmazonPaymentDataQuoteLinkInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Bundle\\Api\\Data\\BundleOptionInterface +*/ +export class BundleDataBundleOptionExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return BundleDataBundleOptionExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface BundleOptionInterface +*/ +export class BundleDataBundleOptionInterface { + /** + * Bundle option id. + */ + 'optionId': number; + /** + * Bundle option quantity. + */ + 'optionQty': number; + /** + * Bundle option selection ids. + */ + 'optionSelections': Array; + 'extensionAttributes'?: BundleDataBundleOptionExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "optionId", + "baseName": "option_id", + "type": "number" + }, + { + "name": "optionQty", + "baseName": "option_qty", + "type": "number" + }, + { + "name": "optionSelections", + "baseName": "option_selections", + "type": "Array" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "BundleDataBundleOptionExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return BundleDataBundleOptionInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Catalog\\Api\\Data\\CustomOptionInterface +*/ +export class CatalogDataCustomOptionExtensionInterface { + 'fileInfo'?: FrameworkDataImageContentInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "fileInfo", + "baseName": "file_info", + "type": "FrameworkDataImageContentInterface" + } ]; + + static getAttributeTypeMap() { + return CatalogDataCustomOptionExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface CustomOptionInterface +*/ +export class CatalogDataCustomOptionInterface { + /** + * Option id + */ + 'optionId': string; + /** + * Option value + */ + 'optionValue': string; + 'extensionAttributes'?: CatalogDataCustomOptionExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "optionId", + "baseName": "option_id", + "type": "string" + }, + { + "name": "optionValue", + "baseName": "option_value", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CatalogDataCustomOptionExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return CatalogDataCustomOptionInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Catalog\\Api\\Data\\ProductRender\\ButtonInterface +*/ +export class CatalogDataProductRenderButtonExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderButtonExtensionInterface.attributeTypeMap; + } +} + +/** +* Button interface. This interface represents all manner of product buttons: add to cart, add to compare, etc... The buttons describes by this interface should have interaction with backend +*/ +export class CatalogDataProductRenderButtonInterface { + /** + * Post data + */ + 'postData': string; + /** + * Url, needed to add product to cart + */ + 'url': string; + /** + * Flag whether a product has options or not + */ + 'requiredOptions': boolean; + 'extensionAttributes'?: CatalogDataProductRenderButtonExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "postData", + "baseName": "post_data", + "type": "string" + }, + { + "name": "url", + "baseName": "url", + "type": "string" + }, + { + "name": "requiredOptions", + "baseName": "required_options", + "type": "boolean" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CatalogDataProductRenderButtonExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderButtonInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Catalog\\Api\\Data\\ProductRenderInterface +*/ +export class CatalogDataProductRenderExtensionInterface { + 'reviewHtml'?: string; + 'wishlistButton'?: CatalogDataProductRenderButtonInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "reviewHtml", + "baseName": "review_html", + "type": "string" + }, + { + "name": "wishlistButton", + "baseName": "wishlist_button", + "type": "CatalogDataProductRenderButtonInterface" + } ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderExtensionInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Catalog\\Api\\Data\\ProductRender\\FormattedPriceInfoInterface +*/ +export class CatalogDataProductRenderFormattedPriceInfoExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderFormattedPriceInfoExtensionInterface.attributeTypeMap; + } +} + +/** +* Formatted Price interface. Aggregate formatted html with price representations. E.g.: $9.00 Consider currency, rounding and html +*/ +export class CatalogDataProductRenderFormattedPriceInfoInterface { + /** + * Html with final price + */ + 'finalPrice': string; + /** + * Max price of a product + */ + 'maxPrice': string; + /** + * The minimal price of the product or variation + */ + 'minimalPrice': string; + /** + * Max regular price + */ + 'maxRegularPrice': string; + /** + * Minimal regular price + */ + 'minimalRegularPrice': string; + /** + * Special price + */ + 'specialPrice': string; + /** + * Price - is price of product without discounts and special price with taxes and fixed product tax + */ + 'regularPrice': string; + 'extensionAttributes'?: CatalogDataProductRenderFormattedPriceInfoExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "finalPrice", + "baseName": "final_price", + "type": "string" + }, + { + "name": "maxPrice", + "baseName": "max_price", + "type": "string" + }, + { + "name": "minimalPrice", + "baseName": "minimal_price", + "type": "string" + }, + { + "name": "maxRegularPrice", + "baseName": "max_regular_price", + "type": "string" + }, + { + "name": "minimalRegularPrice", + "baseName": "minimal_regular_price", + "type": "string" + }, + { + "name": "specialPrice", + "baseName": "special_price", + "type": "string" + }, + { + "name": "regularPrice", + "baseName": "regular_price", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CatalogDataProductRenderFormattedPriceInfoExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderFormattedPriceInfoInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Catalog\\Api\\Data\\ProductRender\\ImageInterface +*/ +export class CatalogDataProductRenderImageExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderImageExtensionInterface.attributeTypeMap; + } +} + +/** +* Product Render image interface. Represents physical characteristics of image, that can be used in product listing or product view +*/ +export class CatalogDataProductRenderImageInterface { + /** + * Image url + */ + 'url': string; + /** + * Image code + */ + 'code': string; + /** + * Image height + */ + 'height': number; + /** + * Image width in px + */ + 'width': number; + /** + * Image label + */ + 'label': string; + /** + * Resize width + */ + 'resizedWidth': number; + /** + * Resize height + */ + 'resizedHeight': number; + 'extensionAttributes'?: CatalogDataProductRenderImageExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "url", + "baseName": "url", + "type": "string" + }, + { + "name": "code", + "baseName": "code", + "type": "string" + }, + { + "name": "height", + "baseName": "height", + "type": "number" + }, + { + "name": "width", + "baseName": "width", + "type": "number" + }, + { + "name": "label", + "baseName": "label", + "type": "string" + }, + { + "name": "resizedWidth", + "baseName": "resized_width", + "type": "number" + }, + { + "name": "resizedHeight", + "baseName": "resized_height", + "type": "number" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CatalogDataProductRenderImageExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderImageInterface.attributeTypeMap; + } +} + +/** +* Represents Data Object which holds enough information to render product This information is put into part as Add To Cart or Add to Compare Data or Price Data +*/ +export class CatalogDataProductRenderInterface { + 'addToCartButton': CatalogDataProductRenderButtonInterface; + 'addToCompareButton': CatalogDataProductRenderButtonInterface; + 'priceInfo': CatalogDataProductRenderPriceInfoInterface; + /** + * Enough information, that needed to render image on front + */ + 'images': Array; + /** + * Product url + */ + 'url': string; + /** + * Product identifier + */ + 'id': number; + /** + * Product name + */ + 'name': string; + /** + * Product type. Such as bundle, grouped, simple, etc... + */ + 'type': string; + /** + * Information about product saleability (In Stock) + */ + 'isSalable': string; + /** + * Information about current store id or requested store id + */ + 'storeId': number; + /** + * Current or desired currency code to product + */ + 'currencyCode': string; + 'extensionAttributes': CatalogDataProductRenderExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "addToCartButton", + "baseName": "add_to_cart_button", + "type": "CatalogDataProductRenderButtonInterface" + }, + { + "name": "addToCompareButton", + "baseName": "add_to_compare_button", + "type": "CatalogDataProductRenderButtonInterface" + }, + { + "name": "priceInfo", + "baseName": "price_info", + "type": "CatalogDataProductRenderPriceInfoInterface" + }, + { + "name": "images", + "baseName": "images", + "type": "Array" + }, + { + "name": "url", + "baseName": "url", + "type": "string" + }, + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "type", + "baseName": "type", + "type": "string" + }, + { + "name": "isSalable", + "baseName": "is_salable", + "type": "string" + }, + { + "name": "storeId", + "baseName": "store_id", + "type": "number" + }, + { + "name": "currencyCode", + "baseName": "currency_code", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CatalogDataProductRenderExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Catalog\\Api\\Data\\ProductRender\\PriceInfoInterface +*/ +export class CatalogDataProductRenderPriceInfoExtensionInterface { + 'msrp'?: MsrpDataProductRenderMsrpPriceInfoInterface; + 'taxAdjustments'?: CatalogDataProductRenderPriceInfoInterface; + 'weeeAttributes'?: Array; + 'weeeAdjustment'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "msrp", + "baseName": "msrp", + "type": "MsrpDataProductRenderMsrpPriceInfoInterface" + }, + { + "name": "taxAdjustments", + "baseName": "tax_adjustments", + "type": "CatalogDataProductRenderPriceInfoInterface" + }, + { + "name": "weeeAttributes", + "baseName": "weee_attributes", + "type": "Array" + }, + { + "name": "weeeAdjustment", + "baseName": "weee_adjustment", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderPriceInfoExtensionInterface.attributeTypeMap; + } +} + +/** +* Price interface. +*/ +export class CatalogDataProductRenderPriceInfoInterface { + /** + * Final price + */ + 'finalPrice': number; + /** + * Max price of a product + */ + 'maxPrice': number; + /** + * Max regular price + */ + 'maxRegularPrice': number; + /** + * Minimal regular price + */ + 'minimalRegularPrice': number; + /** + * Special price + */ + 'specialPrice': number; + /** + * Minimal price + */ + 'minimalPrice': number; + /** + * Regular price + */ + 'regularPrice': number; + 'formattedPrices': CatalogDataProductRenderFormattedPriceInfoInterface; + 'extensionAttributes'?: CatalogDataProductRenderPriceInfoExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "finalPrice", + "baseName": "final_price", + "type": "number" + }, + { + "name": "maxPrice", + "baseName": "max_price", + "type": "number" + }, + { + "name": "maxRegularPrice", + "baseName": "max_regular_price", + "type": "number" + }, + { + "name": "minimalRegularPrice", + "baseName": "minimal_regular_price", + "type": "number" + }, + { + "name": "specialPrice", + "baseName": "special_price", + "type": "number" + }, + { + "name": "minimalPrice", + "baseName": "minimal_price", + "type": "number" + }, + { + "name": "regularPrice", + "baseName": "regular_price", + "type": "number" + }, + { + "name": "formattedPrices", + "baseName": "formatted_prices", + "type": "CatalogDataProductRenderFormattedPriceInfoInterface" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CatalogDataProductRenderPriceInfoExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderPriceInfoInterface.attributeTypeMap; + } +} + +/** +* Dto that holds render information about products +*/ +export class CatalogDataProductRenderSearchResultsInterface { + /** + * List of products rendered information + */ + 'items': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "items", + "baseName": "items", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return CatalogDataProductRenderSearchResultsInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Checkout\\Api\\Data\\PaymentDetailsInterface +*/ +export class CheckoutDataPaymentDetailsExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return CheckoutDataPaymentDetailsExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface PaymentDetailsInterface +*/ +export class CheckoutDataPaymentDetailsInterface { + 'paymentMethods': Array; + 'totals': QuoteDataTotalsInterface; + 'extensionAttributes'?: CheckoutDataPaymentDetailsExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "paymentMethods", + "baseName": "payment_methods", + "type": "Array" + }, + { + "name": "totals", + "baseName": "totals", + "type": "QuoteDataTotalsInterface" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CheckoutDataPaymentDetailsExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return CheckoutDataPaymentDetailsInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Checkout\\Api\\Data\\ShippingInformationInterface +*/ +export class CheckoutDataShippingInformationExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return CheckoutDataShippingInformationExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface ShippingInformationInterface +*/ +export class CheckoutDataShippingInformationInterface { + 'shippingAddress': QuoteDataAddressInterface; + 'billingAddress'?: QuoteDataAddressInterface; + /** + * Shipping method code + */ + 'shippingMethodCode': string; + /** + * Carrier code + */ + 'shippingCarrierCode': string; + 'extensionAttributes'?: CheckoutDataShippingInformationExtensionInterface; + /** + * Custom attributes values. + */ + 'customAttributes'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "shippingAddress", + "baseName": "shipping_address", + "type": "QuoteDataAddressInterface" + }, + { + "name": "billingAddress", + "baseName": "billing_address", + "type": "QuoteDataAddressInterface" + }, + { + "name": "shippingMethodCode", + "baseName": "shipping_method_code", + "type": "string" + }, + { + "name": "shippingCarrierCode", + "baseName": "shipping_carrier_code", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CheckoutDataShippingInformationExtensionInterface" + }, + { + "name": "customAttributes", + "baseName": "custom_attributes", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return CheckoutDataShippingInformationInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Checkout\\Api\\Data\\TotalsInformationInterface +*/ +export class CheckoutDataTotalsInformationExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return CheckoutDataTotalsInformationExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface TotalsInformationInterface +*/ +export class CheckoutDataTotalsInformationInterface { + 'address': QuoteDataAddressInterface; + /** + * Shipping method code + */ + 'shippingMethodCode'?: string; + /** + * Carrier code + */ + 'shippingCarrierCode'?: string; + 'extensionAttributes'?: CheckoutDataTotalsInformationExtensionInterface; + /** + * Custom attributes values. + */ + 'customAttributes'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "address", + "baseName": "address", + "type": "QuoteDataAddressInterface" + }, + { + "name": "shippingMethodCode", + "baseName": "shipping_method_code", + "type": "string" + }, + { + "name": "shippingCarrierCode", + "baseName": "shipping_carrier_code", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CheckoutDataTotalsInformationExtensionInterface" + }, + { + "name": "customAttributes", + "baseName": "custom_attributes", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return CheckoutDataTotalsInformationInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\ConfigurableProduct\\Api\\Data\\ConfigurableItemOptionValueInterface +*/ +export class ConfigurableProductDataConfigurableItemOptionValueExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return ConfigurableProductDataConfigurableItemOptionValueExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface ConfigurableItemOptionValueInterface +*/ +export class ConfigurableProductDataConfigurableItemOptionValueInterface { + /** + * Option SKU + */ + 'optionId': string; + /** + * Item id + */ + 'optionValue'?: number; + 'extensionAttributes'?: ConfigurableProductDataConfigurableItemOptionValueExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "optionId", + "baseName": "option_id", + "type": "string" + }, + { + "name": "optionValue", + "baseName": "option_value", + "type": "number" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "ConfigurableProductDataConfigurableItemOptionValueExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return ConfigurableProductDataConfigurableItemOptionValueInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Customer\\Api\\Data\\AddressInterface +*/ +export class CustomerDataAddressExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return CustomerDataAddressExtensionInterface.attributeTypeMap; + } +} + +/** +* Customer address interface. +*/ +export class CustomerDataAddressInterface { + /** + * ID + */ + 'id'?: number; + /** + * Customer ID + */ + 'customerId'?: number; + 'region'?: CustomerDataRegionInterface; + /** + * Region ID + */ + 'regionId'?: number; + /** + * Country code in ISO_3166-2 format + */ + 'countryId'?: string; + /** + * Street + */ + 'street'?: Array; + /** + * Company + */ + 'company'?: string; + /** + * Telephone number + */ + 'telephone'?: string; + /** + * Fax number + */ + 'fax'?: string; + /** + * Postcode + */ + 'postcode'?: string; + /** + * City name + */ + 'city'?: string; + /** + * First name + */ + 'firstname'?: string; + /** + * Last name + */ + 'lastname'?: string; + /** + * Middle name + */ + 'middlename'?: string; + /** + * Prefix + */ + 'prefix'?: string; + /** + * Suffix + */ + 'suffix'?: string; + /** + * Vat id + */ + 'vatId'?: string; + /** + * If this address is default shipping address. + */ + 'defaultShipping'?: boolean; + /** + * If this address is default billing address + */ + 'defaultBilling'?: boolean; + 'extensionAttributes'?: CustomerDataAddressExtensionInterface; + /** + * Custom attributes values. + */ + 'customAttributes'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "customerId", + "baseName": "customer_id", + "type": "number" + }, + { + "name": "region", + "baseName": "region", + "type": "CustomerDataRegionInterface" + }, + { + "name": "regionId", + "baseName": "region_id", + "type": "number" + }, + { + "name": "countryId", + "baseName": "country_id", + "type": "string" + }, + { + "name": "street", + "baseName": "street", + "type": "Array" + }, + { + "name": "company", + "baseName": "company", + "type": "string" + }, + { + "name": "telephone", + "baseName": "telephone", + "type": "string" + }, + { + "name": "fax", + "baseName": "fax", + "type": "string" + }, + { + "name": "postcode", + "baseName": "postcode", + "type": "string" + }, + { + "name": "city", + "baseName": "city", + "type": "string" + }, + { + "name": "firstname", + "baseName": "firstname", + "type": "string" + }, + { + "name": "lastname", + "baseName": "lastname", + "type": "string" + }, + { + "name": "middlename", + "baseName": "middlename", + "type": "string" + }, + { + "name": "prefix", + "baseName": "prefix", + "type": "string" + }, + { + "name": "suffix", + "baseName": "suffix", + "type": "string" + }, + { + "name": "vatId", + "baseName": "vat_id", + "type": "string" + }, + { + "name": "defaultShipping", + "baseName": "default_shipping", + "type": "boolean" + }, + { + "name": "defaultBilling", + "baseName": "default_billing", + "type": "boolean" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CustomerDataAddressExtensionInterface" + }, + { + "name": "customAttributes", + "baseName": "custom_attributes", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return CustomerDataAddressInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Customer\\Api\\Data\\CustomerInterface +*/ +export class CustomerDataCustomerExtensionInterface { + 'assistanceAllowed'?: number; + 'isSubscribed'?: boolean; + 'amazonId'?: string; + 'vertexCustomerCode'?: string; + 'vertexCustomerCountry'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "assistanceAllowed", + "baseName": "assistance_allowed", + "type": "number" + }, + { + "name": "isSubscribed", + "baseName": "is_subscribed", + "type": "boolean" + }, + { + "name": "amazonId", + "baseName": "amazon_id", + "type": "string" + }, + { + "name": "vertexCustomerCode", + "baseName": "vertex_customer_code", + "type": "string" + }, + { + "name": "vertexCustomerCountry", + "baseName": "vertex_customer_country", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return CustomerDataCustomerExtensionInterface.attributeTypeMap; + } +} + +/** +* Customer interface. +*/ +export class CustomerDataCustomerInterface { + /** + * Customer id + */ + 'id'?: number; + /** + * Group id + */ + 'groupId'?: number; + /** + * Default billing address id + */ + 'defaultBilling'?: string; + /** + * Default shipping address id + */ + 'defaultShipping'?: string; + /** + * Confirmation + */ + 'confirmation'?: string; + /** + * Created at time + */ + 'createdAt'?: string; + /** + * Updated at time + */ + 'updatedAt'?: string; + /** + * Created in area + */ + 'createdIn'?: string; + /** + * Date of birth + */ + 'dob'?: string; + /** + * Email address + */ + 'email': string; + /** + * First name + */ + 'firstname': string; + /** + * Last name + */ + 'lastname': string; + /** + * Middle name + */ + 'middlename'?: string; + /** + * Prefix + */ + 'prefix'?: string; + /** + * Suffix + */ + 'suffix'?: string; + /** + * Gender + */ + 'gender'?: number; + /** + * Store id + */ + 'storeId'?: number; + /** + * Tax Vat + */ + 'taxvat'?: string; + /** + * Website id + */ + 'websiteId'?: number; + /** + * Customer addresses. + */ + 'addresses'?: Array; + /** + * Disable auto group change flag. + */ + 'disableAutoGroupChange'?: number; + 'extensionAttributes'?: CustomerDataCustomerExtensionInterface; + /** + * Custom attributes values. + */ + 'customAttributes'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "groupId", + "baseName": "group_id", + "type": "number" + }, + { + "name": "defaultBilling", + "baseName": "default_billing", + "type": "string" + }, + { + "name": "defaultShipping", + "baseName": "default_shipping", + "type": "string" + }, + { + "name": "confirmation", + "baseName": "confirmation", + "type": "string" + }, + { + "name": "createdAt", + "baseName": "created_at", + "type": "string" + }, + { + "name": "updatedAt", + "baseName": "updated_at", + "type": "string" + }, + { + "name": "createdIn", + "baseName": "created_in", + "type": "string" + }, + { + "name": "dob", + "baseName": "dob", + "type": "string" + }, + { + "name": "email", + "baseName": "email", + "type": "string" + }, + { + "name": "firstname", + "baseName": "firstname", + "type": "string" + }, + { + "name": "lastname", + "baseName": "lastname", + "type": "string" + }, + { + "name": "middlename", + "baseName": "middlename", + "type": "string" + }, + { + "name": "prefix", + "baseName": "prefix", + "type": "string" + }, + { + "name": "suffix", + "baseName": "suffix", + "type": "string" + }, + { + "name": "gender", + "baseName": "gender", + "type": "number" + }, + { + "name": "storeId", + "baseName": "store_id", + "type": "number" + }, + { + "name": "taxvat", + "baseName": "taxvat", + "type": "string" + }, + { + "name": "websiteId", + "baseName": "website_id", + "type": "number" + }, + { + "name": "addresses", + "baseName": "addresses", + "type": "Array" + }, + { + "name": "disableAutoGroupChange", + "baseName": "disable_auto_group_change", + "type": "number" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CustomerDataCustomerExtensionInterface" + }, + { + "name": "customAttributes", + "baseName": "custom_attributes", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return CustomerDataCustomerInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Customer\\Api\\Data\\RegionInterface +*/ +export class CustomerDataRegionExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return CustomerDataRegionExtensionInterface.attributeTypeMap; + } +} + +/** +* Customer address region interface. +*/ +export class CustomerDataRegionInterface { + /** + * Region code + */ + 'regionCode': string; + /** + * Region + */ + 'region': string; + /** + * Region id + */ + 'regionId': number; + 'extensionAttributes'?: CustomerDataRegionExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "regionCode", + "baseName": "region_code", + "type": "string" + }, + { + "name": "region", + "baseName": "region", + "type": "string" + }, + { + "name": "regionId", + "baseName": "region_id", + "type": "number" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "CustomerDataRegionExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return CustomerDataRegionInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Directory\\Api\\Data\\CountryInformationInterface +*/ +export class DirectoryDataCountryInformationExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return DirectoryDataCountryInformationExtensionInterface.attributeTypeMap; + } +} + +/** +* Country Information interface. +*/ +export class DirectoryDataCountryInformationInterface { + /** + * The country id for the store. + */ + 'id': string; + /** + * The country 2 letter abbreviation for the store. + */ + 'twoLetterAbbreviation': string; + /** + * The country 3 letter abbreviation for the store. + */ + 'threeLetterAbbreviation': string; + /** + * The country full name (in store locale) for the store. + */ + 'fullNameLocale': string; + /** + * The country full name (in English) for the store. + */ + 'fullNameEnglish': string; + /** + * The available regions for the store. + */ + 'availableRegions'?: Array; + 'extensionAttributes'?: DirectoryDataCountryInformationExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "string" + }, + { + "name": "twoLetterAbbreviation", + "baseName": "two_letter_abbreviation", + "type": "string" + }, + { + "name": "threeLetterAbbreviation", + "baseName": "three_letter_abbreviation", + "type": "string" + }, + { + "name": "fullNameLocale", + "baseName": "full_name_locale", + "type": "string" + }, + { + "name": "fullNameEnglish", + "baseName": "full_name_english", + "type": "string" + }, + { + "name": "availableRegions", + "baseName": "available_regions", + "type": "Array" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "DirectoryDataCountryInformationExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return DirectoryDataCountryInformationInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Directory\\Api\\Data\\CurrencyInformationInterface +*/ +export class DirectoryDataCurrencyInformationExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return DirectoryDataCurrencyInformationExtensionInterface.attributeTypeMap; + } +} + +/** +* Currency Information interface. +*/ +export class DirectoryDataCurrencyInformationInterface { + /** + * The base currency code for the store. + */ + 'baseCurrencyCode': string; + /** + * The currency symbol of the base currency for the store. + */ + 'baseCurrencySymbol': string; + /** + * The default display currency code for the store. + */ + 'defaultDisplayCurrencyCode': string; + /** + * The currency symbol of the default display currency for the store. + */ + 'defaultDisplayCurrencySymbol': string; + /** + * The list of allowed currency codes for the store. + */ + 'availableCurrencyCodes': Array; + /** + * The list of exchange rate information for the store. + */ + 'exchangeRates': Array; + 'extensionAttributes'?: DirectoryDataCurrencyInformationExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "baseCurrencyCode", + "baseName": "base_currency_code", + "type": "string" + }, + { + "name": "baseCurrencySymbol", + "baseName": "base_currency_symbol", + "type": "string" + }, + { + "name": "defaultDisplayCurrencyCode", + "baseName": "default_display_currency_code", + "type": "string" + }, + { + "name": "defaultDisplayCurrencySymbol", + "baseName": "default_display_currency_symbol", + "type": "string" + }, + { + "name": "availableCurrencyCodes", + "baseName": "available_currency_codes", + "type": "Array" + }, + { + "name": "exchangeRates", + "baseName": "exchange_rates", + "type": "Array" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "DirectoryDataCurrencyInformationExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return DirectoryDataCurrencyInformationInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Directory\\Api\\Data\\ExchangeRateInterface +*/ +export class DirectoryDataExchangeRateExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return DirectoryDataExchangeRateExtensionInterface.attributeTypeMap; + } +} + +/** +* Exchange Rate interface. +*/ +export class DirectoryDataExchangeRateInterface { + /** + * The currency code associated with the exchange rate. + */ + 'currencyTo': string; + /** + * The exchange rate for the associated currency and the store's base currency. + */ + 'rate': number; + 'extensionAttributes'?: DirectoryDataExchangeRateExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "currencyTo", + "baseName": "currency_to", + "type": "string" + }, + { + "name": "rate", + "baseName": "rate", + "type": "number" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "DirectoryDataExchangeRateExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return DirectoryDataExchangeRateInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Directory\\Api\\Data\\RegionInformationInterface +*/ +export class DirectoryDataRegionInformationExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return DirectoryDataRegionInformationExtensionInterface.attributeTypeMap; + } +} + +/** +* Region Information interface. +*/ +export class DirectoryDataRegionInformationInterface { + /** + * Region id + */ + 'id': string; + /** + * Region code + */ + 'code': string; + /** + * Region name + */ + 'name': string; + 'extensionAttributes'?: DirectoryDataRegionInformationExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "string" + }, + { + "name": "code", + "baseName": "code", + "type": "string" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "DirectoryDataRegionInformationExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return DirectoryDataRegionInformationInterface.attributeTypeMap; + } +} + +/** +* Downloadable Option +*/ +export class DownloadableDataDownloadableOptionInterface { + /** + * The list of downloadable links + */ + 'downloadableLinks': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "downloadableLinks", + "baseName": "downloadable_links", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return DownloadableDataDownloadableOptionInterface.attributeTypeMap; + } +} + +/** +* Errors list +*/ +export class ErrorErrors extends Array { + + static discriminator: string | undefined = undefined; + +} + +/** +* Error details +*/ +export class ErrorErrorsItem { + /** + * Error message + */ + 'message'?: string; + 'parameters'?: ErrorParameters; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "message", + "baseName": "message", + "type": "string" + }, + { + "name": "parameters", + "baseName": "parameters", + "type": "ErrorParameters" + } ]; + + static getAttributeTypeMap() { + return ErrorErrorsItem.attributeTypeMap; + } +} + +/** +* Error parameters list +*/ +export class ErrorParameters extends Array { + + static discriminator: string | undefined = undefined; + +} + +/** +* Error parameters item +*/ +export class ErrorParametersItem { + /** + * ACL resource + */ + 'resources'?: string; + /** + * Missing or invalid field name + */ + 'fieldName'?: string; + /** + * Incorrect field value + */ + 'fieldValue'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "resources", + "baseName": "resources", + "type": "string" + }, + { + "name": "fieldName", + "baseName": "fieldName", + "type": "string" + }, + { + "name": "fieldValue", + "baseName": "fieldValue", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return ErrorParametersItem.attributeTypeMap; + } +} + +export class ErrorResponse { + /** + * Error message + */ + 'message': string; + 'errors'?: ErrorErrors; + /** + * Error code + */ + 'code'?: number; + 'parameters'?: ErrorParameters; + /** + * Stack trace + */ + 'trace'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "message", + "baseName": "message", + "type": "string" + }, + { + "name": "errors", + "baseName": "errors", + "type": "ErrorErrors" + }, + { + "name": "code", + "baseName": "code", + "type": "number" + }, + { + "name": "parameters", + "baseName": "parameters", + "type": "ErrorParameters" + }, + { + "name": "trace", + "baseName": "trace", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return ErrorResponse.attributeTypeMap; + } +} + +/** +* Interface for custom attribute value. +*/ +export class FrameworkAttributeInterface { + /** + * Attribute code + */ + 'attributeCode': string; + /** + * Attribute value + */ + 'value': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "attributeCode", + "baseName": "attribute_code", + "type": "string" + }, + { + "name": "value", + "baseName": "value", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return FrameworkAttributeInterface.attributeTypeMap; + } +} + +/** +* Image Content data interface +*/ +export class FrameworkDataImageContentInterface { + /** + * Media data (base64 encoded content) + */ + 'base64EncodedData': string; + /** + * MIME type + */ + 'type': string; + /** + * Image name + */ + 'name': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "base64EncodedData", + "baseName": "base64_encoded_data", + "type": "string" + }, + { + "name": "type", + "baseName": "type", + "type": "string" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return FrameworkDataImageContentInterface.attributeTypeMap; + } +} + +/** +* Filter which can be used by any methods from service layer. +*/ +export class FrameworkFilter { + /** + * Field + */ + 'field': string; + /** + * Value + */ + 'value': string; + /** + * Condition type + */ + 'conditionType'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "field", + "baseName": "field", + "type": "string" + }, + { + "name": "value", + "baseName": "value", + "type": "string" + }, + { + "name": "conditionType", + "baseName": "condition_type", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return FrameworkFilter.attributeTypeMap; + } +} + +/** +* Faceted data +*/ +export class FrameworkSearchAggregationInterface { + /** + * All Document fields + */ + 'buckets': Array; + /** + * Document field names + */ + 'bucketNames': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "buckets", + "baseName": "buckets", + "type": "Array" + }, + { + "name": "bucketNames", + "baseName": "bucket_names", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return FrameworkSearchAggregationInterface.attributeTypeMap; + } +} + +/** +* Interface \\Magento\\Framework\\Api\\Search\\AggregationValueInterface +*/ +export class FrameworkSearchAggregationValueInterface { + /** + * Aggregation + */ + 'value': string; + /** + * Metrics + */ + 'metrics': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "value", + "baseName": "value", + "type": "string" + }, + { + "name": "metrics", + "baseName": "metrics", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return FrameworkSearchAggregationValueInterface.attributeTypeMap; + } +} + +/** +* Facet Bucket +*/ +export class FrameworkSearchBucketInterface { + /** + * Field name + */ + 'name': string; + /** + * Field values + */ + 'values': Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "values", + "baseName": "values", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return FrameworkSearchBucketInterface.attributeTypeMap; + } +} + +/** +* Interface \\Magento\\Framework\\Api\\Search\\DocumentInterface +*/ +export class FrameworkSearchDocumentInterface { + 'id': number; + /** + * Custom attributes values. + */ + 'customAttributes'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "customAttributes", + "baseName": "custom_attributes", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return FrameworkSearchDocumentInterface.attributeTypeMap; + } +} + +/** +* Groups two or more filters together using a logical OR +*/ +export class FrameworkSearchFilterGroup { + /** + * A list of filters in this group + */ + 'filters'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "filters", + "baseName": "filters", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return FrameworkSearchFilterGroup.attributeTypeMap; + } +} + +/** +* Interface SearchCriteriaInterface +*/ +export class FrameworkSearchSearchCriteriaInterface { + 'requestName': string; + /** + * A list of filter groups. + */ + 'filterGroups': Array; + /** + * Sort order. + */ + 'sortOrders'?: Array; + /** + * Page size. + */ + 'pageSize'?: number; + /** + * Current page. + */ + 'currentPage'?: number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "requestName", + "baseName": "request_name", + "type": "string" + }, + { + "name": "filterGroups", + "baseName": "filter_groups", + "type": "Array" + }, + { + "name": "sortOrders", + "baseName": "sort_orders", + "type": "Array" + }, + { + "name": "pageSize", + "baseName": "page_size", + "type": "number" + }, + { + "name": "currentPage", + "baseName": "current_page", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return FrameworkSearchSearchCriteriaInterface.attributeTypeMap; + } +} + +/** +* Interface SearchResultInterface +*/ +export class FrameworkSearchSearchResultInterface { + 'items': Array; + 'aggregations': FrameworkSearchAggregationInterface; + 'searchCriteria': FrameworkSearchSearchCriteriaInterface; + /** + * Total count. + */ + 'totalCount': number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "items", + "baseName": "items", + "type": "Array" + }, + { + "name": "aggregations", + "baseName": "aggregations", + "type": "FrameworkSearchAggregationInterface" + }, + { + "name": "searchCriteria", + "baseName": "search_criteria", + "type": "FrameworkSearchSearchCriteriaInterface" + }, + { + "name": "totalCount", + "baseName": "total_count", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return FrameworkSearchSearchResultInterface.attributeTypeMap; + } +} + +/** +* Data object for sort order. +*/ +export class FrameworkSortOrder { + /** + * Sorting field. + */ + 'field': string; + /** + * Sorting direction. + */ + 'direction': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "field", + "baseName": "field", + "type": "string" + }, + { + "name": "direction", + "baseName": "direction", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return FrameworkSortOrder.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\GiftMessage\\Api\\Data\\MessageInterface +*/ +export class GiftMessageDataMessageExtensionInterface { + 'entityId'?: string; + 'entityType'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "entityId", + "baseName": "entity_id", + "type": "string" + }, + { + "name": "entityType", + "baseName": "entity_type", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return GiftMessageDataMessageExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface MessageInterface +*/ +export class GiftMessageDataMessageInterface { + /** + * Gift message ID. Otherwise, null. + */ + 'giftMessageId'?: number; + /** + * Customer ID. Otherwise, null. + */ + 'customerId'?: number; + /** + * Sender name. + */ + 'sender': string; + /** + * Recipient name. + */ + 'recipient': string; + /** + * Message text. + */ + 'message': string; + 'extensionAttributes'?: GiftMessageDataMessageExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "giftMessageId", + "baseName": "gift_message_id", + "type": "number" + }, + { + "name": "customerId", + "baseName": "customer_id", + "type": "number" + }, + { + "name": "sender", + "baseName": "sender", + "type": "string" + }, + { + "name": "recipient", + "baseName": "recipient", + "type": "string" + }, + { + "name": "message", + "baseName": "message", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "GiftMessageDataMessageExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return GiftMessageDataMessageInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\InventoryInStorePickupApi\\Api\\Data\\PickupLocationInterface +*/ +export class InventoryInStorePickupApiDataPickupLocationExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataPickupLocationExtensionInterface.attributeTypeMap; + } +} + +/** +* Represents sources projection on In-Store Pickup context. Realisation must follow immutable DTO concept. Partial immutability done according to restriction of current Extension Attributes implementation. +*/ +export class InventoryInStorePickupApiDataPickupLocationInterface { + /** + * Source code of Pickup Location. + */ + 'pickupLocationCode': string; + /** + * Pickup Location name. + */ + 'name'?: string; + /** + * Pickup Location contact email. + */ + 'email'?: string; + /** + * Fax contact info. + */ + 'fax'?: string; + /** + * Pickup Location contact name. + */ + 'contactName'?: string; + /** + * Pickup Location description. + */ + 'description'?: string; + /** + * Pickup Location latitude. + */ + 'latitude'?: number; + /** + * Pickup Location longitude. + */ + 'longitude'?: number; + /** + * Pickup Location country ID. + */ + 'countryId'?: string; + /** + * Pickup Location region ID. + */ + 'regionId'?: number; + /** + * Pickup Location region. + */ + 'region'?: string; + /** + * Pickup Location city. + */ + 'city'?: string; + /** + * Pickup Location street. + */ + 'street'?: string; + /** + * Pickup Location postcode. + */ + 'postcode'?: string; + /** + * Pickup Location phone. + */ + 'phone'?: string; + 'extensionAttributes'?: InventoryInStorePickupApiDataPickupLocationExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "pickupLocationCode", + "baseName": "pickup_location_code", + "type": "string" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "email", + "baseName": "email", + "type": "string" + }, + { + "name": "fax", + "baseName": "fax", + "type": "string" + }, + { + "name": "contactName", + "baseName": "contact_name", + "type": "string" + }, + { + "name": "description", + "baseName": "description", + "type": "string" + }, + { + "name": "latitude", + "baseName": "latitude", + "type": "number" + }, + { + "name": "longitude", + "baseName": "longitude", + "type": "number" + }, + { + "name": "countryId", + "baseName": "country_id", + "type": "string" + }, + { + "name": "regionId", + "baseName": "region_id", + "type": "number" + }, + { + "name": "region", + "baseName": "region", + "type": "string" + }, + { + "name": "city", + "baseName": "city", + "type": "string" + }, + { + "name": "street", + "baseName": "street", + "type": "string" + }, + { + "name": "postcode", + "baseName": "postcode", + "type": "string" + }, + { + "name": "phone", + "baseName": "phone", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "InventoryInStorePickupApiDataPickupLocationExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataPickupLocationInterface.attributeTypeMap; + } +} + +/** +* Filter by Distance to the Address. Pickup Locations will be filtered by distance according to the geo-position of the entered address. Required fields for the address are country and one of the field: region or city or postcode. +*/ +export class InventoryInStorePickupApiDataSearchRequestAreaInterface { + /** + * Search radius in KM. + */ + 'radius': number; + /** + * Search term string. + */ + 'searchTerm': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "radius", + "baseName": "radius", + "type": "number" + }, + { + "name": "searchTerm", + "baseName": "search_term", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataSearchRequestAreaInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\InventoryInStorePickupApi\\Api\\Data\\SearchRequestInterface +*/ +export class InventoryInStorePickupApiDataSearchRequestExtensionInterface { + 'productsInfo'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "productsInfo", + "baseName": "products_info", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataSearchRequestExtensionInterface.attributeTypeMap; + } +} + +/** +* Filter for Pickup Location search. +*/ +export class InventoryInStorePickupApiDataSearchRequestFilterInterface { + /** + * Value. + */ + 'value': string; + /** + * Condition Type. + */ + 'conditionType': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "value", + "baseName": "value", + "type": "string" + }, + { + "name": "conditionType", + "baseName": "condition_type", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataSearchRequestFilterInterface.attributeTypeMap; + } +} + +/** +* Filter to filter by Fields. Each field may be filtered with different condition type. Supported condition types restricted by @see \\Magento\\Framework\\Api\\SearchCriteriaInterface +*/ +export class InventoryInStorePickupApiDataSearchRequestFiltersInterface { + 'country'?: InventoryInStorePickupApiDataSearchRequestFilterInterface; + 'postcode'?: InventoryInStorePickupApiDataSearchRequestFilterInterface; + 'region'?: InventoryInStorePickupApiDataSearchRequestFilterInterface; + 'regionId'?: InventoryInStorePickupApiDataSearchRequestFilterInterface; + 'city'?: InventoryInStorePickupApiDataSearchRequestFilterInterface; + 'street'?: InventoryInStorePickupApiDataSearchRequestFilterInterface; + 'name'?: InventoryInStorePickupApiDataSearchRequestFilterInterface; + 'pickupLocationCode'?: InventoryInStorePickupApiDataSearchRequestFilterInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "country", + "baseName": "country", + "type": "InventoryInStorePickupApiDataSearchRequestFilterInterface" + }, + { + "name": "postcode", + "baseName": "postcode", + "type": "InventoryInStorePickupApiDataSearchRequestFilterInterface" + }, + { + "name": "region", + "baseName": "region", + "type": "InventoryInStorePickupApiDataSearchRequestFilterInterface" + }, + { + "name": "regionId", + "baseName": "region_id", + "type": "InventoryInStorePickupApiDataSearchRequestFilterInterface" + }, + { + "name": "city", + "baseName": "city", + "type": "InventoryInStorePickupApiDataSearchRequestFilterInterface" + }, + { + "name": "street", + "baseName": "street", + "type": "InventoryInStorePickupApiDataSearchRequestFilterInterface" + }, + { + "name": "name", + "baseName": "name", + "type": "InventoryInStorePickupApiDataSearchRequestFilterInterface" + }, + { + "name": "pickupLocationCode", + "baseName": "pickup_location_code", + "type": "InventoryInStorePickupApiDataSearchRequestFilterInterface" + } ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataSearchRequestFiltersInterface.attributeTypeMap; + } +} + +/** +* Endpoint used to search Pickup Locations by different parameters: - by attribute filters fields @see \\Magento\\InventoryInStorePickupApi\\Api\\Data\\SearchRequest\\FiltersInterface - by distance to the address @see \\Magento\\InventoryInStorePickupApi\\Api\\Data\\SearchRequest\\AreaInterface Also, endpoint supports paging and sort orders. +*/ +export class InventoryInStorePickupApiDataSearchRequestInterface { + 'area'?: InventoryInStorePickupApiDataSearchRequestAreaInterface; + 'filters'?: InventoryInStorePickupApiDataSearchRequestFiltersInterface; + /** + * Page size. + */ + 'pageSize'?: number; + /** + * Current page. + */ + 'currentPage': number; + /** + * Sales Channel Type. + */ + 'scopeType': string; + /** + * Sales Channel code. + */ + 'scopeCode': string; + /** + * Sort Order. + */ + 'sort'?: Array; + 'extensionAttributes'?: InventoryInStorePickupApiDataSearchRequestExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "area", + "baseName": "area", + "type": "InventoryInStorePickupApiDataSearchRequestAreaInterface" + }, + { + "name": "filters", + "baseName": "filters", + "type": "InventoryInStorePickupApiDataSearchRequestFiltersInterface" + }, + { + "name": "pageSize", + "baseName": "page_size", + "type": "number" + }, + { + "name": "currentPage", + "baseName": "current_page", + "type": "number" + }, + { + "name": "scopeType", + "baseName": "scope_type", + "type": "string" + }, + { + "name": "scopeCode", + "baseName": "scope_code", + "type": "string" + }, + { + "name": "sort", + "baseName": "sort", + "type": "Array" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "InventoryInStorePickupApiDataSearchRequestExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataSearchRequestInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\InventoryInStorePickupApi\\Api\\Data\\SearchRequest\\ProductInfoInterface +*/ +export class InventoryInStorePickupApiDataSearchRequestProductInfoExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataSearchRequestProductInfoExtensionInterface.attributeTypeMap; + } +} + +/** +* Product Info Data Transfer Object. +*/ +export class InventoryInStorePickupApiDataSearchRequestProductInfoInterface { + /** + * Product SKU. + */ + 'sku': string; + 'extensionAttributes'?: InventoryInStorePickupApiDataSearchRequestProductInfoExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "sku", + "baseName": "sku", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "InventoryInStorePickupApiDataSearchRequestProductInfoExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataSearchRequestProductInfoInterface.attributeTypeMap; + } +} + +/** +* Search results for providing pickup locations. +*/ +export class InventoryInStorePickupApiDataSearchResultInterface { + /** + * Items list. + */ + 'items': Array; + 'searchRequest': InventoryInStorePickupApiDataSearchRequestInterface; + /** + * Total count. + */ + 'totalCount': number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "items", + "baseName": "items", + "type": "Array" + }, + { + "name": "searchRequest", + "baseName": "search_request", + "type": "InventoryInStorePickupApiDataSearchRequestInterface" + }, + { + "name": "totalCount", + "baseName": "total_count", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return InventoryInStorePickupApiDataSearchResultInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Msrp\\Api\\Data\\ProductRender\\MsrpPriceInfoInterface +*/ +export class MsrpDataProductRenderMsrpPriceInfoExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return MsrpDataProductRenderMsrpPriceInfoExtensionInterface.attributeTypeMap; + } +} + +/** +* Price interface. +*/ +export class MsrpDataProductRenderMsrpPriceInfoInterface { + 'msrpPrice': string; + 'isApplicable': string; + 'isShownPriceOnGesture': string; + 'msrpMessage': string; + 'explanationMessage': string; + 'extensionAttributes'?: MsrpDataProductRenderMsrpPriceInfoExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "msrpPrice", + "baseName": "msrp_price", + "type": "string" + }, + { + "name": "isApplicable", + "baseName": "is_applicable", + "type": "string" + }, + { + "name": "isShownPriceOnGesture", + "baseName": "is_shown_price_on_gesture", + "type": "string" + }, + { + "name": "msrpMessage", + "baseName": "msrp_message", + "type": "string" + }, + { + "name": "explanationMessage", + "baseName": "explanation_message", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "MsrpDataProductRenderMsrpPriceInfoExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return MsrpDataProductRenderMsrpPriceInfoInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\AddressInterface +*/ +export class QuoteDataAddressExtensionInterface { + 'pickupLocationCode'?: string; + 'discounts'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "pickupLocationCode", + "baseName": "pickup_location_code", + "type": "string" + }, + { + "name": "discounts", + "baseName": "discounts", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return QuoteDataAddressExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface AddressInterface +*/ +export class QuoteDataAddressInterface { + /** + * Id + */ + 'id'?: number; + /** + * Region name + */ + 'region': string; + /** + * Region id + */ + 'regionId': number; + /** + * Region code + */ + 'regionCode': string; + /** + * Country id + */ + 'countryId': string; + /** + * Street + */ + 'street': Array; + /** + * Company + */ + 'company'?: string; + /** + * Telephone number + */ + 'telephone': string; + /** + * Fax number + */ + 'fax'?: string; + /** + * Postcode + */ + 'postcode': string; + /** + * City name + */ + 'city': string; + /** + * First name + */ + 'firstname': string; + /** + * Last name + */ + 'lastname': string; + /** + * Middle name + */ + 'middlename'?: string; + /** + * Prefix + */ + 'prefix'?: string; + /** + * Suffix + */ + 'suffix'?: string; + /** + * Vat id + */ + 'vatId'?: string; + /** + * Customer id + */ + 'customerId'?: number; + /** + * Billing/shipping email + */ + 'email': string; + /** + * Same as billing flag + */ + 'sameAsBilling'?: number; + /** + * Customer address id + */ + 'customerAddressId'?: number; + /** + * Save in address book flag + */ + 'saveInAddressBook'?: number; + 'extensionAttributes'?: QuoteDataAddressExtensionInterface; + /** + * Custom attributes values. + */ + 'customAttributes'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "region", + "baseName": "region", + "type": "string" + }, + { + "name": "regionId", + "baseName": "region_id", + "type": "number" + }, + { + "name": "regionCode", + "baseName": "region_code", + "type": "string" + }, + { + "name": "countryId", + "baseName": "country_id", + "type": "string" + }, + { + "name": "street", + "baseName": "street", + "type": "Array" + }, + { + "name": "company", + "baseName": "company", + "type": "string" + }, + { + "name": "telephone", + "baseName": "telephone", + "type": "string" + }, + { + "name": "fax", + "baseName": "fax", + "type": "string" + }, + { + "name": "postcode", + "baseName": "postcode", + "type": "string" + }, + { + "name": "city", + "baseName": "city", + "type": "string" + }, + { + "name": "firstname", + "baseName": "firstname", + "type": "string" + }, + { + "name": "lastname", + "baseName": "lastname", + "type": "string" + }, + { + "name": "middlename", + "baseName": "middlename", + "type": "string" + }, + { + "name": "prefix", + "baseName": "prefix", + "type": "string" + }, + { + "name": "suffix", + "baseName": "suffix", + "type": "string" + }, + { + "name": "vatId", + "baseName": "vat_id", + "type": "string" + }, + { + "name": "customerId", + "baseName": "customer_id", + "type": "number" + }, + { + "name": "email", + "baseName": "email", + "type": "string" + }, + { + "name": "sameAsBilling", + "baseName": "same_as_billing", + "type": "number" + }, + { + "name": "customerAddressId", + "baseName": "customer_address_id", + "type": "number" + }, + { + "name": "saveInAddressBook", + "baseName": "save_in_address_book", + "type": "number" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataAddressExtensionInterface" + }, + { + "name": "customAttributes", + "baseName": "custom_attributes", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return QuoteDataAddressInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\CartInterface +*/ +export class QuoteDataCartExtensionInterface { + 'shippingAssignments'?: Array; + 'amazonOrderReferenceId'?: AmazonPaymentDataQuoteLinkInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "shippingAssignments", + "baseName": "shipping_assignments", + "type": "Array" + }, + { + "name": "amazonOrderReferenceId", + "baseName": "amazon_order_reference_id", + "type": "AmazonPaymentDataQuoteLinkInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataCartExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface CartInterface +*/ +export class QuoteDataCartInterface { + /** + * Cart/quote ID. + */ + 'id': number; + /** + * Cart creation date and time. Otherwise, null. + */ + 'createdAt'?: string; + /** + * Cart last update date and time. Otherwise, null. + */ + 'updatedAt'?: string; + /** + * Cart conversion date and time. Otherwise, null. + */ + 'convertedAt'?: string; + /** + * Active status flag value. Otherwise, null. + */ + 'isActive'?: boolean; + /** + * Virtual flag value. Otherwise, null. + */ + 'isVirtual'?: boolean; + /** + * Array of items. Otherwise, null. + */ + 'items'?: Array; + /** + * Number of different items or products in the cart. Otherwise, null. + */ + 'itemsCount'?: number; + /** + * Total quantity of all cart items. Otherwise, null. + */ + 'itemsQty'?: number; + 'customer': CustomerDataCustomerInterface; + 'billingAddress'?: QuoteDataAddressInterface; + /** + * Reserved order ID. Otherwise, null. + */ + 'reservedOrderId'?: string; + /** + * Original order ID. Otherwise, null. + */ + 'origOrderId'?: number; + 'currency'?: QuoteDataCurrencyInterface; + /** + * For guest customers, false for logged in customers + */ + 'customerIsGuest'?: boolean; + /** + * Notice text + */ + 'customerNote'?: string; + /** + * Customer notification flag + */ + 'customerNoteNotify'?: boolean; + /** + * Customer tax class ID. + */ + 'customerTaxClassId'?: number; + /** + * Store identifier + */ + 'storeId': number; + 'extensionAttributes'?: QuoteDataCartExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "id", + "baseName": "id", + "type": "number" + }, + { + "name": "createdAt", + "baseName": "created_at", + "type": "string" + }, + { + "name": "updatedAt", + "baseName": "updated_at", + "type": "string" + }, + { + "name": "convertedAt", + "baseName": "converted_at", + "type": "string" + }, + { + "name": "isActive", + "baseName": "is_active", + "type": "boolean" + }, + { + "name": "isVirtual", + "baseName": "is_virtual", + "type": "boolean" + }, + { + "name": "items", + "baseName": "items", + "type": "Array" + }, + { + "name": "itemsCount", + "baseName": "items_count", + "type": "number" + }, + { + "name": "itemsQty", + "baseName": "items_qty", + "type": "number" + }, + { + "name": "customer", + "baseName": "customer", + "type": "CustomerDataCustomerInterface" + }, + { + "name": "billingAddress", + "baseName": "billing_address", + "type": "QuoteDataAddressInterface" + }, + { + "name": "reservedOrderId", + "baseName": "reserved_order_id", + "type": "string" + }, + { + "name": "origOrderId", + "baseName": "orig_order_id", + "type": "number" + }, + { + "name": "currency", + "baseName": "currency", + "type": "QuoteDataCurrencyInterface" + }, + { + "name": "customerIsGuest", + "baseName": "customer_is_guest", + "type": "boolean" + }, + { + "name": "customerNote", + "baseName": "customer_note", + "type": "string" + }, + { + "name": "customerNoteNotify", + "baseName": "customer_note_notify", + "type": "boolean" + }, + { + "name": "customerTaxClassId", + "baseName": "customer_tax_class_id", + "type": "number" + }, + { + "name": "storeId", + "baseName": "store_id", + "type": "number" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataCartExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataCartInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\CartItemInterface +*/ +export class QuoteDataCartItemExtensionInterface { + 'discounts'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "discounts", + "baseName": "discounts", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return QuoteDataCartItemExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface CartItemInterface +*/ +export class QuoteDataCartItemInterface { + /** + * Item ID. Otherwise, null. + */ + 'itemId'?: number; + /** + * Product SKU. Otherwise, null. + */ + 'sku'?: string; + /** + * Product quantity. + */ + 'qty': number; + /** + * Product name. Otherwise, null. + */ + 'name'?: string; + /** + * Product price. Otherwise, null. + */ + 'price'?: number; + /** + * Product type. Otherwise, null. + */ + 'productType'?: string; + /** + * Quote id. + */ + 'quoteId': string; + 'productOption'?: QuoteDataProductOptionInterface; + 'extensionAttributes'?: QuoteDataCartItemExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "itemId", + "baseName": "item_id", + "type": "number" + }, + { + "name": "sku", + "baseName": "sku", + "type": "string" + }, + { + "name": "qty", + "baseName": "qty", + "type": "number" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "price", + "baseName": "price", + "type": "number" + }, + { + "name": "productType", + "baseName": "product_type", + "type": "string" + }, + { + "name": "quoteId", + "baseName": "quote_id", + "type": "string" + }, + { + "name": "productOption", + "baseName": "product_option", + "type": "QuoteDataProductOptionInterface" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataCartItemExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataCartItemInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\CurrencyInterface +*/ +export class QuoteDataCurrencyExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return QuoteDataCurrencyExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface CurrencyInterface +*/ +export class QuoteDataCurrencyInterface { + /** + * Global currency code + */ + 'globalCurrencyCode'?: string; + /** + * Base currency code + */ + 'baseCurrencyCode'?: string; + /** + * Store currency code + */ + 'storeCurrencyCode'?: string; + /** + * Quote currency code + */ + 'quoteCurrencyCode'?: string; + /** + * Store currency to base currency rate + */ + 'storeToBaseRate'?: number; + /** + * Store currency to quote currency rate + */ + 'storeToQuoteRate'?: number; + /** + * Base currency to global currency rate + */ + 'baseToGlobalRate'?: number; + /** + * Base currency to quote currency rate + */ + 'baseToQuoteRate'?: number; + 'extensionAttributes'?: QuoteDataCurrencyExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "globalCurrencyCode", + "baseName": "global_currency_code", + "type": "string" + }, + { + "name": "baseCurrencyCode", + "baseName": "base_currency_code", + "type": "string" + }, + { + "name": "storeCurrencyCode", + "baseName": "store_currency_code", + "type": "string" + }, + { + "name": "quoteCurrencyCode", + "baseName": "quote_currency_code", + "type": "string" + }, + { + "name": "storeToBaseRate", + "baseName": "store_to_base_rate", + "type": "number" + }, + { + "name": "storeToQuoteRate", + "baseName": "store_to_quote_rate", + "type": "number" + }, + { + "name": "baseToGlobalRate", + "baseName": "base_to_global_rate", + "type": "number" + }, + { + "name": "baseToQuoteRate", + "baseName": "base_to_quote_rate", + "type": "number" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataCurrencyExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataCurrencyInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\PaymentInterface +*/ +export class QuoteDataPaymentExtensionInterface { + 'agreementIds'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "agreementIds", + "baseName": "agreement_ids", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return QuoteDataPaymentExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface PaymentInterface +*/ +export class QuoteDataPaymentInterface { + /** + * Purchase order number + */ + 'poNumber'?: string; + /** + * Payment method code + */ + 'method': string; + /** + * Payment additional details + */ + 'additionalData'?: Array; + 'extensionAttributes'?: QuoteDataPaymentExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "poNumber", + "baseName": "po_number", + "type": "string" + }, + { + "name": "method", + "baseName": "method", + "type": "string" + }, + { + "name": "additionalData", + "baseName": "additional_data", + "type": "Array" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataPaymentExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataPaymentInterface.attributeTypeMap; + } +} + +/** +* Interface PaymentMethodInterface +*/ +export class QuoteDataPaymentMethodInterface { + /** + * Payment method code + */ + 'code': string; + /** + * Payment method title + */ + 'title': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "code", + "baseName": "code", + "type": "string" + }, + { + "name": "title", + "baseName": "title", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return QuoteDataPaymentMethodInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\ProductOptionInterface +*/ +export class QuoteDataProductOptionExtensionInterface { + 'customOptions'?: Array; + 'bundleOptions'?: Array; + 'downloadableOption'?: DownloadableDataDownloadableOptionInterface; + 'configurableItemOptions'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "customOptions", + "baseName": "custom_options", + "type": "Array" + }, + { + "name": "bundleOptions", + "baseName": "bundle_options", + "type": "Array" + }, + { + "name": "downloadableOption", + "baseName": "downloadable_option", + "type": "DownloadableDataDownloadableOptionInterface" + }, + { + "name": "configurableItemOptions", + "baseName": "configurable_item_options", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return QuoteDataProductOptionExtensionInterface.attributeTypeMap; + } +} + +/** +* Product option interface +*/ +export class QuoteDataProductOptionInterface { + 'extensionAttributes'?: QuoteDataProductOptionExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataProductOptionExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataProductOptionInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\ShippingAssignmentInterface +*/ +export class QuoteDataShippingAssignmentExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return QuoteDataShippingAssignmentExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface ShippingAssignmentInterface +*/ +export class QuoteDataShippingAssignmentInterface { + 'shipping': QuoteDataShippingInterface; + 'items': Array; + 'extensionAttributes'?: QuoteDataShippingAssignmentExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "shipping", + "baseName": "shipping", + "type": "QuoteDataShippingInterface" + }, + { + "name": "items", + "baseName": "items", + "type": "Array" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataShippingAssignmentExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataShippingAssignmentInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\ShippingInterface +*/ +export class QuoteDataShippingExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return QuoteDataShippingExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface ShippingInterface +*/ +export class QuoteDataShippingInterface { + 'address': QuoteDataAddressInterface; + /** + * Shipping method + */ + 'method': string; + 'extensionAttributes'?: QuoteDataShippingExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "address", + "baseName": "address", + "type": "QuoteDataAddressInterface" + }, + { + "name": "method", + "baseName": "method", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataShippingExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataShippingInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\ShippingMethodInterface +*/ +export class QuoteDataShippingMethodExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return QuoteDataShippingMethodExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface ShippingMethodInterface +*/ +export class QuoteDataShippingMethodInterface { + /** + * Shipping carrier code. + */ + 'carrierCode': string; + /** + * Shipping method code. + */ + 'methodCode': string; + /** + * Shipping carrier title. Otherwise, null. + */ + 'carrierTitle'?: string; + /** + * Shipping method title. Otherwise, null. + */ + 'methodTitle'?: string; + /** + * Shipping amount in store currency. + */ + 'amount': number; + /** + * Shipping amount in base currency. + */ + 'baseAmount': number; + /** + * The value of the availability flag for the current shipping method. + */ + 'available': boolean; + 'extensionAttributes'?: QuoteDataShippingMethodExtensionInterface; + /** + * Shipping Error message. + */ + 'errorMessage': string; + /** + * Shipping price excl tax. + */ + 'priceExclTax': number; + /** + * Shipping price incl tax. + */ + 'priceInclTax': number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "carrierCode", + "baseName": "carrier_code", + "type": "string" + }, + { + "name": "methodCode", + "baseName": "method_code", + "type": "string" + }, + { + "name": "carrierTitle", + "baseName": "carrier_title", + "type": "string" + }, + { + "name": "methodTitle", + "baseName": "method_title", + "type": "string" + }, + { + "name": "amount", + "baseName": "amount", + "type": "number" + }, + { + "name": "baseAmount", + "baseName": "base_amount", + "type": "number" + }, + { + "name": "available", + "baseName": "available", + "type": "boolean" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataShippingMethodExtensionInterface" + }, + { + "name": "errorMessage", + "baseName": "error_message", + "type": "string" + }, + { + "name": "priceExclTax", + "baseName": "price_excl_tax", + "type": "number" + }, + { + "name": "priceInclTax", + "baseName": "price_incl_tax", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return QuoteDataShippingMethodInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\TotalSegmentInterface +*/ +export class QuoteDataTotalSegmentExtensionInterface { + 'taxGrandtotalDetails'?: Array; + 'vertexTaxCalculationMessages'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "taxGrandtotalDetails", + "baseName": "tax_grandtotal_details", + "type": "Array" + }, + { + "name": "vertexTaxCalculationMessages", + "baseName": "vertex_tax_calculation_messages", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return QuoteDataTotalSegmentExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface TotalsInterface +*/ +export class QuoteDataTotalSegmentInterface { + /** + * Code + */ + 'code': string; + /** + * Total title + */ + 'title'?: string; + /** + * Total value + */ + 'value': number; + /** + * Display area code. + */ + 'area'?: string; + 'extensionAttributes'?: QuoteDataTotalSegmentExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "code", + "baseName": "code", + "type": "string" + }, + { + "name": "title", + "baseName": "title", + "type": "string" + }, + { + "name": "value", + "baseName": "value", + "type": "number" + }, + { + "name": "area", + "baseName": "area", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataTotalSegmentExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataTotalSegmentInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\TotalsAdditionalDataInterface +*/ +export class QuoteDataTotalsAdditionalDataExtensionInterface { + 'giftMessages'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "giftMessages", + "baseName": "gift_messages", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return QuoteDataTotalsAdditionalDataExtensionInterface.attributeTypeMap; + } +} + +/** +* Additional data for totals collection. +*/ +export class QuoteDataTotalsAdditionalDataInterface { + 'extensionAttributes'?: QuoteDataTotalsAdditionalDataExtensionInterface; + /** + * Custom attributes values. + */ + 'customAttributes'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataTotalsAdditionalDataExtensionInterface" + }, + { + "name": "customAttributes", + "baseName": "custom_attributes", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return QuoteDataTotalsAdditionalDataInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\TotalsInterface +*/ +export class QuoteDataTotalsExtensionInterface { + 'couponLabel'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "couponLabel", + "baseName": "coupon_label", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return QuoteDataTotalsExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface TotalsInterface +*/ +export class QuoteDataTotalsInterface { + /** + * Grand total in quote currency + */ + 'grandTotal'?: number; + /** + * Grand total in base currency + */ + 'baseGrandTotal'?: number; + /** + * Subtotal in quote currency + */ + 'subtotal'?: number; + /** + * Subtotal in base currency + */ + 'baseSubtotal'?: number; + /** + * Discount amount in quote currency + */ + 'discountAmount'?: number; + /** + * Discount amount in base currency + */ + 'baseDiscountAmount'?: number; + /** + * Subtotal in quote currency with applied discount + */ + 'subtotalWithDiscount'?: number; + /** + * Subtotal in base currency with applied discount + */ + 'baseSubtotalWithDiscount'?: number; + /** + * Shipping amount in quote currency + */ + 'shippingAmount'?: number; + /** + * Shipping amount in base currency + */ + 'baseShippingAmount'?: number; + /** + * Shipping discount amount in quote currency + */ + 'shippingDiscountAmount'?: number; + /** + * Shipping discount amount in base currency + */ + 'baseShippingDiscountAmount'?: number; + /** + * Tax amount in quote currency + */ + 'taxAmount'?: number; + /** + * Tax amount in base currency + */ + 'baseTaxAmount'?: number; + /** + * Item weee tax applied amount in quote currency. + */ + 'weeeTaxAppliedAmount': number; + /** + * Shipping tax amount in quote currency + */ + 'shippingTaxAmount'?: number; + /** + * Shipping tax amount in base currency + */ + 'baseShippingTaxAmount'?: number; + /** + * Subtotal including tax in quote currency + */ + 'subtotalInclTax'?: number; + /** + * Subtotal including tax in base currency + */ + 'baseSubtotalInclTax'?: number; + /** + * Shipping including tax in quote currency + */ + 'shippingInclTax'?: number; + /** + * Shipping including tax in base currency + */ + 'baseShippingInclTax'?: number; + /** + * Base currency code + */ + 'baseCurrencyCode'?: string; + /** + * Quote currency code + */ + 'quoteCurrencyCode'?: string; + /** + * Applied coupon code + */ + 'couponCode'?: string; + /** + * Items qty + */ + 'itemsQty'?: number; + /** + * Totals by items + */ + 'items'?: Array; + /** + * Dynamically calculated totals + */ + 'totalSegments': Array; + 'extensionAttributes'?: QuoteDataTotalsExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "grandTotal", + "baseName": "grand_total", + "type": "number" + }, + { + "name": "baseGrandTotal", + "baseName": "base_grand_total", + "type": "number" + }, + { + "name": "subtotal", + "baseName": "subtotal", + "type": "number" + }, + { + "name": "baseSubtotal", + "baseName": "base_subtotal", + "type": "number" + }, + { + "name": "discountAmount", + "baseName": "discount_amount", + "type": "number" + }, + { + "name": "baseDiscountAmount", + "baseName": "base_discount_amount", + "type": "number" + }, + { + "name": "subtotalWithDiscount", + "baseName": "subtotal_with_discount", + "type": "number" + }, + { + "name": "baseSubtotalWithDiscount", + "baseName": "base_subtotal_with_discount", + "type": "number" + }, + { + "name": "shippingAmount", + "baseName": "shipping_amount", + "type": "number" + }, + { + "name": "baseShippingAmount", + "baseName": "base_shipping_amount", + "type": "number" + }, + { + "name": "shippingDiscountAmount", + "baseName": "shipping_discount_amount", + "type": "number" + }, + { + "name": "baseShippingDiscountAmount", + "baseName": "base_shipping_discount_amount", + "type": "number" + }, + { + "name": "taxAmount", + "baseName": "tax_amount", + "type": "number" + }, + { + "name": "baseTaxAmount", + "baseName": "base_tax_amount", + "type": "number" + }, + { + "name": "weeeTaxAppliedAmount", + "baseName": "weee_tax_applied_amount", + "type": "number" + }, + { + "name": "shippingTaxAmount", + "baseName": "shipping_tax_amount", + "type": "number" + }, + { + "name": "baseShippingTaxAmount", + "baseName": "base_shipping_tax_amount", + "type": "number" + }, + { + "name": "subtotalInclTax", + "baseName": "subtotal_incl_tax", + "type": "number" + }, + { + "name": "baseSubtotalInclTax", + "baseName": "base_subtotal_incl_tax", + "type": "number" + }, + { + "name": "shippingInclTax", + "baseName": "shipping_incl_tax", + "type": "number" + }, + { + "name": "baseShippingInclTax", + "baseName": "base_shipping_incl_tax", + "type": "number" + }, + { + "name": "baseCurrencyCode", + "baseName": "base_currency_code", + "type": "string" + }, + { + "name": "quoteCurrencyCode", + "baseName": "quote_currency_code", + "type": "string" + }, + { + "name": "couponCode", + "baseName": "coupon_code", + "type": "string" + }, + { + "name": "itemsQty", + "baseName": "items_qty", + "type": "number" + }, + { + "name": "items", + "baseName": "items", + "type": "Array" + }, + { + "name": "totalSegments", + "baseName": "total_segments", + "type": "Array" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataTotalsExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return QuoteDataTotalsInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Quote\\Api\\Data\\TotalsItemInterface +*/ +export class QuoteDataTotalsItemExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return QuoteDataTotalsItemExtensionInterface.attributeTypeMap; + } +} + +/** +* Interface TotalsItemInterface +*/ +export class QuoteDataTotalsItemInterface { + /** + * Item id + */ + 'itemId': number; + /** + * Item price in quote currency. + */ + 'price': number; + /** + * Item price in base currency. + */ + 'basePrice': number; + /** + * Item quantity. + */ + 'qty': number; + /** + * Row total in quote currency. + */ + 'rowTotal': number; + /** + * Row total in base currency. + */ + 'baseRowTotal': number; + /** + * Row total with discount in quote currency. Otherwise, null. + */ + 'rowTotalWithDiscount'?: number; + /** + * Tax amount in quote currency. Otherwise, null. + */ + 'taxAmount'?: number; + /** + * Tax amount in base currency. Otherwise, null. + */ + 'baseTaxAmount'?: number; + /** + * Tax percent. Otherwise, null. + */ + 'taxPercent'?: number; + /** + * Discount amount in quote currency. Otherwise, null. + */ + 'discountAmount'?: number; + /** + * Discount amount in base currency. Otherwise, null. + */ + 'baseDiscountAmount'?: number; + /** + * Discount percent. Otherwise, null. + */ + 'discountPercent'?: number; + /** + * Price including tax in quote currency. Otherwise, null. + */ + 'priceInclTax'?: number; + /** + * Price including tax in base currency. Otherwise, null. + */ + 'basePriceInclTax'?: number; + /** + * Row total including tax in quote currency. Otherwise, null. + */ + 'rowTotalInclTax'?: number; + /** + * Row total including tax in base currency. Otherwise, null. + */ + 'baseRowTotalInclTax'?: number; + /** + * Item price in quote currency. + */ + 'options': string; + /** + * Item weee tax applied amount in quote currency. + */ + 'weeeTaxAppliedAmount': number; + /** + * Item weee tax applied in quote currency. + */ + 'weeeTaxApplied': string; + 'extensionAttributes'?: QuoteDataTotalsItemExtensionInterface; + /** + * Product name. Otherwise, null. + */ + 'name'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "itemId", + "baseName": "item_id", + "type": "number" + }, + { + "name": "price", + "baseName": "price", + "type": "number" + }, + { + "name": "basePrice", + "baseName": "base_price", + "type": "number" + }, + { + "name": "qty", + "baseName": "qty", + "type": "number" + }, + { + "name": "rowTotal", + "baseName": "row_total", + "type": "number" + }, + { + "name": "baseRowTotal", + "baseName": "base_row_total", + "type": "number" + }, + { + "name": "rowTotalWithDiscount", + "baseName": "row_total_with_discount", + "type": "number" + }, + { + "name": "taxAmount", + "baseName": "tax_amount", + "type": "number" + }, + { + "name": "baseTaxAmount", + "baseName": "base_tax_amount", + "type": "number" + }, + { + "name": "taxPercent", + "baseName": "tax_percent", + "type": "number" + }, + { + "name": "discountAmount", + "baseName": "discount_amount", + "type": "number" + }, + { + "name": "baseDiscountAmount", + "baseName": "base_discount_amount", + "type": "number" + }, + { + "name": "discountPercent", + "baseName": "discount_percent", + "type": "number" + }, + { + "name": "priceInclTax", + "baseName": "price_incl_tax", + "type": "number" + }, + { + "name": "basePriceInclTax", + "baseName": "base_price_incl_tax", + "type": "number" + }, + { + "name": "rowTotalInclTax", + "baseName": "row_total_incl_tax", + "type": "number" + }, + { + "name": "baseRowTotalInclTax", + "baseName": "base_row_total_incl_tax", + "type": "number" + }, + { + "name": "options", + "baseName": "options", + "type": "string" + }, + { + "name": "weeeTaxAppliedAmount", + "baseName": "weee_tax_applied_amount", + "type": "number" + }, + { + "name": "weeeTaxApplied", + "baseName": "weee_tax_applied", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "QuoteDataTotalsItemExtensionInterface" + }, + { + "name": "name", + "baseName": "name", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return QuoteDataTotalsItemInterface.attributeTypeMap; + } +} + +/** +* Discount Data Interface +*/ +export class SalesRuleDataDiscountDataInterface { + /** + * Amount + */ + 'amount': number; + /** + * Base Amount + */ + 'baseAmount': number; + /** + * Original Amount + */ + 'originalAmount': number; + /** + * Base Original Amount + */ + 'baseOriginalAmount': number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "amount", + "baseName": "amount", + "type": "number" + }, + { + "name": "baseAmount", + "baseName": "base_amount", + "type": "number" + }, + { + "name": "originalAmount", + "baseName": "original_amount", + "type": "number" + }, + { + "name": "baseOriginalAmount", + "baseName": "base_original_amount", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return SalesRuleDataDiscountDataInterface.attributeTypeMap; + } +} + +/** +* Rule discount Interface +*/ +export class SalesRuleDataRuleDiscountInterface { + 'discountData': SalesRuleDataDiscountDataInterface; + /** + * Rule Label + */ + 'ruleLabel': string; + /** + * Rule ID + */ + 'ruleId': number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "discountData", + "baseName": "discount_data", + "type": "SalesRuleDataDiscountDataInterface" + }, + { + "name": "ruleLabel", + "baseName": "rule_label", + "type": "string" + }, + { + "name": "ruleId", + "baseName": "rule_id", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return SalesRuleDataRuleDiscountInterface.attributeTypeMap; + } +} + +/** +* Interface GrandTotalDetailsInterface +*/ +export class TaxDataGrandTotalDetailsInterface { + /** + * Tax amount value + */ + 'amount': number; + /** + * Tax rates info + */ + 'rates': Array; + /** + * Group identifier + */ + 'groupId': number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "amount", + "baseName": "amount", + "type": "number" + }, + { + "name": "rates", + "baseName": "rates", + "type": "Array" + }, + { + "name": "groupId", + "baseName": "group_id", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return TaxDataGrandTotalDetailsInterface.attributeTypeMap; + } +} + +/** +* Interface GrandTotalRatesInterface +*/ +export class TaxDataGrandTotalRatesInterface { + /** + * Tax percentage value + */ + 'percent': string; + /** + * Rate title + */ + 'title': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "percent", + "baseName": "percent", + "type": "string" + }, + { + "name": "title", + "baseName": "title", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return TaxDataGrandTotalRatesInterface.attributeTypeMap; + } +} + +/** +* This is the interface for submission to the API. For ease the API only takes interfaces the same as the SDK, but the SDK model cannot implement the interface. Since the SDK model technically isn't API, we re-implement a simple DTO to handle the scenario. +*/ +export class VertexAddressValidationApiDataAddressInterface { + /** + * The proper name of the city + */ + 'city'?: string; + /** + * ISO 3166-1 Alpha-3 country code + */ + 'country'?: string; + /** + * The proper name or the postal abbreviation of the state, province, or territory + */ + 'mainDivision'?: string; + /** + * The Postal Code + */ + 'postalCode'?: string; + /** + * The street address + */ + 'streetAddress': Array; + /** + * The name of the county + */ + 'subDivision'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "city", + "baseName": "city", + "type": "string" + }, + { + "name": "country", + "baseName": "country", + "type": "string" + }, + { + "name": "mainDivision", + "baseName": "main_division", + "type": "string" + }, + { + "name": "postalCode", + "baseName": "postal_code", + "type": "string" + }, + { + "name": "streetAddress", + "baseName": "street_address", + "type": "Array" + }, + { + "name": "subDivision", + "baseName": "sub_division", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return VertexAddressValidationApiDataAddressInterface.attributeTypeMap; + } +} + +/** +* What we want to output to the API contains more data than what we want to bring in. Chiefly, we want to ensure we're sending Magento data out (instead of Vertex data). That means sending Region IDs, and 2-character ISO country codes. +*/ +export class VertexAddressValidationApiDataCleansedAddressInterface { + 'city'?: string; + 'countryCode'?: string; + 'countryName'?: string; + 'postalCode'?: string; + 'regionId'?: number; + 'regionName'?: string; + 'streetAddress': Array; + /** + * The regional sub division, such as a county or parish + */ + 'subDivision'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "city", + "baseName": "city", + "type": "string" + }, + { + "name": "countryCode", + "baseName": "country_code", + "type": "string" + }, + { + "name": "countryName", + "baseName": "country_name", + "type": "string" + }, + { + "name": "postalCode", + "baseName": "postal_code", + "type": "string" + }, + { + "name": "regionId", + "baseName": "region_id", + "type": "number" + }, + { + "name": "regionName", + "baseName": "region_name", + "type": "string" + }, + { + "name": "streetAddress", + "baseName": "street_address", + "type": "Array" + }, + { + "name": "subDivision", + "baseName": "sub_division", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return VertexAddressValidationApiDataCleansedAddressInterface.attributeTypeMap; + } +} + +/** +* ExtensionInterface class for @see \\Magento\\Weee\\Api\\Data\\ProductRender\\WeeeAdjustmentAttributeInterface +*/ +export class WeeeDataProductRenderWeeeAdjustmentAttributeExtensionInterface { + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + ]; + + static getAttributeTypeMap() { + return WeeeDataProductRenderWeeeAdjustmentAttributeExtensionInterface.attributeTypeMap; + } +} + +/** +* List of all weee attributes, their amounts, etc.., that product has +*/ +export class WeeeDataProductRenderWeeeAdjustmentAttributeInterface { + /** + * Weee attribute amount + */ + 'amount': string; + /** + * Tax which is calculated to fixed product tax attribute + */ + 'taxAmount': string; + /** + * Tax amount of weee attribute + */ + 'taxAmountInclTax': string; + /** + * Product amount exclude tax + */ + 'amountExclTax': string; + /** + * Weee attribute code + */ + 'attributeCode': string; + 'extensionAttributes': WeeeDataProductRenderWeeeAdjustmentAttributeExtensionInterface; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "amount", + "baseName": "amount", + "type": "string" + }, + { + "name": "taxAmount", + "baseName": "tax_amount", + "type": "string" + }, + { + "name": "taxAmountInclTax", + "baseName": "tax_amount_incl_tax", + "type": "string" + }, + { + "name": "amountExclTax", + "baseName": "amount_excl_tax", + "type": "string" + }, + { + "name": "attributeCode", + "baseName": "attribute_code", + "type": "string" + }, + { + "name": "extensionAttributes", + "baseName": "extension_attributes", + "type": "WeeeDataProductRenderWeeeAdjustmentAttributeExtensionInterface" + } ]; + + static getAttributeTypeMap() { + return WeeeDataProductRenderWeeeAdjustmentAttributeInterface.attributeTypeMap; + } +} + + +let enumsMap: {[index: string]: any} = { +} + +let typeMap: {[index: string]: any} = { + "AmazonPaymentDataQuoteLinkInterface": AmazonPaymentDataQuoteLinkInterface, + "BundleDataBundleOptionExtensionInterface": BundleDataBundleOptionExtensionInterface, + "BundleDataBundleOptionInterface": BundleDataBundleOptionInterface, + "CatalogDataCustomOptionExtensionInterface": CatalogDataCustomOptionExtensionInterface, + "CatalogDataCustomOptionInterface": CatalogDataCustomOptionInterface, + "CatalogDataProductRenderButtonExtensionInterface": CatalogDataProductRenderButtonExtensionInterface, + "CatalogDataProductRenderButtonInterface": CatalogDataProductRenderButtonInterface, + "CatalogDataProductRenderExtensionInterface": CatalogDataProductRenderExtensionInterface, + "CatalogDataProductRenderFormattedPriceInfoExtensionInterface": CatalogDataProductRenderFormattedPriceInfoExtensionInterface, + "CatalogDataProductRenderFormattedPriceInfoInterface": CatalogDataProductRenderFormattedPriceInfoInterface, + "CatalogDataProductRenderImageExtensionInterface": CatalogDataProductRenderImageExtensionInterface, + "CatalogDataProductRenderImageInterface": CatalogDataProductRenderImageInterface, + "CatalogDataProductRenderInterface": CatalogDataProductRenderInterface, + "CatalogDataProductRenderPriceInfoExtensionInterface": CatalogDataProductRenderPriceInfoExtensionInterface, + "CatalogDataProductRenderPriceInfoInterface": CatalogDataProductRenderPriceInfoInterface, + "CatalogDataProductRenderSearchResultsInterface": CatalogDataProductRenderSearchResultsInterface, + "CheckoutDataPaymentDetailsExtensionInterface": CheckoutDataPaymentDetailsExtensionInterface, + "CheckoutDataPaymentDetailsInterface": CheckoutDataPaymentDetailsInterface, + "CheckoutDataShippingInformationExtensionInterface": CheckoutDataShippingInformationExtensionInterface, + "CheckoutDataShippingInformationInterface": CheckoutDataShippingInformationInterface, + "CheckoutDataTotalsInformationExtensionInterface": CheckoutDataTotalsInformationExtensionInterface, + "CheckoutDataTotalsInformationInterface": CheckoutDataTotalsInformationInterface, + "ConfigurableProductDataConfigurableItemOptionValueExtensionInterface": ConfigurableProductDataConfigurableItemOptionValueExtensionInterface, + "ConfigurableProductDataConfigurableItemOptionValueInterface": ConfigurableProductDataConfigurableItemOptionValueInterface, + "CustomerDataAddressExtensionInterface": CustomerDataAddressExtensionInterface, + "CustomerDataAddressInterface": CustomerDataAddressInterface, + "CustomerDataCustomerExtensionInterface": CustomerDataCustomerExtensionInterface, + "CustomerDataCustomerInterface": CustomerDataCustomerInterface, + "CustomerDataRegionExtensionInterface": CustomerDataRegionExtensionInterface, + "CustomerDataRegionInterface": CustomerDataRegionInterface, + "DirectoryDataCountryInformationExtensionInterface": DirectoryDataCountryInformationExtensionInterface, + "DirectoryDataCountryInformationInterface": DirectoryDataCountryInformationInterface, + "DirectoryDataCurrencyInformationExtensionInterface": DirectoryDataCurrencyInformationExtensionInterface, + "DirectoryDataCurrencyInformationInterface": DirectoryDataCurrencyInformationInterface, + "DirectoryDataExchangeRateExtensionInterface": DirectoryDataExchangeRateExtensionInterface, + "DirectoryDataExchangeRateInterface": DirectoryDataExchangeRateInterface, + "DirectoryDataRegionInformationExtensionInterface": DirectoryDataRegionInformationExtensionInterface, + "DirectoryDataRegionInformationInterface": DirectoryDataRegionInformationInterface, + "DownloadableDataDownloadableOptionInterface": DownloadableDataDownloadableOptionInterface, + "ErrorErrors": ErrorErrors, + "ErrorErrorsItem": ErrorErrorsItem, + "ErrorParameters": ErrorParameters, + "ErrorParametersItem": ErrorParametersItem, + "ErrorResponse": ErrorResponse, + "FrameworkAttributeInterface": FrameworkAttributeInterface, + "FrameworkDataImageContentInterface": FrameworkDataImageContentInterface, + "FrameworkFilter": FrameworkFilter, + "FrameworkSearchAggregationInterface": FrameworkSearchAggregationInterface, + "FrameworkSearchAggregationValueInterface": FrameworkSearchAggregationValueInterface, + "FrameworkSearchBucketInterface": FrameworkSearchBucketInterface, + "FrameworkSearchDocumentInterface": FrameworkSearchDocumentInterface, + "FrameworkSearchFilterGroup": FrameworkSearchFilterGroup, + "FrameworkSearchSearchCriteriaInterface": FrameworkSearchSearchCriteriaInterface, + "FrameworkSearchSearchResultInterface": FrameworkSearchSearchResultInterface, + "FrameworkSortOrder": FrameworkSortOrder, + "GiftMessageDataMessageExtensionInterface": GiftMessageDataMessageExtensionInterface, + "GiftMessageDataMessageInterface": GiftMessageDataMessageInterface, + "InventoryInStorePickupApiDataPickupLocationExtensionInterface": InventoryInStorePickupApiDataPickupLocationExtensionInterface, + "InventoryInStorePickupApiDataPickupLocationInterface": InventoryInStorePickupApiDataPickupLocationInterface, + "InventoryInStorePickupApiDataSearchRequestAreaInterface": InventoryInStorePickupApiDataSearchRequestAreaInterface, + "InventoryInStorePickupApiDataSearchRequestExtensionInterface": InventoryInStorePickupApiDataSearchRequestExtensionInterface, + "InventoryInStorePickupApiDataSearchRequestFilterInterface": InventoryInStorePickupApiDataSearchRequestFilterInterface, + "InventoryInStorePickupApiDataSearchRequestFiltersInterface": InventoryInStorePickupApiDataSearchRequestFiltersInterface, + "InventoryInStorePickupApiDataSearchRequestInterface": InventoryInStorePickupApiDataSearchRequestInterface, + "InventoryInStorePickupApiDataSearchRequestProductInfoExtensionInterface": InventoryInStorePickupApiDataSearchRequestProductInfoExtensionInterface, + "InventoryInStorePickupApiDataSearchRequestProductInfoInterface": InventoryInStorePickupApiDataSearchRequestProductInfoInterface, + "InventoryInStorePickupApiDataSearchResultInterface": InventoryInStorePickupApiDataSearchResultInterface, + "MsrpDataProductRenderMsrpPriceInfoExtensionInterface": MsrpDataProductRenderMsrpPriceInfoExtensionInterface, + "MsrpDataProductRenderMsrpPriceInfoInterface": MsrpDataProductRenderMsrpPriceInfoInterface, + "QuoteDataAddressExtensionInterface": QuoteDataAddressExtensionInterface, + "QuoteDataAddressInterface": QuoteDataAddressInterface, + "QuoteDataCartExtensionInterface": QuoteDataCartExtensionInterface, + "QuoteDataCartInterface": QuoteDataCartInterface, + "QuoteDataCartItemExtensionInterface": QuoteDataCartItemExtensionInterface, + "QuoteDataCartItemInterface": QuoteDataCartItemInterface, + "QuoteDataCurrencyExtensionInterface": QuoteDataCurrencyExtensionInterface, + "QuoteDataCurrencyInterface": QuoteDataCurrencyInterface, + "QuoteDataPaymentExtensionInterface": QuoteDataPaymentExtensionInterface, + "QuoteDataPaymentInterface": QuoteDataPaymentInterface, + "QuoteDataPaymentMethodInterface": QuoteDataPaymentMethodInterface, + "QuoteDataProductOptionExtensionInterface": QuoteDataProductOptionExtensionInterface, + "QuoteDataProductOptionInterface": QuoteDataProductOptionInterface, + "QuoteDataShippingAssignmentExtensionInterface": QuoteDataShippingAssignmentExtensionInterface, + "QuoteDataShippingAssignmentInterface": QuoteDataShippingAssignmentInterface, + "QuoteDataShippingExtensionInterface": QuoteDataShippingExtensionInterface, + "QuoteDataShippingInterface": QuoteDataShippingInterface, + "QuoteDataShippingMethodExtensionInterface": QuoteDataShippingMethodExtensionInterface, + "QuoteDataShippingMethodInterface": QuoteDataShippingMethodInterface, + "QuoteDataTotalSegmentExtensionInterface": QuoteDataTotalSegmentExtensionInterface, + "QuoteDataTotalSegmentInterface": QuoteDataTotalSegmentInterface, + "QuoteDataTotalsAdditionalDataExtensionInterface": QuoteDataTotalsAdditionalDataExtensionInterface, + "QuoteDataTotalsAdditionalDataInterface": QuoteDataTotalsAdditionalDataInterface, + "QuoteDataTotalsExtensionInterface": QuoteDataTotalsExtensionInterface, + "QuoteDataTotalsInterface": QuoteDataTotalsInterface, + "QuoteDataTotalsItemExtensionInterface": QuoteDataTotalsItemExtensionInterface, + "QuoteDataTotalsItemInterface": QuoteDataTotalsItemInterface, + "SalesRuleDataDiscountDataInterface": SalesRuleDataDiscountDataInterface, + "SalesRuleDataRuleDiscountInterface": SalesRuleDataRuleDiscountInterface, + "TaxDataGrandTotalDetailsInterface": TaxDataGrandTotalDetailsInterface, + "TaxDataGrandTotalRatesInterface": TaxDataGrandTotalRatesInterface, + "VertexAddressValidationApiDataAddressInterface": VertexAddressValidationApiDataAddressInterface, + "VertexAddressValidationApiDataCleansedAddressInterface": VertexAddressValidationApiDataCleansedAddressInterface, + "WeeeDataProductRenderWeeeAdjustmentAttributeExtensionInterface": WeeeDataProductRenderWeeeAdjustmentAttributeExtensionInterface, + "WeeeDataProductRenderWeeeAdjustmentAttributeInterface": WeeeDataProductRenderWeeeAdjustmentAttributeInterface, +} + +export interface Authentication { + /** + * Apply authentication settings to header and query params. + */ + applyToRequest(requestOptions: localVarRequest.Options): void; +} + +export class HttpBasicAuth implements Authentication { + public username: string = ''; + public password: string = ''; + + applyToRequest(requestOptions: localVarRequest.Options): void { + requestOptions.auth = { + username: this.username, password: this.password + } + } +} + +export class ApiKeyAuth implements Authentication { + public apiKey: string = ''; + + constructor(private location: string, private paramName: string) { + } + + applyToRequest(requestOptions: localVarRequest.Options): void { + if (this.location == "query") { + (requestOptions.qs)[this.paramName] = this.apiKey; + } else if (this.location == "header" && requestOptions && requestOptions.headers) { + requestOptions.headers[this.paramName] = this.apiKey; + } + } +} + +export class OAuth implements Authentication { + public accessToken: string = ''; + + applyToRequest(requestOptions: localVarRequest.Options): void { + if (requestOptions && requestOptions.headers) { + requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; + } + } +} + +export class VoidAuth implements Authentication { + public username: string = ''; + public password: string = ''; + + applyToRequest(_: localVarRequest.Options): void { + // Do nothing + } +} + +export enum AmazonPaymentAddressManagementV1ApiApiKeys { +} + +export class AmazonPaymentAddressManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: AmazonPaymentAddressManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[AmazonPaymentAddressManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * + * @param amazonOrderReferenceId + * @param amazonPaymentAddressManagementV1GetBillingAddressPutBody + * @param {*} [options] Override http request options. + */ + public amazonPaymentAddressManagementV1GetBillingAddressPut (amazonOrderReferenceId: string, amazonPaymentAddressManagementV1GetBillingAddressPutBody?: AmazonPaymentAddressManagementV1GetBillingAddressPutBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: string; }> { + const localVarPath = this.basePath + '/V1/amazon-billing-address/{amazonOrderReferenceId}' + .replace('{' + 'amazonOrderReferenceId' + '}', encodeURIComponent(String(amazonOrderReferenceId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'amazonOrderReferenceId' is not null or undefined + if (amazonOrderReferenceId === null || amazonOrderReferenceId === undefined) { + throw new Error('Required parameter amazonOrderReferenceId was null or undefined when calling amazonPaymentAddressManagementV1GetBillingAddressPut.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(amazonPaymentAddressManagementV1GetBillingAddressPutBody, "AmazonPaymentAddressManagementV1GetBillingAddressPutBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: string; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "string"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * + * @param amazonOrderReferenceId + * @param amazonPaymentAddressManagementV1GetShippingAddressPutBody + * @param {*} [options] Override http request options. + */ + public amazonPaymentAddressManagementV1GetShippingAddressPut (amazonOrderReferenceId: string, amazonPaymentAddressManagementV1GetShippingAddressPutBody?: AmazonPaymentAddressManagementV1GetShippingAddressPutBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: string; }> { + const localVarPath = this.basePath + '/V1/amazon-shipping-address/{amazonOrderReferenceId}' + .replace('{' + 'amazonOrderReferenceId' + '}', encodeURIComponent(String(amazonOrderReferenceId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'amazonOrderReferenceId' is not null or undefined + if (amazonOrderReferenceId === null || amazonOrderReferenceId === undefined) { + throw new Error('Required parameter amazonOrderReferenceId was null or undefined when calling amazonPaymentAddressManagementV1GetShippingAddressPut.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(amazonPaymentAddressManagementV1GetShippingAddressPutBody, "AmazonPaymentAddressManagementV1GetShippingAddressPutBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: string; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "string"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum AmazonPaymentOrderInformationManagementV1ApiApiKeys { +} + +export class AmazonPaymentOrderInformationManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: AmazonPaymentOrderInformationManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[AmazonPaymentOrderInformationManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * + * @param {*} [options] Override http request options. + */ + public amazonPaymentOrderInformationManagementV1RemoveOrderReferenceDelete (options: any = {}) : Promise<{ response: http.ClientResponse; body: ErrorResponse; }> { + const localVarPath = this.basePath + '/V1/amazon/order-ref'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'DELETE', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: ErrorResponse; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "ErrorResponse"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum CatalogProductRenderListV1ApiApiKeys { +} + +export class CatalogProductRenderListV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: CatalogProductRenderListV1ApiApiKeys, value: string) { + (this.authentications as any)[CatalogProductRenderListV1ApiApiKeys[key]].apiKey = value; + } + /** + * Collect and retrieve the list of product render info. This info contains raw prices and formatted prices, product name, stock status, store_id, etc. + * @param storeId + * @param currencyCode + * @param searchCriteriaFilterGroups0Filters0Field Field + * @param searchCriteriaFilterGroups0Filters0Value Value + * @param searchCriteriaFilterGroups0Filters0ConditionType Condition type + * @param searchCriteriaSortOrders0Field Sorting field. + * @param searchCriteriaSortOrders0Direction Sorting direction. + * @param searchCriteriaPageSize Page size. + * @param searchCriteriaCurrentPage Current page. + * @param {*} [options] Override http request options. + */ + public catalogProductRenderListV1GetListGet (storeId: number, currencyCode: string, searchCriteriaFilterGroups0Filters0Field?: string, searchCriteriaFilterGroups0Filters0Value?: string, searchCriteriaFilterGroups0Filters0ConditionType?: string, searchCriteriaSortOrders0Field?: string, searchCriteriaSortOrders0Direction?: string, searchCriteriaPageSize?: number, searchCriteriaCurrentPage?: number, options: any = {}) : Promise<{ response: http.ClientResponse; body: CatalogDataProductRenderSearchResultsInterface; }> { + const localVarPath = this.basePath + '/V1/products-render-info'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'storeId' is not null or undefined + if (storeId === null || storeId === undefined) { + throw new Error('Required parameter storeId was null or undefined when calling catalogProductRenderListV1GetListGet.'); + } + + // verify required parameter 'currencyCode' is not null or undefined + if (currencyCode === null || currencyCode === undefined) { + throw new Error('Required parameter currencyCode was null or undefined when calling catalogProductRenderListV1GetListGet.'); + } + + if (searchCriteriaFilterGroups0Filters0Field !== undefined) { + localVarQueryParameters['searchCriteria[filterGroups][0][filters][0][field]'] = ObjectSerializer.serialize(searchCriteriaFilterGroups0Filters0Field, "string"); + } + + if (searchCriteriaFilterGroups0Filters0Value !== undefined) { + localVarQueryParameters['searchCriteria[filterGroups][0][filters][0][value]'] = ObjectSerializer.serialize(searchCriteriaFilterGroups0Filters0Value, "string"); + } + + if (searchCriteriaFilterGroups0Filters0ConditionType !== undefined) { + localVarQueryParameters['searchCriteria[filterGroups][0][filters][0][conditionType]'] = ObjectSerializer.serialize(searchCriteriaFilterGroups0Filters0ConditionType, "string"); + } + + if (searchCriteriaSortOrders0Field !== undefined) { + localVarQueryParameters['searchCriteria[sortOrders][0][field]'] = ObjectSerializer.serialize(searchCriteriaSortOrders0Field, "string"); + } + + if (searchCriteriaSortOrders0Direction !== undefined) { + localVarQueryParameters['searchCriteria[sortOrders][0][direction]'] = ObjectSerializer.serialize(searchCriteriaSortOrders0Direction, "string"); + } + + if (searchCriteriaPageSize !== undefined) { + localVarQueryParameters['searchCriteria[pageSize]'] = ObjectSerializer.serialize(searchCriteriaPageSize, "number"); + } + + if (searchCriteriaCurrentPage !== undefined) { + localVarQueryParameters['searchCriteria[currentPage]'] = ObjectSerializer.serialize(searchCriteriaCurrentPage, "number"); + } + + if (storeId !== undefined) { + localVarQueryParameters['storeId'] = ObjectSerializer.serialize(storeId, "number"); + } + + if (currencyCode !== undefined) { + localVarQueryParameters['currencyCode'] = ObjectSerializer.serialize(currencyCode, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: CatalogDataProductRenderSearchResultsInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "CatalogDataProductRenderSearchResultsInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum CheckoutGuestPaymentInformationManagementV1ApiApiKeys { +} + +export class CheckoutGuestPaymentInformationManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: CheckoutGuestPaymentInformationManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[CheckoutGuestPaymentInformationManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * Get payment information + * @param cartId + * @param {*} [options] Override http request options. + */ + public checkoutGuestPaymentInformationManagementV1GetPaymentInformationGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: CheckoutDataPaymentDetailsInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/payment-information' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling checkoutGuestPaymentInformationManagementV1GetPaymentInformationGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: CheckoutDataPaymentDetailsInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "CheckoutDataPaymentDetailsInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Set payment information and place order for a specified cart. + * @param cartId + * @param checkoutGuestPaymentInformationManagementV1SavePaymentInformationAndPlaceOrderPostBody + * @param {*} [options] Override http request options. + */ + public checkoutGuestPaymentInformationManagementV1SavePaymentInformationAndPlaceOrderPost (cartId: string, checkoutGuestPaymentInformationManagementV1SavePaymentInformationAndPlaceOrderPostBody?: CheckoutGuestPaymentInformationManagementV1SavePaymentInformationAndPlaceOrderPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: number; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/payment-information' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling checkoutGuestPaymentInformationManagementV1SavePaymentInformationAndPlaceOrderPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(checkoutGuestPaymentInformationManagementV1SavePaymentInformationAndPlaceOrderPostBody, "CheckoutGuestPaymentInformationManagementV1SavePaymentInformationAndPlaceOrderPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: number; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "number"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Set payment information for a specified cart. + * @param cartId + * @param checkoutGuestPaymentInformationManagementV1SavePaymentInformationPostBody + * @param {*} [options] Override http request options. + */ + public checkoutGuestPaymentInformationManagementV1SavePaymentInformationPost (cartId: string, checkoutGuestPaymentInformationManagementV1SavePaymentInformationPostBody?: CheckoutGuestPaymentInformationManagementV1SavePaymentInformationPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: number; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/set-payment-information' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling checkoutGuestPaymentInformationManagementV1SavePaymentInformationPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(checkoutGuestPaymentInformationManagementV1SavePaymentInformationPostBody, "CheckoutGuestPaymentInformationManagementV1SavePaymentInformationPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: number; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "number"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum CheckoutGuestShippingInformationManagementV1ApiApiKeys { +} + +export class CheckoutGuestShippingInformationManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: CheckoutGuestShippingInformationManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[CheckoutGuestShippingInformationManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * + * @param cartId + * @param checkoutGuestShippingInformationManagementV1SaveAddressInformationPostBody + * @param {*} [options] Override http request options. + */ + public checkoutGuestShippingInformationManagementV1SaveAddressInformationPost (cartId: string, checkoutGuestShippingInformationManagementV1SaveAddressInformationPostBody?: CheckoutGuestShippingInformationManagementV1SaveAddressInformationPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: CheckoutDataPaymentDetailsInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/shipping-information' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling checkoutGuestShippingInformationManagementV1SaveAddressInformationPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(checkoutGuestShippingInformationManagementV1SaveAddressInformationPostBody, "CheckoutGuestShippingInformationManagementV1SaveAddressInformationPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: CheckoutDataPaymentDetailsInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "CheckoutDataPaymentDetailsInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum CheckoutGuestTotalsInformationManagementV1ApiApiKeys { +} + +export class CheckoutGuestTotalsInformationManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: CheckoutGuestTotalsInformationManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[CheckoutGuestTotalsInformationManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * Calculate quote totals based on address and shipping method. + * @param cartId + * @param checkoutGuestTotalsInformationManagementV1CalculatePostBody + * @param {*} [options] Override http request options. + */ + public checkoutGuestTotalsInformationManagementV1CalculatePost (cartId: string, checkoutGuestTotalsInformationManagementV1CalculatePostBody?: CheckoutGuestTotalsInformationManagementV1CalculatePostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: QuoteDataTotalsInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/totals-information' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling checkoutGuestTotalsInformationManagementV1CalculatePost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(checkoutGuestTotalsInformationManagementV1CalculatePostBody, "CheckoutGuestTotalsInformationManagementV1CalculatePostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: QuoteDataTotalsInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "QuoteDataTotalsInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum CustomerAccountManagementV1ApiApiKeys { +} + +export class CustomerAccountManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: CustomerAccountManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[CustomerAccountManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * Create customer account. Perform necessary business operations like sending email. + * @param customerAccountManagementV1CreateAccountPostBody + * @param {*} [options] Override http request options. + */ + public customerAccountManagementV1CreateAccountPost (customerAccountManagementV1CreateAccountPostBody?: CustomerAccountManagementV1CreateAccountPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: CustomerDataCustomerInterface; }> { + const localVarPath = this.basePath + '/V1/customers'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(customerAccountManagementV1CreateAccountPostBody, "CustomerAccountManagementV1CreateAccountPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: CustomerDataCustomerInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "CustomerDataCustomerInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Send an email to the customer with a password reset link. + * @param customerAccountManagementV1InitiatePasswordResetPutBody + * @param {*} [options] Override http request options. + */ + public customerAccountManagementV1InitiatePasswordResetPut (customerAccountManagementV1InitiatePasswordResetPutBody?: CustomerAccountManagementV1InitiatePasswordResetPutBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/customers/password'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(customerAccountManagementV1InitiatePasswordResetPutBody, "CustomerAccountManagementV1InitiatePasswordResetPutBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Check if given email is associated with a customer account in given website. + * @param customerAccountManagementV1IsEmailAvailablePostBody + * @param {*} [options] Override http request options. + */ + public customerAccountManagementV1IsEmailAvailablePost (customerAccountManagementV1IsEmailAvailablePostBody?: CustomerAccountManagementV1IsEmailAvailablePostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/customers/isEmailAvailable'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(customerAccountManagementV1IsEmailAvailablePostBody, "CustomerAccountManagementV1IsEmailAvailablePostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Reset customer password. + * @param customerAccountManagementV1ResetPasswordPostBody + * @param {*} [options] Override http request options. + */ + public customerAccountManagementV1ResetPasswordPost (customerAccountManagementV1ResetPasswordPostBody?: CustomerAccountManagementV1ResetPasswordPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/customers/resetPassword'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(customerAccountManagementV1ResetPasswordPostBody, "CustomerAccountManagementV1ResetPasswordPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Check if password reset token is valid. + * @param customerId If null is given then a customer will be matched by the RP token. + * @param resetPasswordLinkToken + * @param {*} [options] Override http request options. + */ + public customerAccountManagementV1ValidateResetPasswordLinkTokenGet (customerId: number, resetPasswordLinkToken: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/customers/{customerId}/password/resetLinkToken/{resetPasswordLinkToken}' + .replace('{' + 'customerId' + '}', encodeURIComponent(String(customerId))) + .replace('{' + 'resetPasswordLinkToken' + '}', encodeURIComponent(String(resetPasswordLinkToken))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'customerId' is not null or undefined + if (customerId === null || customerId === undefined) { + throw new Error('Required parameter customerId was null or undefined when calling customerAccountManagementV1ValidateResetPasswordLinkTokenGet.'); + } + + // verify required parameter 'resetPasswordLinkToken' is not null or undefined + if (resetPasswordLinkToken === null || resetPasswordLinkToken === undefined) { + throw new Error('Required parameter resetPasswordLinkToken was null or undefined when calling customerAccountManagementV1ValidateResetPasswordLinkTokenGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum DirectoryCountryInformationAcquirerV1ApiApiKeys { +} + +export class DirectoryCountryInformationAcquirerV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: DirectoryCountryInformationAcquirerV1ApiApiKeys, value: string) { + (this.authentications as any)[DirectoryCountryInformationAcquirerV1ApiApiKeys[key]].apiKey = value; + } + /** + * Get all countries and regions information for the store. + * @param {*} [options] Override http request options. + */ + public directoryCountryInformationAcquirerV1GetCountriesInfoGet (options: any = {}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/V1/directory/countries'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Get country and region information for the store. + * @param countryId + * @param {*} [options] Override http request options. + */ + public directoryCountryInformationAcquirerV1GetCountryInfoGet (countryId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: DirectoryDataCountryInformationInterface; }> { + const localVarPath = this.basePath + '/V1/directory/countries/{countryId}' + .replace('{' + 'countryId' + '}', encodeURIComponent(String(countryId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'countryId' is not null or undefined + if (countryId === null || countryId === undefined) { + throw new Error('Required parameter countryId was null or undefined when calling directoryCountryInformationAcquirerV1GetCountryInfoGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: DirectoryDataCountryInformationInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "DirectoryDataCountryInformationInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum DirectoryCurrencyInformationAcquirerV1ApiApiKeys { +} + +export class DirectoryCurrencyInformationAcquirerV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: DirectoryCurrencyInformationAcquirerV1ApiApiKeys, value: string) { + (this.authentications as any)[DirectoryCurrencyInformationAcquirerV1ApiApiKeys[key]].apiKey = value; + } + /** + * Get currency information for the store. + * @param {*} [options] Override http request options. + */ + public directoryCurrencyInformationAcquirerV1GetCurrencyInfoGet (options: any = {}) : Promise<{ response: http.ClientResponse; body: DirectoryDataCurrencyInformationInterface; }> { + const localVarPath = this.basePath + '/V1/directory/currency'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: DirectoryDataCurrencyInformationInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "DirectoryDataCurrencyInformationInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum GiftMessageGuestCartRepositoryV1ApiApiKeys { +} + +export class GiftMessageGuestCartRepositoryV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: GiftMessageGuestCartRepositoryV1ApiApiKeys, value: string) { + (this.authentications as any)[GiftMessageGuestCartRepositoryV1ApiApiKeys[key]].apiKey = value; + } + /** + * Return the gift message for a specified order. + * @param cartId The shopping cart ID. + * @param {*} [options] Override http request options. + */ + public giftMessageGuestCartRepositoryV1GetGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: GiftMessageDataMessageInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/gift-message' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling giftMessageGuestCartRepositoryV1GetGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: GiftMessageDataMessageInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "GiftMessageDataMessageInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Set the gift message for an entire order. + * @param cartId The cart ID. + * @param giftMessageGuestCartRepositoryV1SavePostBody + * @param {*} [options] Override http request options. + */ + public giftMessageGuestCartRepositoryV1SavePost (cartId: string, giftMessageGuestCartRepositoryV1SavePostBody?: GiftMessageGuestCartRepositoryV1SavePostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/gift-message' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling giftMessageGuestCartRepositoryV1SavePost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(giftMessageGuestCartRepositoryV1SavePostBody, "GiftMessageGuestCartRepositoryV1SavePostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum GiftMessageGuestItemRepositoryV1ApiApiKeys { +} + +export class GiftMessageGuestItemRepositoryV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: GiftMessageGuestItemRepositoryV1ApiApiKeys, value: string) { + (this.authentications as any)[GiftMessageGuestItemRepositoryV1ApiApiKeys[key]].apiKey = value; + } + /** + * Return the gift message for a specified item in a specified shopping cart. + * @param cartId The shopping cart ID. + * @param itemId The item ID. + * @param {*} [options] Override http request options. + */ + public giftMessageGuestItemRepositoryV1GetGet (cartId: string, itemId: number, options: any = {}) : Promise<{ response: http.ClientResponse; body: GiftMessageDataMessageInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/gift-message/{itemId}' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))) + .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling giftMessageGuestItemRepositoryV1GetGet.'); + } + + // verify required parameter 'itemId' is not null or undefined + if (itemId === null || itemId === undefined) { + throw new Error('Required parameter itemId was null or undefined when calling giftMessageGuestItemRepositoryV1GetGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: GiftMessageDataMessageInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "GiftMessageDataMessageInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Set the gift message for a specified item in a specified shopping cart. + * @param cartId The cart ID. + * @param itemId The item ID. + * @param giftMessageGuestItemRepositoryV1SavePostBody + * @param {*} [options] Override http request options. + */ + public giftMessageGuestItemRepositoryV1SavePost (cartId: string, itemId: number, giftMessageGuestItemRepositoryV1SavePostBody?: GiftMessageGuestItemRepositoryV1SavePostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/gift-message/{itemId}' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))) + .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling giftMessageGuestItemRepositoryV1SavePost.'); + } + + // verify required parameter 'itemId' is not null or undefined + if (itemId === null || itemId === undefined) { + throw new Error('Required parameter itemId was null or undefined when calling giftMessageGuestItemRepositoryV1SavePost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(giftMessageGuestItemRepositoryV1SavePostBody, "GiftMessageGuestItemRepositoryV1SavePostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum IntegrationAdminTokenServiceV1ApiApiKeys { +} + +export class IntegrationAdminTokenServiceV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: IntegrationAdminTokenServiceV1ApiApiKeys, value: string) { + (this.authentications as any)[IntegrationAdminTokenServiceV1ApiApiKeys[key]].apiKey = value; + } + /** + * Create access token for admin given the admin credentials. + * @param integrationAdminTokenServiceV1CreateAdminAccessTokenPostBody + * @param {*} [options] Override http request options. + */ + public integrationAdminTokenServiceV1CreateAdminAccessTokenPost (integrationAdminTokenServiceV1CreateAdminAccessTokenPostBody?: IntegrationAdminTokenServiceV1CreateAdminAccessTokenPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: string; }> { + const localVarPath = this.basePath + '/V1/integration/admin/token'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(integrationAdminTokenServiceV1CreateAdminAccessTokenPostBody, "IntegrationAdminTokenServiceV1CreateAdminAccessTokenPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: string; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "string"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum IntegrationCustomerTokenServiceV1ApiApiKeys { +} + +export class IntegrationCustomerTokenServiceV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: IntegrationCustomerTokenServiceV1ApiApiKeys, value: string) { + (this.authentications as any)[IntegrationCustomerTokenServiceV1ApiApiKeys[key]].apiKey = value; + } + /** + * Create access token for admin given the customer credentials. + * @param integrationCustomerTokenServiceV1CreateCustomerAccessTokenPostBody + * @param {*} [options] Override http request options. + */ + public integrationCustomerTokenServiceV1CreateCustomerAccessTokenPost (integrationCustomerTokenServiceV1CreateCustomerAccessTokenPostBody?: IntegrationCustomerTokenServiceV1CreateCustomerAccessTokenPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: string; }> { + const localVarPath = this.basePath + '/V1/integration/customer/token'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(integrationCustomerTokenServiceV1CreateCustomerAccessTokenPostBody, "IntegrationCustomerTokenServiceV1CreateCustomerAccessTokenPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: string; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "string"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum InventoryInStorePickupApiGetPickupLocationsV1ApiApiKeys { +} + +export class InventoryInStorePickupApiGetPickupLocationsV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: InventoryInStorePickupApiGetPickupLocationsV1ApiApiKeys, value: string) { + (this.authentications as any)[InventoryInStorePickupApiGetPickupLocationsV1ApiApiKeys[key]].apiKey = value; + } + /** + * Get Pickup Locations according to the results of filtration by Search Request. + * @param searchRequestAreaRadius Search radius in KM. + * @param searchRequestAreaSearchTerm Search term string. + * @param searchRequestFiltersCountryValue Value. + * @param searchRequestFiltersCountryConditionType Condition Type. + * @param searchRequestFiltersPostcodeValue Value. + * @param searchRequestFiltersPostcodeConditionType Condition Type. + * @param searchRequestFiltersRegionValue Value. + * @param searchRequestFiltersRegionConditionType Condition Type. + * @param searchRequestFiltersRegionIdValue Value. + * @param searchRequestFiltersRegionIdConditionType Condition Type. + * @param searchRequestFiltersCityValue Value. + * @param searchRequestFiltersCityConditionType Condition Type. + * @param searchRequestFiltersStreetValue Value. + * @param searchRequestFiltersStreetConditionType Condition Type. + * @param searchRequestFiltersNameValue Value. + * @param searchRequestFiltersNameConditionType Condition Type. + * @param searchRequestFiltersPickupLocationCodeValue Value. + * @param searchRequestFiltersPickupLocationCodeConditionType Condition Type. + * @param searchRequestPageSize Page size. + * @param searchRequestCurrentPage Current page. + * @param searchRequestScopeType Sales Channel Type. + * @param searchRequestScopeCode Sales Channel code. + * @param searchRequestSort0Field Sorting field. + * @param searchRequestSort0Direction Sorting direction. + * @param searchRequestExtensionAttributesProductsInfo0Sku Product SKU. + * @param {*} [options] Override http request options. + */ + public inventoryInStorePickupApiGetPickupLocationsV1ExecuteGet (searchRequestAreaRadius?: number, searchRequestAreaSearchTerm?: string, searchRequestFiltersCountryValue?: string, searchRequestFiltersCountryConditionType?: string, searchRequestFiltersPostcodeValue?: string, searchRequestFiltersPostcodeConditionType?: string, searchRequestFiltersRegionValue?: string, searchRequestFiltersRegionConditionType?: string, searchRequestFiltersRegionIdValue?: string, searchRequestFiltersRegionIdConditionType?: string, searchRequestFiltersCityValue?: string, searchRequestFiltersCityConditionType?: string, searchRequestFiltersStreetValue?: string, searchRequestFiltersStreetConditionType?: string, searchRequestFiltersNameValue?: string, searchRequestFiltersNameConditionType?: string, searchRequestFiltersPickupLocationCodeValue?: string, searchRequestFiltersPickupLocationCodeConditionType?: string, searchRequestPageSize?: number, searchRequestCurrentPage?: number, searchRequestScopeType?: string, searchRequestScopeCode?: string, searchRequestSort0Field?: string, searchRequestSort0Direction?: string, searchRequestExtensionAttributesProductsInfo0Sku?: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: InventoryInStorePickupApiDataSearchResultInterface; }> { + const localVarPath = this.basePath + '/V1/inventory/in-store-pickup/pickup-locations/'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + if (searchRequestAreaRadius !== undefined) { + localVarQueryParameters['searchRequest[area][radius]'] = ObjectSerializer.serialize(searchRequestAreaRadius, "number"); + } + + if (searchRequestAreaSearchTerm !== undefined) { + localVarQueryParameters['searchRequest[area][searchTerm]'] = ObjectSerializer.serialize(searchRequestAreaSearchTerm, "string"); + } + + if (searchRequestFiltersCountryValue !== undefined) { + localVarQueryParameters['searchRequest[filters][country][value]'] = ObjectSerializer.serialize(searchRequestFiltersCountryValue, "string"); + } + + if (searchRequestFiltersCountryConditionType !== undefined) { + localVarQueryParameters['searchRequest[filters][country][conditionType]'] = ObjectSerializer.serialize(searchRequestFiltersCountryConditionType, "string"); + } + + if (searchRequestFiltersPostcodeValue !== undefined) { + localVarQueryParameters['searchRequest[filters][postcode][value]'] = ObjectSerializer.serialize(searchRequestFiltersPostcodeValue, "string"); + } + + if (searchRequestFiltersPostcodeConditionType !== undefined) { + localVarQueryParameters['searchRequest[filters][postcode][conditionType]'] = ObjectSerializer.serialize(searchRequestFiltersPostcodeConditionType, "string"); + } + + if (searchRequestFiltersRegionValue !== undefined) { + localVarQueryParameters['searchRequest[filters][region][value]'] = ObjectSerializer.serialize(searchRequestFiltersRegionValue, "string"); + } + + if (searchRequestFiltersRegionConditionType !== undefined) { + localVarQueryParameters['searchRequest[filters][region][conditionType]'] = ObjectSerializer.serialize(searchRequestFiltersRegionConditionType, "string"); + } + + if (searchRequestFiltersRegionIdValue !== undefined) { + localVarQueryParameters['searchRequest[filters][regionId][value]'] = ObjectSerializer.serialize(searchRequestFiltersRegionIdValue, "string"); + } + + if (searchRequestFiltersRegionIdConditionType !== undefined) { + localVarQueryParameters['searchRequest[filters][regionId][conditionType]'] = ObjectSerializer.serialize(searchRequestFiltersRegionIdConditionType, "string"); + } + + if (searchRequestFiltersCityValue !== undefined) { + localVarQueryParameters['searchRequest[filters][city][value]'] = ObjectSerializer.serialize(searchRequestFiltersCityValue, "string"); + } + + if (searchRequestFiltersCityConditionType !== undefined) { + localVarQueryParameters['searchRequest[filters][city][conditionType]'] = ObjectSerializer.serialize(searchRequestFiltersCityConditionType, "string"); + } + + if (searchRequestFiltersStreetValue !== undefined) { + localVarQueryParameters['searchRequest[filters][street][value]'] = ObjectSerializer.serialize(searchRequestFiltersStreetValue, "string"); + } + + if (searchRequestFiltersStreetConditionType !== undefined) { + localVarQueryParameters['searchRequest[filters][street][conditionType]'] = ObjectSerializer.serialize(searchRequestFiltersStreetConditionType, "string"); + } + + if (searchRequestFiltersNameValue !== undefined) { + localVarQueryParameters['searchRequest[filters][name][value]'] = ObjectSerializer.serialize(searchRequestFiltersNameValue, "string"); + } + + if (searchRequestFiltersNameConditionType !== undefined) { + localVarQueryParameters['searchRequest[filters][name][conditionType]'] = ObjectSerializer.serialize(searchRequestFiltersNameConditionType, "string"); + } + + if (searchRequestFiltersPickupLocationCodeValue !== undefined) { + localVarQueryParameters['searchRequest[filters][pickupLocationCode][value]'] = ObjectSerializer.serialize(searchRequestFiltersPickupLocationCodeValue, "string"); + } + + if (searchRequestFiltersPickupLocationCodeConditionType !== undefined) { + localVarQueryParameters['searchRequest[filters][pickupLocationCode][conditionType]'] = ObjectSerializer.serialize(searchRequestFiltersPickupLocationCodeConditionType, "string"); + } + + if (searchRequestPageSize !== undefined) { + localVarQueryParameters['searchRequest[pageSize]'] = ObjectSerializer.serialize(searchRequestPageSize, "number"); + } + + if (searchRequestCurrentPage !== undefined) { + localVarQueryParameters['searchRequest[currentPage]'] = ObjectSerializer.serialize(searchRequestCurrentPage, "number"); + } + + if (searchRequestScopeType !== undefined) { + localVarQueryParameters['searchRequest[scopeType]'] = ObjectSerializer.serialize(searchRequestScopeType, "string"); + } + + if (searchRequestScopeCode !== undefined) { + localVarQueryParameters['searchRequest[scopeCode]'] = ObjectSerializer.serialize(searchRequestScopeCode, "string"); + } + + if (searchRequestSort0Field !== undefined) { + localVarQueryParameters['searchRequest[sort][0][field]'] = ObjectSerializer.serialize(searchRequestSort0Field, "string"); + } + + if (searchRequestSort0Direction !== undefined) { + localVarQueryParameters['searchRequest[sort][0][direction]'] = ObjectSerializer.serialize(searchRequestSort0Direction, "string"); + } + + if (searchRequestExtensionAttributesProductsInfo0Sku !== undefined) { + localVarQueryParameters['searchRequest[extensionAttributes][productsInfo][0][sku]'] = ObjectSerializer.serialize(searchRequestExtensionAttributesProductsInfo0Sku, "string"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: InventoryInStorePickupApiDataSearchResultInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "InventoryInStorePickupApiDataSearchResultInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum MageplazaSmtpCheckoutManagementV1ApiApiKeys { +} + +export class MageplazaSmtpCheckoutManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: MageplazaSmtpCheckoutManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[MageplazaSmtpCheckoutManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * + * @param cartId + * @param mageplazaSmtpCheckoutManagementV1UpdateOrderPostBody + * @param {*} [options] Override http request options. + */ + public mageplazaSmtpCheckoutManagementV1UpdateOrderPost (cartId: string, mageplazaSmtpCheckoutManagementV1UpdateOrderPostBody?: MageplazaSmtpCheckoutManagementV1UpdateOrderPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/carts/{cartId}/update-order' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling mageplazaSmtpCheckoutManagementV1UpdateOrderPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(mageplazaSmtpCheckoutManagementV1UpdateOrderPostBody, "MageplazaSmtpCheckoutManagementV1UpdateOrderPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestBillingAddressManagementV1ApiApiKeys { +} + +export class QuoteGuestBillingAddressManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestBillingAddressManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestBillingAddressManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * Assign a specified billing address to a specified cart. + * @param cartId The cart ID. + * @param quoteGuestBillingAddressManagementV1AssignPostBody + * @param {*} [options] Override http request options. + */ + public quoteGuestBillingAddressManagementV1AssignPost (cartId: string, quoteGuestBillingAddressManagementV1AssignPostBody?: QuoteGuestBillingAddressManagementV1AssignPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: number; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/billing-address' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestBillingAddressManagementV1AssignPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(quoteGuestBillingAddressManagementV1AssignPostBody, "QuoteGuestBillingAddressManagementV1AssignPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: number; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "number"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Return the billing address for a specified quote. + * @param cartId The cart ID. + * @param {*} [options] Override http request options. + */ + public quoteGuestBillingAddressManagementV1GetGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: QuoteDataAddressInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/billing-address' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestBillingAddressManagementV1GetGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: QuoteDataAddressInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "QuoteDataAddressInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestCartItemRepositoryV1ApiApiKeys { +} + +export class QuoteGuestCartItemRepositoryV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestCartItemRepositoryV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestCartItemRepositoryV1ApiApiKeys[key]].apiKey = value; + } + /** + * Remove the specified item from the specified cart. + * @param cartId The cart ID. + * @param itemId The item ID of the item to be removed. + * @param {*} [options] Override http request options. + */ + public quoteGuestCartItemRepositoryV1DeleteByIdDelete (cartId: string, itemId: number, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/items/{itemId}' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))) + .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCartItemRepositoryV1DeleteByIdDelete.'); + } + + // verify required parameter 'itemId' is not null or undefined + if (itemId === null || itemId === undefined) { + throw new Error('Required parameter itemId was null or undefined when calling quoteGuestCartItemRepositoryV1DeleteByIdDelete.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'DELETE', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * List items that are assigned to a specified cart. + * @param cartId The cart ID. + * @param {*} [options] Override http request options. + */ + public quoteGuestCartItemRepositoryV1GetListGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/items' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCartItemRepositoryV1GetListGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Add/update the specified cart item. + * @param cartId + * @param quoteGuestCartItemRepositoryV1SavePostBody + * @param {*} [options] Override http request options. + */ + public quoteGuestCartItemRepositoryV1SavePost (cartId: string, quoteGuestCartItemRepositoryV1SavePostBody?: QuoteGuestCartItemRepositoryV1SavePostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: QuoteDataCartItemInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/items' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCartItemRepositoryV1SavePost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(quoteGuestCartItemRepositoryV1SavePostBody, "QuoteGuestCartItemRepositoryV1SavePostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: QuoteDataCartItemInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "QuoteDataCartItemInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Add/update the specified cart item. + * @param cartId + * @param itemId + * @param quoteGuestCartItemRepositoryV1SavePutBody + * @param {*} [options] Override http request options. + */ + public quoteGuestCartItemRepositoryV1SavePut (cartId: string, itemId: string, quoteGuestCartItemRepositoryV1SavePutBody?: QuoteGuestCartItemRepositoryV1SavePutBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: QuoteDataCartItemInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/items/{itemId}' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))) + .replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCartItemRepositoryV1SavePut.'); + } + + // verify required parameter 'itemId' is not null or undefined + if (itemId === null || itemId === undefined) { + throw new Error('Required parameter itemId was null or undefined when calling quoteGuestCartItemRepositoryV1SavePut.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(quoteGuestCartItemRepositoryV1SavePutBody, "QuoteGuestCartItemRepositoryV1SavePutBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: QuoteDataCartItemInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "QuoteDataCartItemInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestCartManagementV1ApiApiKeys { +} + +export class QuoteGuestCartManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestCartManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestCartManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * Enable an customer or guest user to create an empty cart and quote for an anonymous customer. + * @param {*} [options] Override http request options. + */ + public quoteGuestCartManagementV1CreateEmptyCartPost (options: any = {}) : Promise<{ response: http.ClientResponse; body: string; }> { + const localVarPath = this.basePath + '/V1/guest-carts'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: string; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "string"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Place an order for a specified cart. + * @param cartId The cart ID. + * @param quoteGuestCartManagementV1PlaceOrderPutBody + * @param {*} [options] Override http request options. + */ + public quoteGuestCartManagementV1PlaceOrderPut (cartId: string, quoteGuestCartManagementV1PlaceOrderPutBody?: QuoteGuestCartManagementV1PlaceOrderPutBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: number; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/order' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCartManagementV1PlaceOrderPut.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(quoteGuestCartManagementV1PlaceOrderPutBody, "QuoteGuestCartManagementV1PlaceOrderPutBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: number; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "number"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestCartRepositoryV1ApiApiKeys { +} + +export class QuoteGuestCartRepositoryV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestCartRepositoryV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestCartRepositoryV1ApiApiKeys[key]].apiKey = value; + } + /** + * Enable a guest user to return information for a specified cart. + * @param cartId + * @param {*} [options] Override http request options. + */ + public quoteGuestCartRepositoryV1GetGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: QuoteDataCartInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCartRepositoryV1GetGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: QuoteDataCartInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "QuoteDataCartInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestCartTotalManagementV1ApiApiKeys { +} + +export class QuoteGuestCartTotalManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestCartTotalManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestCartTotalManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * Set shipping/billing methods and additional data for cart and collect totals for guest. + * @param cartId The cart ID. + * @param quoteGuestCartTotalManagementV1CollectTotalsPutBody + * @param {*} [options] Override http request options. + */ + public quoteGuestCartTotalManagementV1CollectTotalsPut (cartId: string, quoteGuestCartTotalManagementV1CollectTotalsPutBody?: QuoteGuestCartTotalManagementV1CollectTotalsPutBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: QuoteDataTotalsInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/collect-totals' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCartTotalManagementV1CollectTotalsPut.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(quoteGuestCartTotalManagementV1CollectTotalsPutBody, "QuoteGuestCartTotalManagementV1CollectTotalsPutBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: QuoteDataTotalsInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "QuoteDataTotalsInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestCartTotalRepositoryV1ApiApiKeys { +} + +export class QuoteGuestCartTotalRepositoryV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestCartTotalRepositoryV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestCartTotalRepositoryV1ApiApiKeys[key]].apiKey = value; + } + /** + * Return quote totals data for a specified cart. + * @param cartId The cart ID. + * @param {*} [options] Override http request options. + */ + public quoteGuestCartTotalRepositoryV1GetGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: QuoteDataTotalsInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/totals' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCartTotalRepositoryV1GetGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: QuoteDataTotalsInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "QuoteDataTotalsInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestCouponManagementV1ApiApiKeys { +} + +export class QuoteGuestCouponManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestCouponManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestCouponManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * Return information for a coupon in a specified cart. + * @param cartId The cart ID. + * @param {*} [options] Override http request options. + */ + public quoteGuestCouponManagementV1GetGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: string; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/coupons' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCouponManagementV1GetGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: string; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "string"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Delete a coupon from a specified cart. + * @param cartId The cart ID. + * @param {*} [options] Override http request options. + */ + public quoteGuestCouponManagementV1RemoveDelete (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/coupons' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCouponManagementV1RemoveDelete.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'DELETE', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Add a coupon by code to a specified cart. + * @param cartId The cart ID. + * @param couponCode The coupon code data. + * @param {*} [options] Override http request options. + */ + public quoteGuestCouponManagementV1SetPut (cartId: string, couponCode: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: boolean; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/coupons/{couponCode}' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))) + .replace('{' + 'couponCode' + '}', encodeURIComponent(String(couponCode))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestCouponManagementV1SetPut.'); + } + + // verify required parameter 'couponCode' is not null or undefined + if (couponCode === null || couponCode === undefined) { + throw new Error('Required parameter couponCode was null or undefined when calling quoteGuestCouponManagementV1SetPut.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: boolean; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "boolean"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestPaymentMethodManagementV1ApiApiKeys { +} + +export class QuoteGuestPaymentMethodManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestPaymentMethodManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestPaymentMethodManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * Return the payment method for a specified shopping cart. + * @param cartId The cart ID. + * @param {*} [options] Override http request options. + */ + public quoteGuestPaymentMethodManagementV1GetGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: QuoteDataPaymentInterface; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/selected-payment-method' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestPaymentMethodManagementV1GetGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: QuoteDataPaymentInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "QuoteDataPaymentInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * List available payment methods for a specified shopping cart. This call returns an array of objects, but detailed information about each object’s attributes might not be included. See https://devdocs.magento.com/codelinks/attributes.html#GuestPaymentMethodManagementInterface to determine which call to use to get detailed information about all attributes for an object. + * @param cartId The cart ID. + * @param {*} [options] Override http request options. + */ + public quoteGuestPaymentMethodManagementV1GetListGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/payment-methods' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestPaymentMethodManagementV1GetListGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } + /** + * Add a specified payment method to a specified shopping cart. + * @param cartId The cart ID. + * @param quoteGuestPaymentMethodManagementV1SetPutBody + * @param {*} [options] Override http request options. + */ + public quoteGuestPaymentMethodManagementV1SetPut (cartId: string, quoteGuestPaymentMethodManagementV1SetPutBody?: QuoteGuestPaymentMethodManagementV1SetPutBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: number; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/selected-payment-method' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestPaymentMethodManagementV1SetPut.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'PUT', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(quoteGuestPaymentMethodManagementV1SetPutBody, "QuoteGuestPaymentMethodManagementV1SetPutBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: number; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "number"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestShipmentEstimationV1ApiApiKeys { +} + +export class QuoteGuestShipmentEstimationV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestShipmentEstimationV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestShipmentEstimationV1ApiApiKeys[key]].apiKey = value; + } + /** + * Estimate shipping by address and return list of available shipping methods + * @param cartId + * @param quoteGuestShipmentEstimationV1EstimateByExtendedAddressPostBody + * @param {*} [options] Override http request options. + */ + public quoteGuestShipmentEstimationV1EstimateByExtendedAddressPost (cartId: string, quoteGuestShipmentEstimationV1EstimateByExtendedAddressPostBody?: QuoteGuestShipmentEstimationV1EstimateByExtendedAddressPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/estimate-shipping-methods' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestShipmentEstimationV1EstimateByExtendedAddressPost.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(quoteGuestShipmentEstimationV1EstimateByExtendedAddressPostBody, "QuoteGuestShipmentEstimationV1EstimateByExtendedAddressPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum QuoteGuestShippingMethodManagementV1ApiApiKeys { +} + +export class QuoteGuestShippingMethodManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: QuoteGuestShippingMethodManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[QuoteGuestShippingMethodManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * List applicable shipping methods for a specified quote. + * @param cartId The shopping cart ID. + * @param {*} [options] Override http request options. + */ + public quoteGuestShippingMethodManagementV1GetListGet (cartId: string, options: any = {}) : Promise<{ response: http.ClientResponse; body: Array; }> { + const localVarPath = this.basePath + '/V1/guest-carts/{cartId}/shipping-methods' + .replace('{' + 'cartId' + '}', encodeURIComponent(String(cartId))); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + // verify required parameter 'cartId' is not null or undefined + if (cartId === null || cartId === undefined) { + throw new Error('Required parameter cartId was null or undefined when calling quoteGuestShippingMethodManagementV1GetListGet.'); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "Array"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum SearchV1ApiApiKeys { +} + +export class SearchV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: SearchV1ApiApiKeys, value: string) { + (this.authentications as any)[SearchV1ApiApiKeys[key]].apiKey = value; + } + /** + * Make Full Text Search and return found Documents + * @param searchCriteriaRequestName + * @param searchCriteriaFilterGroups0Filters0Field Field + * @param searchCriteriaFilterGroups0Filters0Value Value + * @param searchCriteriaFilterGroups0Filters0ConditionType Condition type + * @param searchCriteriaSortOrders0Field Sorting field. + * @param searchCriteriaSortOrders0Direction Sorting direction. + * @param searchCriteriaPageSize Page size. + * @param searchCriteriaCurrentPage Current page. + * @param {*} [options] Override http request options. + */ + public searchV1SearchGet (searchCriteriaRequestName?: string, searchCriteriaFilterGroups0Filters0Field?: string, searchCriteriaFilterGroups0Filters0Value?: string, searchCriteriaFilterGroups0Filters0ConditionType?: string, searchCriteriaSortOrders0Field?: string, searchCriteriaSortOrders0Direction?: string, searchCriteriaPageSize?: number, searchCriteriaCurrentPage?: number, options: any = {}) : Promise<{ response: http.ClientResponse; body: FrameworkSearchSearchResultInterface; }> { + const localVarPath = this.basePath + '/V1/search'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + if (searchCriteriaRequestName !== undefined) { + localVarQueryParameters['searchCriteria[requestName]'] = ObjectSerializer.serialize(searchCriteriaRequestName, "string"); + } + + if (searchCriteriaFilterGroups0Filters0Field !== undefined) { + localVarQueryParameters['searchCriteria[filterGroups][0][filters][0][field]'] = ObjectSerializer.serialize(searchCriteriaFilterGroups0Filters0Field, "string"); + } + + if (searchCriteriaFilterGroups0Filters0Value !== undefined) { + localVarQueryParameters['searchCriteria[filterGroups][0][filters][0][value]'] = ObjectSerializer.serialize(searchCriteriaFilterGroups0Filters0Value, "string"); + } + + if (searchCriteriaFilterGroups0Filters0ConditionType !== undefined) { + localVarQueryParameters['searchCriteria[filterGroups][0][filters][0][conditionType]'] = ObjectSerializer.serialize(searchCriteriaFilterGroups0Filters0ConditionType, "string"); + } + + if (searchCriteriaSortOrders0Field !== undefined) { + localVarQueryParameters['searchCriteria[sortOrders][0][field]'] = ObjectSerializer.serialize(searchCriteriaSortOrders0Field, "string"); + } + + if (searchCriteriaSortOrders0Direction !== undefined) { + localVarQueryParameters['searchCriteria[sortOrders][0][direction]'] = ObjectSerializer.serialize(searchCriteriaSortOrders0Direction, "string"); + } + + if (searchCriteriaPageSize !== undefined) { + localVarQueryParameters['searchCriteria[pageSize]'] = ObjectSerializer.serialize(searchCriteriaPageSize, "number"); + } + + if (searchCriteriaCurrentPage !== undefined) { + localVarQueryParameters['searchCriteria[currentPage]'] = ObjectSerializer.serialize(searchCriteriaCurrentPage, "number"); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: FrameworkSearchSearchResultInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "FrameworkSearchSearchResultInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum VertexAddressValidationAddressManagementV1ApiApiKeys { +} + +export class VertexAddressValidationAddressManagementV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: VertexAddressValidationAddressManagementV1ApiApiKeys, value: string) { + (this.authentications as any)[VertexAddressValidationAddressManagementV1ApiApiKeys[key]].apiKey = value; + } + /** + * + * @param vertexAddressValidationAddressManagementV1GetValidAddressPostBody + * @param {*} [options] Override http request options. + */ + public vertexAddressValidationAddressManagementV1GetValidAddressPost (vertexAddressValidationAddressManagementV1GetValidAddressPostBody?: VertexAddressValidationAddressManagementV1GetValidAddressPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: QuoteDataAddressInterface; }> { + const localVarPath = this.basePath + '/V1/vertex-address-validation/vertex-address'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(vertexAddressValidationAddressManagementV1GetValidAddressPostBody, "VertexAddressValidationAddressManagementV1GetValidAddressPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: QuoteDataAddressInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "QuoteDataAddressInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} +export enum VertexAddressValidationApiGuestCleanseAddressV1ApiApiKeys { +} + +export class VertexAddressValidationApiGuestCleanseAddressV1Api { + protected _basePath = defaultBasePath; + protected defaultHeaders : any = {}; + protected _useQuerystring : boolean = false; + + protected authentications = { + 'default': new VoidAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set useQuerystring(value: boolean) { + this._useQuerystring = value; + } + + set basePath(basePath: string) { + this._basePath = basePath; + } + + get basePath() { + return this._basePath; + } + + public setDefaultAuthentication(auth: Authentication) { + this.authentications.default = auth; + } + + public setApiKey(key: VertexAddressValidationApiGuestCleanseAddressV1ApiApiKeys, value: string) { + (this.authentications as any)[VertexAddressValidationApiGuestCleanseAddressV1ApiApiKeys[key]].apiKey = value; + } + /** + * Query Vertex to cleanse an address + * @param vertexAddressValidationApiGuestCleanseAddressV1CleanseAddressPostBody + * @param {*} [options] Override http request options. + */ + public vertexAddressValidationApiGuestCleanseAddressV1CleanseAddressPost (vertexAddressValidationApiGuestCleanseAddressV1CleanseAddressPostBody?: VertexAddressValidationApiGuestCleanseAddressV1CleanseAddressPostBody, options: any = {}) : Promise<{ response: http.ClientResponse; body: VertexAddressValidationApiDataCleansedAddressInterface; }> { + const localVarPath = this.basePath + '/V1/guest-address/cleanse'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); + let localVarFormParams: any = {}; + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize(vertexAddressValidationApiGuestCleanseAddressV1CleanseAddressPostBody, "VertexAddressValidationApiGuestCleanseAddressV1CleanseAddressPostBody") + }; + + this.authentications.default.applyToRequest(localVarRequestOptions); + + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ response: http.ClientResponse; body: VertexAddressValidationApiDataCleansedAddressInterface; }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + body = ObjectSerializer.deserialize(body, "VertexAddressValidationApiDataCleansedAddressInterface"); + if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { + resolve({ response: response, body: body }); + } else { + reject({ response: response, body: body }); + } + } + }); + }); + } +} diff --git a/src/argv.ts b/src/argv.ts new file mode 100644 index 0000000..8ce395e --- /dev/null +++ b/src/argv.ts @@ -0,0 +1,55 @@ +import * as CLI from 'yargs'; +import { + warn, error, + default_path, + Options, OutputFormat, OutputTarget, inspect +} from './'; + + +const LIGHT = 'http://google.co.uk'; +const HEAVY = 'http://0.0.0.0:5555/app/xcf?debug=true&xblox=debug&xgrid=debug&davinci=debug&userDirectory=/PMaster/x4mm/user;' + +// default options for all commands +export const defaultOptions = (yargs: CLI.Argv) => { + return yargs.option('url', { + default: LIGHT, + describe: 'The URL to analyze' + }).option('format', { + default: 'text', + describe: 'Normal human readable text or JSON [text|json]' + }).option('target', { + default: 'console', + describe: 'Output target [console|file]' + }).option('path', { + default: '', + describe: 'The target location on the local filesystem for --target=file' + }).option('debug', { + default: 'false', + describe: 'Enable internal debug message' + }) +}; + +// Sanitizes faulty user argv options for all commands. +export const sanitize = (argv: CLI.Arguments): Options => { + const args = argv as Options; + args.cwd = args.cwd || process.cwd(); + if (!args.url) { + // internal user error, should never happen! + error('Invalid url, abort'); + return process.exit(); + } + // path given but target is not file, correct to file + if (args.path && args.target !== OutputTarget.FILE) { + args.target = OutputTarget.FILE; + } + // target is file but no path given, correct to default file + if (args.target === OutputTarget.FILE && !args.path) { + args.path = default_path(args.cwd, args.url); + } + // format string not valid + if (!(argv.format as string in OutputFormat)) { + warn(`Unknown output format ${argv.format}! Default to ${OutputFormat.text}`); + args.format = OutputFormat.text; + } + return args; +}; diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..97e6bb7 --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,2 @@ +export const GIT_CHANGELOG_MESSAGE_PREFIX = 'ChangeLog:'; +export const GIT_REPO = 'https://github.com/plastic-hub/products' \ No newline at end of file diff --git a/src/format.ts b/src/format.ts new file mode 100644 index 0000000..a721fb1 --- /dev/null +++ b/src/format.ts @@ -0,0 +1,19 @@ +import { Options, OutputFormat } from "./types"; +import { error } from "./log"; + +export const render = (result: any, options: Options) => { + switch (options.format) { + case OutputFormat.text: { + //@TODO: human readable format + return JSON.stringify(result, null, 2); + } + case OutputFormat.json: { + return JSON.stringify(result, null, 2); + } + default: { + //private, should never happen since options had to be sanitized + error('format::render Invalid value in options.format'); + return ''; + } + } +} \ No newline at end of file diff --git a/src/formatter.ts b/src/formatter.ts new file mode 100644 index 0000000..dd96231 --- /dev/null +++ b/src/formatter.ts @@ -0,0 +1,18 @@ +export const sizeToString = (bytes: number, si: boolean = true) => { + var units; + var u; + var b = bytes; + var thresh = si ? 1000 : 1024; + if (Math.abs(b) < thresh) { + return b + ' B'; + } + units = si + ? ['kB', 'MB', 'GB', 'TB'] + : ['KiB', 'MiB', 'GiB', 'TiB']; + u = -1; + do { + b /= thresh; + ++u; + } while (Math.abs(b) >= thresh && u < units.length - 1); + return b.toFixed(1) + ' ' + units[u]; +}; \ No newline at end of file diff --git a/src/git_push.sh b/src/git_push.sh new file mode 100644 index 0000000..da84dcd --- /dev/null +++ b/src/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..8c2ccaf --- /dev/null +++ b/src/index.ts @@ -0,0 +1,6 @@ +export * from './paths'; +export * from './format'; +export * from './log'; +export * from './types'; +export * from './formatter'; +export * from './main'; diff --git a/src/lib/common/array.ts b/src/lib/common/array.ts new file mode 100644 index 0000000..8924fc7 --- /dev/null +++ b/src/lib/common/array.ts @@ -0,0 +1,15 @@ +/** + * Return last element + * @private + * @param {(Array)} array + * @returns object | undefined + */ +export const lastOf = (array: Array) => array[array.length - 1]; + +/** + * Return first element + * @private + * @param {(Array)} array + * @returns object | undefined + */ +export const firstOf = (array: Array) => array[0]; diff --git a/src/lib/common/enums.ts b/src/lib/common/enums.ts new file mode 100644 index 0000000..b81ca58 --- /dev/null +++ b/src/lib/common/enums.ts @@ -0,0 +1,55 @@ +export const EVENTS = { + +}; + +export enum COMMANDS { + RUN_FILE = 'Run_File', + RUN_CLASS = 'Run_Class', + RUN_APP_SERVER_CLASS = 'Run_App_Server_Class', + RUN_APP_SERVER_CLASS_METHOD = 'Run_App_Server_Class_Method', + RUN_APP_SERVER_COMPONENT_METHOD = 'Run_App_Server_Component_Method', + CANCEL_APP_SERVER_COMPONENT_METHOD = 'Cancel_App_Server_Component_Method', + ANSWER_APP_SERVER_COMPONENT_METHOD_INTERRUPT = 'Answer_App_Server_Component_Method_Interrupt' +} + +export enum LOGGING_SIGNAL { +}; + +export enum LOGGING_FLAGS { + /** + * No logging + * @constant + * @type int + */ + NONE = 0x00000000, + /** + * Log in the IDE's global console + * @constant + * @type int + */ + GLOBAL_CONSOLE = 0x00000001, + /** + * Log in the IDE's status bar + * @constant + * @type int + */ + STATUS_BAR = 0x00000002, + /** + * Create notification popup in the IDE + * @constant + * @type int + */ + POPUP = 0x00000004, + /** + * Log to file + * @constant + * @type int + */ + FILE = 0x00000008, + /** + * Log into the IDE's dev tool's console + * @constant + * @type int + */ + DEV_CONSOLE = 0x00000010 +}; diff --git a/src/lib/common/platform.ts b/src/lib/common/platform.ts new file mode 100644 index 0000000..a07fe43 --- /dev/null +++ b/src/lib/common/platform.ts @@ -0,0 +1,12 @@ +import { platform, arch } from 'os'; + +export const os = () => { + if (platform() === 'win32') { + return 'windows'; + } else if (platform() === 'darwin') { + return 'osx'; + } else if (arch() === 'arm') { + return 'arm'; + } + return 'linux'; +} \ No newline at end of file diff --git a/src/lib/common/primitives.ts b/src/lib/common/primitives.ts new file mode 100644 index 0000000..8f92969 --- /dev/null +++ b/src/lib/common/primitives.ts @@ -0,0 +1,247 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +const _typeof = { + number: 'number', + string: 'string', + undefined: 'undefined', + object: 'object', + function: 'function' +}; + +/** + * @returns whether the provided parameter is a JavaScript Array or not. + */ +export function isArray(array: any): array is any[] { + if (Array.isArray) { + return Array.isArray(array); + } + + if (array && typeof (array.length) === _typeof.number && array.constructor === Array) { + return true; + } + + return false; +} + +/** + * @returns whether the provided parameter is a JavaScript String or not. + */ +export function isString(str: any): str is string { + if (typeof (str) === _typeof.string || str instanceof String) { + return true; + } + + return false; +} + +/** + * @returns whether the provided parameter is a JavaScript Array and each element in the array is a string. + */ +export function isStringArray(value: any): value is string[] { + return isArray(value) && (value).every(elem => isString(elem)); +} + +/** + * + * @returns whether the provided parameter is of type `object` but **not** + * `null`, an `array`, a `regexp`, nor a `date`. + */ +export function isObject(obj: any): boolean { + // The method can't do a type cast since there are type (like strings) which + // are subclasses of any put not positvely matched by the function. Hence type + // narrowing results in wrong results. + return typeof obj === _typeof.object + && obj !== null + && !Array.isArray(obj) + && !(obj instanceof RegExp) + && !(obj instanceof Date); +} + +/** + * In **contrast** to just checking `typeof` this will return `false` for `NaN`. + * @returns whether the provided parameter is a JavaScript Number or not. + */ +export function isNumber(obj: any): obj is number { + if ((typeof (obj) === _typeof.number || obj instanceof Number) && !isNaN(obj)) { + return true; + } + + return false; +} + +/** + * @returns whether the provided parameter is a JavaScript Boolean or not. + */ +export function isBoolean(obj: any): obj is boolean { + return obj === true || obj === false; +} + +/** + * @returns whether the provided parameter is undefined. + */ +export function isUndefined(obj: any): boolean { + return typeof (obj) === _typeof.undefined; +} + +/** + * @returns whether the provided parameter is undefined or null. + */ +export function isUndefinedOrNull(obj: any): boolean { + return isUndefined(obj) || obj === null; +} + + +const hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * @returns whether the provided parameter is an empty JavaScript Object or not. + */ +export function isEmptyObject(obj: any): obj is any { + if (!isObject(obj)) { + return false; + } + + for (let key in obj) { + if (hasOwnProperty.call(obj, key)) { + return false; + } + } + + return true; +} + +/** + * @returns whether the provided parameter is a JavaScript Function or not. + */ +export function isFunction(obj: any): obj is Function { + return typeof obj === _typeof.function; +} + +/** + * @returns whether the provided parameters is are JavaScript Function or not. + */ +export function areFunctions(...objects: any[]): boolean { + return objects && objects.length > 0 && objects.every(isFunction); +} + +export type TypeConstraint = string | Function; + +export function validateConstraints(args: any[], constraints: TypeConstraint[]): void { + const len = Math.min(args.length, constraints.length); + for (let i = 0; i < len; i++) { + validateConstraint(args[i], constraints[i]); + } +} + +export function validateConstraint(arg: any, constraint: TypeConstraint): void { + + if (isString(constraint)) { + if (typeof arg !== constraint) { + throw new Error(`argument does not match constraint: typeof ${constraint}`); + } + } else if (isFunction(constraint)) { + if (arg instanceof constraint) { + return; + } + if (arg && arg.constructor === constraint) { + return; + } + if (constraint.length === 1 && constraint.call(undefined, arg) === true) { + return; + } + throw new Error(`argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true`); + } +} + +/** + * Creates a new object of the provided class and will call the constructor with + * any additional argument supplied. + */ +export function create(ctor: Function, ...args: any[]): any { + let obj = Object.create(ctor.prototype); + ctor.apply(obj, args); + + return obj; +} + +export interface IFunction0 { + (): T; +} +export interface IFunction1 { + (a1: A1): T; +} +export interface IFunction2 { + (a1: A1, a2: A2): T; +} +export interface IFunction3 { + (a1: A1, a2: A2, a3: A3): T; +} +export interface IFunction4 { + (a1: A1, a2: A2, a3: A3, a4: A4): T; +} +export interface IFunction5 { + (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): T; +} +export interface IFunction6 { + (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): T; +} +export interface IFunction7 { + (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): T; +} +export interface IFunction8 { + (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): T; +} + +export interface IAction0 extends IFunction0 { } +export interface IAction1 extends IFunction1 { } +export interface IAction2 extends IFunction2 { } +export interface IAction3 extends IFunction3 { } +export interface IAction4 extends IFunction4 { } +export interface IAction5 extends IFunction5 { } +export interface IAction6 extends IFunction6 { } +export interface IAction7 extends IFunction7 { } +export interface IAction8 extends IFunction8 { } + +export type NumberCallback = (index: number) => void; + +export function count(to: number, callback: NumberCallback): void; +export function count(from: number, to: number, callback: NumberCallback): void; +export function count(fromOrTo: number, toOrCallback?: NumberCallback | number, callback?: NumberCallback): any { + var from: number, to: number; + + if (isNumber(toOrCallback)) { + from = fromOrTo; + to = toOrCallback; + } else { + from = 0; + to = fromOrTo; + callback = toOrCallback; + } + + var op = from <= to ? (i: number) => i + 1 : (i: number) => i - 1; + var cmp = from <= to ? (a: number, b: number) => a < b : (a: number, b: number) => a > b; + + for (var i = from; cmp(i, to); i = op(i)) { + callback(i); + } +} + +export function countToArray(to: number): number[]; +export function countToArray(from: number, to: number): number[]; +export function countToArray(fromOrTo: number, to?: number): number[] { + var result: number[] = []; + var fn = (i: number) => result.push(i); + + if (isUndefined(to)) { + count(fromOrTo, fn); + } else { + count(fromOrTo, to, fn); + } + + return result; +} + diff --git a/src/lib/common/strings.ts b/src/lib/common/strings.ts new file mode 100644 index 0000000..f9299f3 --- /dev/null +++ b/src/lib/common/strings.ts @@ -0,0 +1,487 @@ +import { isArray, isObject, } from './primitives'; +import { Hash } from './types'; +import { isString } from 'lodash'; + +const escapeRegExpPattern = /[[\]{}()|\/\\^$.*+?]/g; +const escapeXmlPattern = /[&<]/g; +const escapeXmlForPattern = /[&<>'"]/g; +const escapeXmlMap: Hash = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''' +}; +export const DefaultDelimiter = { + begin: '<%', + end: '%>' +}; +export const hasFlag = (field, enumValue) => { + //noinspection JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage + // tslint:disable-next-line:no-bitwise + return ((1 << enumValue) & field) ? true : false; +}; +export const hasFlagHex = (field, enumValue) => { + //noinspection JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage,JSBitwiseOperatorUsage + // tslint:disable-next-line:no-bitwise + return enumValue & field ? true : false; +}; +export const disableFlag = (enumValue, field) => { + enumValue &= ~(1 << field); + return enumValue; +}; +/** + * The minimum location of high surrogates + */ +export const HIGH_SURROGATE_MIN = 0xD800; +/** + * The maximum location of high surrogates + */ +export const HIGH_SURROGATE_MAX = 0xDBFF; +/** + * The minimum location of low surrogates + */ +export const LOW_SURROGATE_MIN = 0xDC00; +/** + * The maximum location of low surrogates + */ +export const LOW_SURROGATE_MAX = 0xDFFF; + +const BASE64_KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + +export const capitalize = (word) => { + return word.substring(0, 1).toUpperCase() + word.substring(1); +}; + +export const getJson = (inData, validOnly, ommit) => { + try { + return isString(inData) ? JSON.parse(inData) : validOnly === true ? null : inData; + } catch (e) { + ommit !== false && console.error('error parsing json data ' + inData + ' error = ' + e); + } + return null; +}; + +/** + * Escapes a string so that it can safely be passed to the RegExp constructor. + * @param text The string to be escaped + * @return The escaped string + */ +export function escapeRegExpEx(text: string): string { + return !text ? text : text.replace(escapeRegExpPattern, '\\$&'); +} + +/** + * Sanitizes a string to protect against tag injection. + * @param xml The string to be escaped + * @param forAttribute Whether to also escape ', ", and > in addition to < and & + * @return The escaped string + */ +export function escapeXml(xml: string, forAttribute: boolean = true): string { + if (!xml) { + return xml; + } + + const pattern = forAttribute ? escapeXmlForPattern : escapeXmlPattern; + + return xml.replace(pattern, function (character: string): string { + return escapeXmlMap[character]; + }); +} + +export function createUUID(): string { + const S4 = function () { + return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); + }; + return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4()); +} + +export function escapeRegExp(str: string): string { + const special = ['[', ']', '(', ')', '{', '}', '*', '+', '.', '|', '||']; + for (let n = 0; n < special.length; n++) { + str = str.replace(special[n], '\\' + special[n]); + } + return str; +}; + +export function findOcurrences(expression: string, delimiters: IDelimiter): Array { + // tslint:disable-next-line:no-object-literal-type-assertion + const d = { + begin: escapeRegExp(delimiters.begin), + end: escapeRegExp(delimiters.end) + } as IDelimiter; + return expression.match(new RegExp(d.begin + '([^' + d.end + ']*)' + d.end, 'g')); +}; + +export function multipleReplace(str: string, hash: any): string { + // to array + const a = []; + // tslint:disable-next-line:forin + for (let key in hash) { + a[a.length] = key; + } + return str.replace(new RegExp(a.join('\\b|\\b'), 'g'), function (m) { + return hash[m] || hash['\\' + m]; + }); +}; + +export function replaceAll(find: string, replace: string, str: string): string { + return str ? str.split(find).join(replace) : ''; +}; + +export interface IDelimiter { + begin: string; + end: string; +} + +export function replace(str: string, needle: any | null, what: string | any, delimiters: IDelimiter): string { + if (!str) { + return ''; + } + if (what && isObject(what) || isArray(what)) { + what = what as any; + if (!delimiters) { + // fast case + return multipleReplace(str, what); + } + const occurrence = findOcurrences(str, delimiters); + if (!occurrence) { + return str; + } else { + for (let i = 0, j = occurrence.length; i < j; i++) { + const el = occurrence[i]; + // strip off delimiters + let _variableName = replaceAll(delimiters.begin, '', el); + _variableName = replaceAll(delimiters.end, '', _variableName); + str = replaceAll(el, (what[_variableName]), str); + } + } + return str; + } + // fast case + return replaceAll(needle, what as string, str); +}; + +export const substitute = (template, map ) => { + const transform = (k) => k || ''; + return template.replace(/\$\{([^\s\:\}]+)(?:\:([^\s\:\}]+))?\}/g, + (match, key, format) => transform(map[key]).toString()); +}; + +function decodeUtf8EncodedCodePoint(codePoint: number, validationRange: number[] = [0, Infinity], checkSurrogate?: boolean): string { + if (codePoint < validationRange[0] || codePoint > validationRange[1]) { + throw Error('Invalid continuation byte'); + } + + if (checkSurrogate && codePoint >= HIGH_SURROGATE_MIN && codePoint <= LOW_SURROGATE_MAX) { + throw Error('Surrogate is not a scalar value'); + } + + let encoded = ''; + + if (codePoint > 0xFFFF) { + codePoint -= 0x010000; + encoded += String.fromCharCode(codePoint >>> 0x10 & 0x03FF | HIGH_SURROGATE_MIN); + codePoint = LOW_SURROGATE_MIN | codePoint & 0x03FF; + } + + encoded += String.fromCharCode(codePoint); + + return encoded; +} + +function validateUtf8EncodedCodePoint(codePoint: number): void { + if ((codePoint & 0xC0) !== 0x80) { + throw Error('Invalid continuation byte'); + } +} + +export type ByteBuffer = Uint16Array | Uint8Array | Buffer | number[]; + +export interface Codec { + encode(data: string): number[]; + decode(data: ByteBuffer): string; +} + +/** + * Provides facilities for encoding a string into an ASCII-encoded byte buffer and + * decoding an ASCII-encoded byte buffer into a string. + */ +export const ascii: Codec = { + /** + * Encodes a string into an ASCII-encoded byte buffer. + * + * @param data The text string to encode + */ + encode(data: string): number[] { + if (data == null) { + return []; + } + + const buffer: number[] = []; + + for (let i = 0, length = data.length; i < length; i++) { + buffer[i] = data.charCodeAt(i); + } + + return buffer; + }, + /** + * Decodes an ASCII-encoded byte buffer into a string. + * + * @param data The byte buffer to decode + */ + decode(data: ByteBuffer): string { + if (data == null) { + return ''; + } + + let decoded = ''; + + for (let i = 0, length = data.length; i < length; i++) { + decoded += String.fromCharCode(data[i]); + } + + return decoded; + } +}; + +/** + * Provides facilities for encoding a string into a Base64-encoded byte buffer and + * decoding a Base64-encoded byte buffer into a string. + */ +export const base64: Codec = { + /** + * Encodes a Base64-encoded string into a Base64 byte buffer. + * + * @param data The Base64-encoded string to encode + */ + encode(data: string): number[] { + if (data == null) { + return []; + } + + const buffer: number[] = []; + + let i = 0; + let length = data.length; + + while (data[--length] === '=') { } + while (i < length) { + let encoded = BASE64_KEYSTR.indexOf(data[i++]) << 18; + if (i <= length) { + encoded |= BASE64_KEYSTR.indexOf(data[i++]) << 12; + } + if (i <= length) { + encoded |= BASE64_KEYSTR.indexOf(data[i++]) << 6; + } + if (i <= length) { + encoded |= BASE64_KEYSTR.indexOf(data[i++]); + } + + buffer.push((encoded >>> 16) & 0xff); + buffer.push((encoded >>> 8) & 0xff); + buffer.push(encoded & 0xff); + } + + while (buffer[buffer.length - 1] === 0) { + buffer.pop(); + } + + return buffer; + }, + /** + * Decodes a Base64-encoded byte buffer into a Base64-encoded string. + * + * @param data The byte buffer to decode + */ + decode(data: ByteBuffer): string { + if (data == null) { + return ''; + } + + let decoded = ''; + let i = 0; + + for (let length = data.length - (data.length % 3); i < length;) { + let encoded = data[i++] << 16 | data[i++] << 8 | data[i++]; + + decoded += BASE64_KEYSTR.charAt((encoded >>> 18) & 0x3F); + decoded += BASE64_KEYSTR.charAt((encoded >>> 12) & 0x3F); + decoded += BASE64_KEYSTR.charAt((encoded >>> 6) & 0x3F); + decoded += BASE64_KEYSTR.charAt(encoded & 0x3F); + } + + if (data.length % 3 === 1) { + let encoded = data[i++] << 16; + decoded += BASE64_KEYSTR.charAt((encoded >>> 18) & 0x3f); + decoded += BASE64_KEYSTR.charAt((encoded >>> 12) & 0x3f); + decoded += '=='; + } else if (data.length % 3 === 2) { + let encoded = data[i++] << 16 | data[i++] << 8; + decoded += BASE64_KEYSTR.charAt((encoded >>> 18) & 0x3f); + decoded += BASE64_KEYSTR.charAt((encoded >>> 12) & 0x3f); + decoded += BASE64_KEYSTR.charAt((encoded >>> 6) & 0x3f); + decoded += '='; + } + + return decoded; + } +}; + +/** + * Provides facilities for encoding a string into a hex-encoded byte buffer and + * decoding a hex-encoded byte buffer into a string. + */ +export const hex: Codec = { + /** + * Encodes a string into a hex-encoded byte buffer. + * + * @param data The hex-encoded string to encode + */ + encode(data: string): number[] { + if (data == null) { + return []; + } + + const buffer: number[] = []; + + for (let i = 0, length = data.length; i < length; i += 2) { + let encodedChar = parseInt(data.substr(i, 2), 16); + + buffer.push(encodedChar); + } + + return buffer; + }, + /** + * Decodes a hex-encoded byte buffer into a hex-encoded string. + * + * @param data The byte buffer to decode + */ + decode(data: ByteBuffer): string { + if (data == null) { + return ''; + } + + let decoded = ''; + + for (let i = 0, length = data.length; i < length; i++) { + decoded += data[i].toString(16).toUpperCase(); + } + + return decoded; + } +}; + +/** + * Provides facilities for encoding a string into a UTF-8-encoded byte buffer and + * decoding a UTF-8-encoded byte buffer into a string. + * Inspired by the work of: https://github.com/mathiasbynens/utf8.js + */ +export const utf8: Codec = { + /** + * Encodes a string into a UTF-8-encoded byte buffer. + * + * @param data The text string to encode + */ + encode(data: string): number[] { + if (data == null) { + return []; + } + + const buffer: number[] = []; + + for (let i = 0, length = data.length; i < length; i++) { + let encodedChar = data.charCodeAt(i); + /** + * Surrogates + * http://en.wikipedia.org/wiki/Universal_Character_Set_characters + */ + if (encodedChar >= HIGH_SURROGATE_MIN && encodedChar <= HIGH_SURROGATE_MAX) { + let lowSurrogate = data.charCodeAt(i + 1); + if (lowSurrogate >= LOW_SURROGATE_MIN && lowSurrogate <= LOW_SURROGATE_MAX) { + encodedChar = 0x010000 + (encodedChar - HIGH_SURROGATE_MIN) * 0x0400 + (lowSurrogate - LOW_SURROGATE_MIN); + i++; + } + } + + if (encodedChar < 0x80) { + buffer.push(encodedChar); + } else { + if (encodedChar < 0x800) { + buffer.push(((encodedChar >> 0x06) & 0x1F) | 0xC0); + } else if (encodedChar < 0x010000) { + if (encodedChar >= HIGH_SURROGATE_MIN && encodedChar <= LOW_SURROGATE_MAX) { + throw Error('Surrogate is not a scalar value'); + } + + buffer.push(((encodedChar >> 0x0C) & 0x0F) | 0xE0); + buffer.push(((encodedChar >> 0x06) & 0x3F) | 0x80); + } else if (encodedChar < 0x200000) { + buffer.push(((encodedChar >> 0x12) & 0x07) | 0xF0); + buffer.push(((encodedChar >> 0x0C) & 0x3F) | 0x80); + buffer.push(((encodedChar >> 0x06) & 0x3F) | 0x80); + } + buffer.push((encodedChar & 0x3F) | 0x80); + } + } + + return buffer; + }, + /** + * Decodes a UTF-8-encoded byte buffer into a string. + * + * @param data The byte buffer to decode + */ + decode(data: ByteBuffer): string { + if (data == null) { + return ''; + } + + let decoded = ''; + + for (let i = 0, length = data.length; i < length; i++) { + let byte1 = data[i] & 0xFF; + + if ((byte1 & 0x80) === 0) { + decoded += decodeUtf8EncodedCodePoint(byte1); + } else if ((byte1 & 0xE0) === 0xC0) { + let byte2 = data[++i] & 0xFF; + validateUtf8EncodedCodePoint(byte2); + byte2 = byte2 & 0x3F; + let encodedByte = ((byte1 & 0x1F) << 0x06) | byte2; + decoded += decodeUtf8EncodedCodePoint(encodedByte, [0x80, Infinity]); + } else if ((byte1 & 0xF0) === 0xE0) { + let byte2 = data[++i] & 0xFF; + validateUtf8EncodedCodePoint(byte2); + byte2 = byte2 & 0x3F; + + let byte3 = data[++i] & 0xFF; + validateUtf8EncodedCodePoint(byte3); + byte3 = byte3 & 0x3F; + + let encodedByte = ((byte1 & 0x1F) << 0x0C) | (byte2 << 0x06) | byte3; + decoded += decodeUtf8EncodedCodePoint(encodedByte, [0x0800, Infinity], true); + } else if ((byte1 & 0xF8) === 0xF0) { + let byte2 = data[++i] & 0xFF; + validateUtf8EncodedCodePoint(byte2); + byte2 = byte2 & 0x3F; + + let byte3 = data[++i] & 0xFF; + validateUtf8EncodedCodePoint(byte3); + byte3 = byte3 & 0x3F; + + let byte4 = data[++i] & 0xFF; + validateUtf8EncodedCodePoint(byte4); + byte4 = byte4 & 0x3F; + + let encodedByte = ((byte1 & 0x1F) << 0x0C) | (byte2 << 0x0C) | (byte3 << 0x06) | byte4; + decoded += decodeUtf8EncodedCodePoint(encodedByte, [0x010000, 0x10FFFF]); + } else { + validateUtf8EncodedCodePoint(byte1); + } + } + return decoded; + } +}; diff --git a/src/lib/common/types.ts b/src/lib/common/types.ts new file mode 100644 index 0000000..2d5e65e --- /dev/null +++ b/src/lib/common/types.ts @@ -0,0 +1,35 @@ +export * from './enums'; + +// tslint:disable-next-line:interface-name +export interface Hash { + [id: string]: T; +} +// tslint:disable-next-line:interface-name +export interface List { + [index: number]: T; + length: number; +} +/** + * Interface of the simple literal object with any string keys. + */ +export interface IObjectLiteral { + [key: string]: any; +} +/** + * Represents some Type of the Object. + */ +// tslint:disable-next-line:ban-types +export type ObjectType = { new(): T } | (Function); +/** + * Same as Partial but goes deeper and makes Partial all its properties and sub-properties. + */ +export type DeepPartial = { + [P in keyof T]?: DeepPartial; +}; + +export interface IDelimitter { + begin: string; + end: string; +} + +export type JSONPathExpression = string; diff --git a/src/lib/content/front.ts b/src/lib/content/front.ts new file mode 100644 index 0000000..fcf1979 --- /dev/null +++ b/src/lib/content/front.ts @@ -0,0 +1,67 @@ +import { capitalize } from "../common/strings"; + +export const howto_header = (title, category, image, description: string = "", tagline: string = "", config: string = "") => { + return `--- +image: ${image} +category: "${category}" +title: "${title}" +tagline: ${tagline || '""' } +description: ${description || `"Precious Plastic - Howto : ${category} :: ${title} "` } +${config} +---\n`; +} + +export const gallery_image = (path, title= "", alt ="") =>{ + return ` + - url: "${path}" + image_path: "${path}" + alt: "${alt}" + title: "${title}"`; +} + +export const drawing_image = (path, pdf, title= "", alt ="") =>{ + return ` + - url: "${pdf}" + image_path: "${path}" + alt: "${alt}" + title: "${title}"`; +} + + +export const machine_header = (title, category, image, slug, rel, description: string = "", tagline: string = "", config: string = "") => { + return `--- +image: ${image} +category: "${category}" +title: "${title}" +product_rel: "/${rel}" +tagline: ${tagline || '""'} +description: ${description || `"Precious Plastic - Machine : ${capitalize(category)} :: ${title}"` } +${config} +---\n`; +} + +export const product_header = (title, category, image, slug, rel, description: string = "", tagline: string = "", config: string = "") => { + return `--- +image: ${image} +category: "${category}" +title: "${title}" +product_rel: "/${rel}" +tagline: ${tagline || '""'} +description: ${description || `"Precious Plastic - Machine : ${title} by PlasticHub"` } +${config} +---\n`; +} + +export const projects_header = (title, category, image, slug, rel, description: string = "", tagline: string = "", config: string = "") => { + return `--- +image: ${image} +category: "${category}" +title: "${title}" +product_rel: "/${rel}" +tagline: ${tagline || '""'} +description: ${description || `"Precious Plastic - ${capitalize(category)} :: ${title}"` } +${config} +sidebar: + nav: "projects" +---\n`; +} diff --git a/src/lib/content/html.ts b/src/lib/content/html.ts new file mode 100644 index 0000000..d398d82 --- /dev/null +++ b/src/lib/content/html.ts @@ -0,0 +1,26 @@ +import { GIT_REPO } from '../../constants'; +import { html_beautify } from 'js-beautify'; +export const img = (file, label, id = '') => { + return `
+ + + + ${label} +
`; +} + +export const changelog_entry = (e) => { + return `
+
${e.date} 
${e.msg} +
    + ${e.files.map((f) => { + return `
  • ${f.path}
  • ` + })} +
+
+ ` +} + +export const changelog = (log: any[]) => { + return html_beautify(log.map(changelog_entry).join('
')); +} \ No newline at end of file diff --git a/src/lib/content/md.ts b/src/lib/content/md.ts new file mode 100644 index 0000000..c229a2f --- /dev/null +++ b/src/lib/content/md.ts @@ -0,0 +1,77 @@ +import * as debug from '../..'; +import * as path from 'path'; +import { isArray, isString } from 'util'; + +import { files, read, csvToMarkdown, toHTML, md2html, exists } from '../../lib/'; +import { html_beautify } from 'js-beautify'; +import { sync as mkdir } from '@plastichub/fs/dir'; +import { substitute } from '../common/strings'; + +const md_tables = require('markdown-table'); + +export const parse_config = (config, root) => { + if (Object.keys(config)) { + for (const key in config) { + let val = config[key]; + if (isArray(val)) { + if (key !== 'authors') { + config[key] = md2html(md_tables(val)); + } + } else if (isString(val)) { + if (val.endsWith('.csv')) { + const parsed = path.parse(root); + let csv = path.resolve(`${parsed.dir}/${parsed.base}/${val}`) as any; + debug.info("Parsing CSV " + csv); + if (exists(csv)) { + csv = read(csv) || ""; + try { + csv = md2html(csvToMarkdown(csv)); + config[key] = csv; + } catch (e) { + debug.error(`Error converting csv to md ${val}`); + } + } else { + debug.error(`Can't find CSV file at ${csv}`, parsed); + } + } + } + } + } +} + +export const md_edit_wrap = (content, f, prefix = '', context = '') => { + return html_beautify(`
${content}
`); +} + +export const read_fragments = (src, config, prefix = '', context = '') => { + + if (!exists(src)) { + debug.warn(`Create template folder ${src}`); + mkdir(src); + } + let fragments = files(src, '*.html'); + fragments.map((f) => { + config[path.parse(f).name] = md_edit_wrap(toHTML(f, true), f, prefix, context); + }); + + fragments = files(src, '*.md'); + fragments.map((f) => { + config[path.parse(f).name] = md_edit_wrap(toHTML(f, false), f, prefix, context); + }); + return config; +} + +const _resolve = (config) => { + for (const key in config) { + if (config[key] && typeof config[key] == 'string') { + const resolved = substitute(config[key], config); + config[key] = resolved; + } + } + return config; +} +export const resolveConfig = (config) => { + config = _resolve(config); + config = _resolve(config); + return config; +} \ No newline at end of file diff --git a/src/lib/content/tables.ts b/src/lib/content/tables.ts new file mode 100644 index 0000000..8637f48 --- /dev/null +++ b/src/lib/content/tables.ts @@ -0,0 +1,76 @@ +/** + * Converts CSV to Markdown Table + * + * @param {string} csvContent - The string content of the CSV + * @param {string} delimiter - The character(s) to use as the CSV column delimiter + * @param {boolean} hasHeader - Whether to use the first row of Data as headers + * @returns {string} + */ +export function csvToMarkdown(csvContent: string, delimiter: string = ",", hasHeader: boolean = true): string { + if (delimiter != "\t") { + csvContent = csvContent.replace(/\t/g, " "); + } + + const columns = csvContent.split(/\r?\n/); + + const tabularData: string[][] = []; + const maxRowLen: number[] = []; + + columns.forEach((e, i) => { + if (typeof tabularData[i] == "undefined") { + tabularData[i] = []; + } + const regex = new RegExp(delimiter + '(?![^"]*"\\B)'); + const row = e.split(regex); + row.forEach((ee, ii) => { + if (typeof maxRowLen[ii] == "undefined") { + maxRowLen[ii] = 0; + } + + // escape pipes and backslashes + ee = ee.replace(/(\||\\)/g, "\\$1"); + + maxRowLen[ii] = Math.max(maxRowLen[ii], ee.length); + tabularData[i][ii] = ee; + }); + }); + + let headerOutput = ""; + let seperatorOutput = ""; + + maxRowLen.forEach((len) => { + const sizer = Array(len + 1 + 2); + + seperatorOutput += "|" + sizer.join("-"); + headerOutput += "|" + sizer.join(" "); + }); + + headerOutput += "| \n"; + seperatorOutput += "| \n"; + + if (hasHeader) { + headerOutput = ""; + } + + let rowOutput = ""; + tabularData.forEach((col, i) => { + maxRowLen.forEach((len, y) => { + const row = typeof col[y] == "undefined" ? "" : col[y]; + const spacing = Array((len - row.length) + 1).join(" "); + const out = `| ${row}${spacing} `; + if (hasHeader && i === 0) { + headerOutput += out; + } else { + rowOutput += out; + } + }); + + if (hasHeader && i === 0) { + headerOutput += "| \n"; + } else { + rowOutput += "| \n"; + } + }); + + return `\n\n ${headerOutput}${seperatorOutput}${rowOutput} \n\n`; +} diff --git a/src/lib/core/.editorconfig b/src/lib/core/.editorconfig new file mode 100644 index 0000000..0e43c5d --- /dev/null +++ b/src/lib/core/.editorconfig @@ -0,0 +1,16 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = tab +indent_size = 4 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/src/lib/core/.gitattributes b/src/lib/core/.gitattributes new file mode 100644 index 0000000..d3f42db --- /dev/null +++ b/src/lib/core/.gitattributes @@ -0,0 +1,21 @@ +# Set the default behavior, in case users don't have core.autocrlf set +* text=auto + +# Files that should always be normalized and converted to native line +# endings on checkout. +*.js text +*.json text +*.ts text +*.md text +*.yml text +LICENSE text + +# Files that are truly binary and should not be modified +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.jar binary +*.zip binary +*.psd binary +*.enc binary diff --git a/src/lib/core/.github/CONTRIBUTING.md b/src/lib/core/.github/CONTRIBUTING.md new file mode 100644 index 0000000..0767383 --- /dev/null +++ b/src/lib/core/.github/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# Thank You + +We very much welcome contributions to Dojo 2. + +Because we have so many repositories that are part of Dojo 2, we have located our [Contributing Guidelines](https://github.com/dojo/meta/blob/master/CONTRIBUTING.md) in our [Dojo 2 Meta Repository](https://github.com/dojo/meta#readme). + +Look forward to working with you on Dojo 2!!! diff --git a/src/lib/core/.github/ISSUE_TEMPLATE.md b/src/lib/core/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..5bf21b4 --- /dev/null +++ b/src/lib/core/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,28 @@ + + +**Bug / Enhancement** + + + +Package Version: + +**Code** + + + +**Expected behavior:** + + + +**Actual behavior:** + + diff --git a/src/lib/core/.github/PULL_REQUEST_TEMPLATE.md b/src/lib/core/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..0459c2e --- /dev/null +++ b/src/lib/core/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ +**Type:** bug / feature + +The following has been addressed in the PR: + +* [ ] There is a related issue +* [ ] All code has been formatted with [`prettier`](https://prettier.io/) as per the [readme code style guidelines](./../#code-style) +* [ ] Unit or Functional tests are included in the PR + + + +**Description:** + +Resolves #??? diff --git a/src/lib/core/.gitignore b/src/lib/core/.gitignore new file mode 100644 index 0000000..5324573 --- /dev/null +++ b/src/lib/core/.gitignore @@ -0,0 +1,18 @@ +.sublimets +.tscache +.tsconfig*.json +*.js +*.js.map +!/*.js +dist +deploy_key +node_modules +/typings/** +bower_components +tests/typings/dist/ +.baseDir.ts +html-report +coverage-final.lcov +coverage-unmapped.json +/_build +/_apidoc diff --git a/src/lib/core/.npmignore b/src/lib/core/.npmignore new file mode 100644 index 0000000..482a902 --- /dev/null +++ b/src/lib/core/.npmignore @@ -0,0 +1,17 @@ +/_build +/docs +/html-report +/resources +/support +/tests +/typings +.editorconfig +.gitattributes +.gitignore +.npmignore +.travis.yml +.tscache +.vscode +Gruntfile.js +tsconfig.json +tslint.json diff --git a/src/lib/core/.travis.yml b/src/lib/core/.travis.yml new file mode 100644 index 0000000..6945a95 --- /dev/null +++ b/src/lib/core/.travis.yml @@ -0,0 +1,32 @@ +sudo: false +language: node_js +node_js: +- '6' +env: + global: + # Please get your own free key if you want to test yourself + - SAUCE_USERNAME: dojo2-ts-ci + - SAUCE_ACCESS_KEY: e92610e3-834e-4bec-a3b5-6f7b9d874601 + - BROWSERSTACK_USERNAME: dylanschiemann2 + - BROWSERSTACK_ACCESS_KEY: 4Q2g8YAc9qeZzB2hECnS +addons: + apt: + packages: + - openssl +before_install: +- if [ ${TRAVIS_BRANCH-""} == "master" ] && [ -n ${encrypted_12c8071d2874_key-""} ]; then openssl aes-256-cbc -K + $encrypted_12c8071d2874_key -iv $encrypted_12c8071d2874_iv + -in deploy_key.enc -out deploy_key -d; fi +install: +- travis_retry npm install grunt-cli +- travis_retry npm install +script: +- grunt +- grunt intern:browserstack --test-reporter +- grunt uploadCoverage +- grunt dist +- if [ "$TRAVIS_BRANCH" = "master" ]; then grunt doc; fi +notifications: + slack: + secure: ZuM/LrujGyUs8r/KGYtxaqRHNVyAMhQi+nrbfhxxqrfXqfFoikMqwGSlY4728MvOEj3ptJhcqjxHTp+rnajXTHkEXJ6y7yfIGekd5523dGVooESIu6oFjmh0iIVxJWLhxQ+DwABRYX0FsPAIMZCCVuK/0EM6Pw00uPwiPjmeRkylV+lUkEoWkuKCTxuaBDgY4ITDGprDVGmtJRQp7Weov4IOlfGLVdoupVd1AmXq5OyvpW4fVtBKR+aph0jAqSVOMFIas77njKKoSPzxGtqf1110MQ1QJc7yTY6J6XFZEPpv15cRjo/LRZFx3xf/hwAufxnZR0L1bxvuVG9mfn4q8m1Wgq6JyoWfg+DC12KSfo9Y2MJCIi/mAh5NkiP6wzsryhnQVLDKlnN5P611DuxeImsxYXMoZMqoZ/eT2djdm2PkJCwGilCRM1aTU2dfqpwbdM4aD88FzCfICigNuaIXhzinDrrBQtIn6EoRkqw0T1lplMxeG+lt2SLpcPsZmtjNVrFqb8lNQPm1RWOuo9toCPYeKnIBZt3wzTuEoj27nTVarNLQK1S74IyP8kKvnjtEeUGD0/a4ow9FnUCnARNfSx62ksB5sJV5DV4zi5tzuowTZsvyUM6tpt1U3SiKEIDIteurdS1G7vCNArucvP5cxCVqYbrgaFdRmJMEwvrAqXc= + on_success: change diff --git a/src/lib/core/CONTRIBUTING.md b/src/lib/core/CONTRIBUTING.md new file mode 100644 index 0000000..17a8f4d --- /dev/null +++ b/src/lib/core/CONTRIBUTING.md @@ -0,0 +1,2 @@ +The [Contributing Guidelines](https://github.com/dojo/meta/blob/master/CONTRIBUTING.md) +for all Dojo 2 packages can be found in the [Dojo 2 Meta Repository](https://github.com/dojo/meta#readme). diff --git a/src/lib/core/Gruntfile.js b/src/lib/core/Gruntfile.js new file mode 100644 index 0000000..35c96a6 --- /dev/null +++ b/src/lib/core/Gruntfile.js @@ -0,0 +1,17 @@ +module.exports = function (grunt) { + require('grunt-dojo2').initConfig(grunt, { + dtsGenerator: { + options: { + main: 'dojo-core/main' + } + }, + typedoc: { + options: { + ignoreCompilerErrors: true, // Remove this once compile errors are resolved + } + }, + intern: { + version: 4 + } + }); +}; diff --git a/src/lib/core/LICENSE b/src/lib/core/LICENSE new file mode 100644 index 0000000..e6da784 --- /dev/null +++ b/src/lib/core/LICENSE @@ -0,0 +1,54 @@ +The "New" BSD License +********************* + +Copyright (c) 2015 - 2017, [JS Foundation](https://js.foundation/) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the JS Foundation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------- + +Code for string.codePointAt, string.fromCodePoint, and string.repeat +adapted from polyfills by Mathias Bynens, under the MIT license: + +Copyright Mathias Bynens + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/lib/core/README.md b/src/lib/core/README.md new file mode 100644 index 0000000..3a41837 --- /dev/null +++ b/src/lib/core/README.md @@ -0,0 +1,153 @@ +## The `@dojo/core` repository has been deprecated and merged into [`@dojo/framework`](https://github.com/dojo/framework) + +You can read more about this change on our [blog](https://dojo.io/blog/). We will continue providing patches for `core` and other Dojo 2 repositories, and a [CLI migration tool](https://github.com/dojo/cli-upgrade) is available to aid in migrating projects from v2 to v3. + +*** + +# Dojo 2 core + +[![Build Status](https://travis-ci.org/dojo/core.svg?branch=master)](https://travis-ci.org/dojo/core) +[![codecov.io](https://codecov.io/github/dojo/core/coverage.svg?branch=master)](https://codecov.io/github/dojo/core?branch=master) +[![npm version](https://badge.fury.io/js/%40dojo%2Fcore.svg)](https://badge.fury.io/js/%40dojo%2Fcore) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fdojo%2Fcore.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fdojo%2Fcore?ref=badge_shield) + +This package provides a set of language helpers, utility functions, and classes for writing TypeScript applications. It includes APIs for feature detection, asynchronous operations, basic event handling, +and making HTTP requests. + +## Usage + +To use `@dojo/core`, install the package along with its required peer dependencies: + +```bash +npm install @dojo/core + +# peer dependencies +npm install @dojo/has +npm install @dojo/shim +``` + +## Features + +- [Feature Detection](#feature-detection) +- [Language Utilities](#language-utilities) + - [lang](#lang) + - [load](#load) + - [string](#string) +- [UrlSearchParams](#urlsearchparams) +- [Event Handling](#event-handling) +- [HTTP Requests](#http-requests) +- [Promises and Asynchronous Operations](#promises-and-asynchronous-operations) + - [Promise](#promise) + - [Task](#task) + +### Feature Detection + +Using the latest Web technologies isn't always as straightforward as developers would like due to differing support across platforms. [`@dojo/core/has`](docs/has.md) provides a simple feature detection API that makes it easy to +detect which platforms support which features. + +### Language Utilities + +The core package provides modules offering language utilities. Some of these are heavily based +on methods in the ES2015 proposal; others are additional APIs for commonly-performed tasks. + +#### lang + +The [`@dojo/core/lang` module](docs/lang.md) contains various utility functions for tasks such as copying objects +and creating late-bound or partially applied functions. + +### load +The [`@dojo/core/load` module](docs/load.md) can be used to dynamically load modules or other arbitrary resources via plugins. + +#### string + +The [`@dojo/core/stringExtras` module](docs/stringExtras.md) contains various string functions that are not available as part of the ES2015 String APIs. + +#### UrlSearchParams + +The [`@dojo/core/UrlSearchParams` class](docs/UrlSearchParams.md) can be used to parse and generate URL query strings. + +#### Event handling + +The [`@dojo/core/on` module](docs/on.md) contains methods to handle events across types of listeners. It also includes methods to handle different event use cases including only firing +once and pauseable events. + +#### HTTP requests + +The [`@dojo/core/request` module](docs/request.md) contains methods to simplify making HTTP requests. It can handle +making requests in both node and the browser through the same methods. + +### Promises and Asynchronous Operations + +#### Promise + +The `@dojo/core/Promise` class is an implementation of the ES2015 Promise API that also includes static state inspection and a `finally` method for cleanup actions. + +`@dojo/core/async` contains a number of classes and utility modules to simplify working with asynchronous operations. + +#### Task + +The `@dojo/core/async/Task` class is an extension of `@dojo/core/Promise` that provides cancelation support. + +### Code Style + +This repository uses [`prettier`](https://prettier.io/) for code styling rules and formatting. A pre-commit hook is installed automatically and configured to run `prettier` against all staged files as per the configuration in the project's `package.json`. + +An additional npm script to run `prettier` (with write set to `true`) against all `src` and `test` project files is available by running: + +```bash +npm run prettier +``` + +### Installation + +To start working with this package, clone the repository and run `npm install`. + +In order to build the project run `grunt dev` or `grunt dist`. + +### Testing + +Test cases MUST be written using [Intern](https://theintern.github.io) using the Object test interface and Assert assertion interface. + +90% branch coverage MUST be provided for all code submitted to this repository, as reported by istanbul’s combined coverage results for all supported platforms. + +To test locally in node run: + +`grunt test` + +To test against browsers with a local selenium server run: + +`grunt test:local` + +To test against BrowserStack or Sauce Labs run: + +`grunt test:browserstack` + +or + +`grunt test:saucelabs` + +## Licensing information + +© 2004–2018 [JS Foundation](https://js.foundation/) & contributors. [New BSD](http://opensource.org/licenses/BSD-3-Clause) license. + +Some string functions (`codePointAt`, `fromCodePoint`, and `repeat`) adopted from polyfills by Mathias Bynens, +under the [MIT](http://opensource.org/licenses/MIT) license. + +See [LICENSE](LICENSE) for details. + +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fdojo%2Fcore.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fdojo%2Fcore?ref=badge_large) + + diff --git a/src/lib/core/codecov.yml b/src/lib/core/codecov.yml new file mode 100644 index 0000000..bb117a8 --- /dev/null +++ b/src/lib/core/codecov.yml @@ -0,0 +1,11 @@ +comment: + branches: + - master + - feature/* +coverage: + notify: + slack: + default: + url: "secret:Edc+HC1cJt1JJoV0jwebOEPNfk5DXBFBMMWgjsFRUJUaymGWE8gQ/D8oCHq42U7cXaWEtKDc3fa4hBtdtVyZTsae/MXdu1x4HNkBuLx2ZI3WKOerVZRaJ6bXkA9EtvSXa6gjVouiGGIrnjkb4DxRS72m4bqnFKMHSGkkzgComjk=" + threshold: 2 + attachments: "sunburst, diff" diff --git a/src/lib/core/deploy_key.enc b/src/lib/core/deploy_key.enc new file mode 100644 index 0000000..8fbfcd6 Binary files /dev/null and b/src/lib/core/deploy_key.enc differ diff --git a/src/lib/core/docs/UrlSearchParams.md b/src/lib/core/docs/UrlSearchParams.md new file mode 100644 index 0000000..77ce542 --- /dev/null +++ b/src/lib/core/docs/UrlSearchParams.md @@ -0,0 +1,151 @@ +# UrlSearchParams + +The `UrlSearchParams` object makes working with URL query parameters a little easier. + +## Creating a Url Search Params Object + +### With search params string + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams('a=b&b=c&c=a'); +``` + +### With object of search params + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams({ + a: 'b', + b: 'c', + c: 'a' +}); +``` + +## Instance methods + +### `append` + +Adds the value to the values that are associated with the key. + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams('a=b&b=c&c=a'); + +const key = 'a'; +const value = 'e'; + +searchParams.append(key, value); +``` + +### `delete` + +Removes the key from the search params. + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams('a=b&b=c&c=a'); + +const key = 'a'; + +searchParams.delete(key); +``` + +### `get` + +Retrieves the first value for the key provided. + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams('a=first&a=second'); + +const key = 'a'; + +const result = searchParams.get(key); + +result === 'first'; // true +``` + +### `getAll` + +Retrieves all the values for the key provided. + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams('a=first&a=second'); + +const key = 'a'; + +const result = searchParams.getAll(key); + +result[0] === 'first'; // true +result[1] === 'second'; // true +``` + +### `has` + +Returns true if the key exists within the search params and false if it is not. + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams('a=b&b=c&c=a'); + +const key = 'd'; + +const result = searchParams.has(key); + +result === false; // true +``` + +### `keys` + +Returns an array of the keys of the search params. + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams('a=b&b=c&c=a'); + +const result = searchParams.keys(); + +result instanceof Array; // true +result[0] === 'a'; // true +result[1] === 'b'; // true +result[2] === 'c'; // true +``` + +### `set` + +Sets the value of a key (clears previous values). + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams('a=b&b=c&c=a'); + +const key = 'a'; +const value = 'e'; + +searchParams.set(key, value); +``` + +### `toString` + +Return a string of the search params. + +``` +import { UrlSearchParams } from '@dojo/core/UrlSearchParams'; + +const searchParams = new UrlSearchParams('a=b&b=c&c=a'); + +const result = searchParams.toString(); + +result === 'a=b&b=c&c=a'; // true +``` diff --git a/src/lib/core/docs/api.json b/src/lib/core/docs/api.json new file mode 100644 index 0000000..43be1d5 --- /dev/null +++ b/src/lib/core/docs/api.json @@ -0,0 +1,53322 @@ +{ + "id": 0, + "name": "@dojo/core", + "kind": 0, + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 842, + "name": "\"DateObject\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/DateObject.ts", + "children": [ + { + "id": 870, + "name": "DateObject", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 877, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 878, + "name": "new DateObject", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 879, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + }, + { + "id": 880, + "name": "new DateObject", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 881, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + }, + { + "id": 882, + "name": "new DateObject", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 883, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Date" + } + } + ], + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + }, + { + "id": 884, + "name": "new DateObject", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 885, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "KwArgs", + "id": 843 + } + } + ], + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + }, + { + "id": 886, + "name": "new DateObject", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 71, + "character": 30 + }, + { + "fileName": "DateObject.ts", + "line": 73, + "character": 28 + }, + { + "fileName": "DateObject.ts", + "line": 74, + "character": 28 + }, + { + "fileName": "DateObject.ts", + "line": 75, + "character": 26 + }, + { + "fileName": "DateObject.ts", + "line": 76, + "character": 28 + }, + { + "fileName": "DateObject.ts", + "line": 77, + "character": 15 + } + ] + }, + { + "id": 876, + "name": "utc", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 71, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "DateProperties", + "id": 859 + } + }, + { + "id": 899, + "name": "dayOfMonth", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 900, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "setSignature": [ + { + "id": 901, + "name": "__set", + "kind": 1048576, + "kindString": "Set signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 902, + "name": "day", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 211, + "character": 15 + }, + { + "fileName": "DateObject.ts", + "line": 214, + "character": 15 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.dayOfMonth", + "id": 860 + } + }, + { + "id": 923, + "name": "dayOfWeek", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 924, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 253, + "character": 14 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.dayOfWeek", + "id": 861 + } + }, + { + "id": 889, + "name": "daysInMonth", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 890, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 176, + "character": 16 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.daysInMonth", + "id": 862 + } + }, + { + "id": 903, + "name": "hours", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 904, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "setSignature": [ + { + "id": 905, + "name": "__set", + "kind": 1048576, + "kindString": "Set signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 906, + "name": "hours", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 218, + "character": 10 + }, + { + "fileName": "DateObject.ts", + "line": 221, + "character": 10 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.hours", + "id": 863 + } + }, + { + "id": 887, + "name": "isLeapYear", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 888, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 172, + "character": 15 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.isLeapYear", + "id": 864 + } + }, + { + "id": 915, + "name": "milliseconds", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 916, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "setSignature": [ + { + "id": 917, + "name": "__set", + "kind": 1048576, + "kindString": "Set signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 918, + "name": "milliseconds", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 239, + "character": 17 + }, + { + "fileName": "DateObject.ts", + "line": 242, + "character": 17 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.milliseconds", + "id": 865 + } + }, + { + "id": 907, + "name": "minutes", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 908, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "setSignature": [ + { + "id": 909, + "name": "__set", + "kind": 1048576, + "kindString": "Set signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 910, + "name": "minutes", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 225, + "character": 12 + }, + { + "fileName": "DateObject.ts", + "line": 228, + "character": 12 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.minutes", + "id": 866 + } + }, + { + "id": 895, + "name": "month", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 896, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "setSignature": [ + { + "id": 897, + "name": "__set", + "kind": 1048576, + "kindString": "Set signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 898, + "name": "month", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 198, + "character": 10 + }, + { + "fileName": "DateObject.ts", + "line": 201, + "character": 10 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.month", + "id": 867 + } + }, + { + "id": 911, + "name": "seconds", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 912, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "setSignature": [ + { + "id": 913, + "name": "__set", + "kind": 1048576, + "kindString": "Set signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 914, + "name": "seconds", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 232, + "character": 12 + }, + { + "fileName": "DateObject.ts", + "line": 235, + "character": 12 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.seconds", + "id": 868 + } + }, + { + "id": 919, + "name": "time", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 920, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "setSignature": [ + { + "id": 921, + "name": "__set", + "kind": 1048576, + "kindString": "Set signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 922, + "name": "time", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 246, + "character": 9 + }, + { + "fileName": "DateObject.ts", + "line": 249, + "character": 9 + } + ] + }, + { + "id": 925, + "name": "timezoneOffset", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 926, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 256, + "character": 19 + } + ] + }, + { + "id": 891, + "name": "year", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 892, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "setSignature": [ + { + "id": 893, + "name": "__set", + "kind": 1048576, + "kindString": "Set signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 894, + "name": "year", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 185, + "character": 9 + }, + { + "fileName": "DateObject.ts", + "line": 188, + "character": 9 + } + ], + "implementationOf": { + "type": "reference", + "name": "DateProperties.year", + "id": 869 + } + }, + { + "id": 927, + "name": "add", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 928, + "name": "add", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 929, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + }, + { + "id": 930, + "name": "add", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 931, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "OperationKwArgs", + "id": 851 + } + } + ], + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 260, + "character": 4 + }, + { + "fileName": "DateObject.ts", + "line": 261, + "character": 4 + }, + { + "fileName": "DateObject.ts", + "line": 262, + "character": 4 + } + ] + }, + { + "id": 932, + "name": "compare", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 933, + "name": "compare", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 934, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 290, + "character": 8 + } + ] + }, + { + "id": 935, + "name": "compareDate", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 936, + "name": "compareDate", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 937, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "KwArgs", + "id": 843 + } + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 301, + "character": 12 + } + ] + }, + { + "id": 938, + "name": "compareTime", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 939, + "name": "compareTime", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 940, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "KwArgs", + "id": 843 + } + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 311, + "character": 12 + } + ] + }, + { + "id": 943, + "name": "toDateString", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 944, + "name": "toDateString", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 324, + "character": 13 + } + ] + }, + { + "id": 953, + "name": "toISOString", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 954, + "name": "toISOString", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 339, + "character": 12 + } + ] + }, + { + "id": 955, + "name": "toJSON", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 956, + "name": "toJSON", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 957, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 342, + "character": 7 + } + ] + }, + { + "id": 949, + "name": "toLocaleDateString", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 950, + "name": "toLocaleDateString", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 333, + "character": 19 + } + ] + }, + { + "id": 947, + "name": "toLocaleString", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 948, + "name": "toLocaleString", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 330, + "character": 15 + } + ] + }, + { + "id": 951, + "name": "toLocaleTimeString", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 952, + "name": "toLocaleTimeString", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 336, + "character": 19 + } + ] + }, + { + "id": 941, + "name": "toString", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 942, + "name": "toString", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 321, + "character": 9 + } + ] + }, + { + "id": 945, + "name": "toTimeString", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 946, + "name": "toTimeString", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 327, + "character": 13 + } + ] + }, + { + "id": 958, + "name": "valueOf", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 959, + "name": "valueOf", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 345, + "character": 8 + } + ] + }, + { + "id": 874, + "name": "now", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 875, + "name": "now", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 66, + "character": 11 + } + ] + }, + { + "id": 871, + "name": "parse", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 872, + "name": "parse", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 873, + "name": "str", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "reference", + "name": "DateObject", + "id": 870 + } + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 62, + "character": 13 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 877 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 876 + ] + }, + { + "title": "Accessors", + "kind": 262144, + "children": [ + 899, + 923, + 889, + 903, + 887, + 915, + 907, + 895, + 911, + 919, + 925, + 891 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 927, + 932, + 935, + 938, + 943, + 953, + 955, + 949, + 947, + 951, + 941, + 945, + 958, + 874, + 871 + ] + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 61, + "character": 31 + } + ], + "implementedTypes": [ + { + "type": "reference", + "name": "DateProperties", + "id": 859 + } + ] + }, + { + "id": 859, + "name": "DateProperties", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The properties of a complete date" + }, + "children": [ + { + "id": 860, + "name": "dayOfMonth", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 27, + "character": 11 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 861, + "name": "dayOfWeek", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 28, + "character": 19 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 862, + "name": "daysInMonth", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 29, + "character": 21 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 863, + "name": "hours", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 30, + "character": 6 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 864, + "name": "isLeapYear", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 31, + "character": 20 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 865, + "name": "milliseconds", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 32, + "character": 13 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 866, + "name": "minutes", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 33, + "character": 8 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 867, + "name": "month", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 34, + "character": 6 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 868, + "name": "seconds", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 35, + "character": 8 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 869, + "name": "year", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 36, + "character": 5 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 860, + 861, + 862, + 863, + 864, + 865, + 866, + 867, + 868, + 869 + ] + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 26, + "character": 31 + } + ], + "implementedBy": [ + { + "type": "reference", + "name": "DateObject", + "id": 870 + } + ] + }, + { + "id": 843, + "name": "KwArgs", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 844, + "name": "dayOfMonth", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 4, + "character": 11 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 845, + "name": "hours", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 5, + "character": 6 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 846, + "name": "milliseconds", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 6, + "character": 13 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 847, + "name": "minutes", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 7, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 848, + "name": "month", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 8, + "character": 6 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 849, + "name": "seconds", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 9, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 850, + "name": "year", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 10, + "character": 5 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 844, + 845, + 846, + 847, + 848, + 849, + 850 + ] + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 3, + "character": 23 + } + ] + }, + { + "id": 851, + "name": "OperationKwArgs", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 852, + "name": "days", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 14, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 853, + "name": "hours", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 15, + "character": 6 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 854, + "name": "milliseconds", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 16, + "character": 13 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 855, + "name": "minutes", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 17, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 856, + "name": "months", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 18, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 857, + "name": "seconds", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 19, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 858, + "name": "years", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 20, + "character": 6 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 852, + 853, + 854, + 855, + 856, + 857, + 858 + ] + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 13, + "character": 32 + } + ] + }, + { + "id": 960, + "name": "days", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 39, + "character": 10 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "number" + } + }, + "defaultValue": " [NaN, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]" + }, + { + "id": 961, + "name": "isLeapYear", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 41, + "character": 16 + } + ], + "type": { + "type": "reference", + "name": "isLeapYear" + }, + "defaultValue": " (function() {\n\tconst date = new Date();\n\tfunction isLeapYear(year: number): boolean {\n\t\tdate.setFullYear(year, 1, 29);\n\t\treturn date.getDate() === 29;\n\t}\n\treturn isLeapYear;\n})()" + }, + { + "id": 963, + "name": "operationHash", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 51, + "character": 19 + } + ], + "type": { + "type": "reference", + "name": "Hash", + "id": 19, + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "defaultValue": " Object.create(null, {\n\tdays: { value: 'Date' },\n\thours: { value: 'UTCHours' },\n\tmilliseconds: { value: 'UTCMilliseconds' },\n\tminutes: { value: 'UTCMinutes' },\n\tmonths: { value: 'Month' },\n\tseconds: { value: 'UTCSeconds' },\n\tyears: { value: 'FullYear' }\n})" + }, + { + "id": 962, + "name": "operationOrder", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "DateObject.ts", + "line": 50, + "character": 20 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + }, + "defaultValue": " ['years', 'months', 'days', 'hours', 'minutes', 'seconds', 'milliseconds']" + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 870 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 859, + 843, + 851 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 960, + 961, + 963, + 962 + ] + } + ], + "sources": [ + { + "fileName": "DateObject.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 964, + "name": "\"Destroyable\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/Destroyable.ts", + "children": [ + { + "id": 965, + "name": "Destroyable", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 966, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "signatures": [ + { + "id": 967, + "name": "new Destroyable", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "type": { + "type": "reference", + "name": "Destroyable", + "id": 965 + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 23, + "character": 27 + } + ] + }, + { + "id": 971, + "name": "destroy", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 972, + "name": "destroy", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Destrpys all handers registered for the instance", + "returns": "a promise that resolves once all handles have been destroyed\n" + }, + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 55, + "character": 8 + } + ] + }, + { + "id": 968, + "name": "own", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 969, + "name": "own", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Register handles for the instance that will be destroyed when `this.destroy` is called", + "returns": "a handle for the handle, removes the handle for the instance and calls destroy\n" + }, + "parameters": [ + { + "id": 970, + "name": "handles", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Handle", + "id": 16 + }, + { + "type": "array", + "elementType": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 38, + "character": 4 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 966 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 971, + 968 + ] + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 19, + "character": 24 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "Evented", + "id": 982 + } + ] + }, + { + "id": 975, + "name": "destroyed", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 976, + "name": "destroyed", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "No op function used to replace own, once instance has been destoryed" + }, + "type": { + "type": "intrinsic", + "name": "never" + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 15, + "character": 18 + } + ] + }, + { + "id": 973, + "name": "noop", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 974, + "name": "noop", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "No operation function to replace own once instance is destoryed" + }, + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "boolean" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 8, + "character": 13 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 965 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 975, + 973 + ] + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 977, + "name": "\"Evented\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/Evented.ts", + "children": [ + { + "id": 982, + "name": "Evented", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Event Class" + }, + "typeParameter": [ + { + "id": 983, + "name": "M", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "id": 984, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 985, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "children": [ + { + "id": 1002, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "signatures": [ + { + "id": 1003, + "name": "new Evented", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "type": { + "type": "reference", + "name": "Evented", + "id": 982 + }, + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.__constructor", + "id": 966 + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 23, + "character": 27 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.__constructor", + "id": 966 + } + }, + { + "id": 986, + "name": "__typeMap__", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "Evented.ts", + "line": 64, + "character": 22 + } + ], + "type": { + "type": "reference", + "name": "M", + "id": 983 + } + }, + { + "id": 987, + "name": "listenersMap", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "comment": { + "shortText": "map of listeners keyed by event type" + }, + "sources": [ + { + "fileName": "Evented.ts", + "line": 68, + "character": 23 + } + ], + "type": { + "type": "reference", + "name": "Map", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + ] + }, + { + "type": "array", + "elementType": { + "type": "reference", + "name": "EventedCallback", + "id": 1014, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + } + ] + }, + "defaultValue": " new Map()" + }, + { + "id": 1007, + "name": "destroy", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1008, + "name": "destroy", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Destrpys all handers registered for the instance", + "returns": "a promise that resolves once all handles have been destroyed\n" + }, + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.destroy", + "id": 971 + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 55, + "character": 8 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.destroy", + "id": 971 + } + }, + { + "id": 988, + "name": "emit", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 989, + "name": "emit", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Emits the event object for the specified type" + }, + "typeParameter": [ + { + "id": 990, + "name": "K", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + } + ], + "parameters": [ + { + "id": 991, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the event to emit\n" + }, + "type": { + "type": "unknown", + "name": "M[K]" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + }, + { + "id": 992, + "name": "emit", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 993, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "Evented.ts", + "line": 75, + "character": 5 + }, + { + "fileName": "Evented.ts", + "line": 76, + "character": 5 + }, + { + "fileName": "Evented.ts", + "line": 77, + "character": 5 + } + ] + }, + { + "id": 994, + "name": "on", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 995, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Catch all handler for various call signatures. The signatures are defined in\n`BaseEventedEvents`. You can add your own event type -> handler types by extending\n`BaseEventedEvents`. See example for details.", + "returns": "\n", + "tags": [ + { + "tag": "example", + "text": "\n\ninterface WidgetBaseEvents extends BaseEventedEvents {\n (type: 'properties:changed', handler: PropertiesChangedHandler): Handle;\n}\nclass WidgetBase extends Evented {\n on: WidgetBaseEvents;\n}\n" + } + ] + }, + "typeParameter": [ + { + "id": 996, + "name": "K", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + } + ], + "parameters": [ + { + "id": 997, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + } + }, + { + "id": 998, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventedCallbackOrArray", + "id": 1020, + "typeArguments": [ + { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + }, + { + "type": "unknown", + "name": "M[K]" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 999, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1000, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 1001, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventedCallbackOrArray", + "id": 1020, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "Evented.ts", + "line": 105, + "character": 3 + }, + { + "fileName": "Evented.ts", + "line": 106, + "character": 3 + }, + { + "fileName": "Evented.ts", + "line": 107, + "character": 3 + } + ] + }, + { + "id": 1004, + "name": "own", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1005, + "name": "own", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Register handles for the instance that will be destroyed when `this.destroy` is called", + "returns": "a handle for the handle, removes the handle for the instance and calls destroy\n" + }, + "parameters": [ + { + "id": 1006, + "name": "handles", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Handle", + "id": 16 + }, + { + "type": "array", + "elementType": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + }, + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.own", + "id": 968 + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 38, + "character": 4 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.own", + "id": 968 + } + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1002 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 986, + 987 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1007, + 988, + 994, + 1004 + ] + } + ], + "sources": [ + { + "fileName": "Evented.ts", + "line": 56, + "character": 20 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "Destroyable", + "id": 965 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "QueuingEvented", + "id": 2365 + } + ] + }, + { + "id": 978, + "name": "CustomEventTypes", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 979, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + ], + "indexSignature": [ + { + "id": 980, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 981, + "name": "index", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "Evented.ts", + "line": 40, + "character": 33 + } + ] + }, + { + "id": 1014, + "name": "EventedCallback", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 1015, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1016, + "name": "E", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Evented.ts", + "line": 30, + "character": 27 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 1017, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1018, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A callback that takes an `event` argument" + }, + "parameters": [ + { + "id": 1019, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The event object\n" + }, + "type": { + "type": "typeParameter", + "name": "E", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "boolean" + }, + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Evented.ts", + "line": 30, + "character": 87 + } + ] + } + } + }, + { + "id": 1020, + "name": "EventedCallbackOrArray", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A type which is either a targeted event listener or an array of listeners", + "tags": [ + { + "tag": "template", + "text": "T The type of target for the events" + }, + { + "tag": "template", + "text": "E The event type for the events\n" + } + ] + }, + "typeParameter": [ + { + "id": 1021, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1022, + "name": "E", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Evented.ts", + "line": 49, + "character": 34 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "EventedCallback", + "id": 1014, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "E", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + }, + { + "type": "array", + "elementType": { + "type": "reference", + "name": "EventedCallback", + "id": 1014, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "E", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + } + ] + } + }, + { + "id": 1009, + "name": "regexMap", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "comment": { + "shortText": "Map of computed regular expressions, keyed by string" + }, + "sources": [ + { + "fileName": "Evented.ts", + "line": 8, + "character": 14 + } + ], + "type": { + "type": "reference", + "name": "Map", + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "reference", + "name": "RegExp" + } + ] + }, + "defaultValue": " new Map()" + }, + { + "id": 1010, + "name": "isGlobMatch", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1011, + "name": "isGlobMatch", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Determines is the event type glob has been matched", + "returns": "boolean that indicates if the glob is matched\n" + }, + "parameters": [ + { + "id": 1012, + "name": "globString", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + }, + { + "id": 1013, + "name": "targetString", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "Evented.ts", + "line": 15, + "character": 27 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 982 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 978 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 1014, + 1020 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 1009 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1010 + ] + } + ], + "sources": [ + { + "fileName": "Evented.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1130, + "name": "\"IdentityRegistry\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/IdentityRegistry.ts", + "children": [ + { + "id": 1139, + "name": "IdentityRegistry", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A registry of values, mapped by identities." + }, + "typeParameter": [ + { + "id": 1140, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "children": [ + { + "id": 1141, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1142, + "name": "new IdentityRegistry", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IdentityRegistry", + "id": 1139 + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 34, + "character": 92 + } + ] + }, + { + "id": 1168, + "name": "__@iterator", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1169, + "name": "__@iterator", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "tuple", + "elements": [ + { + "type": "reference", + "name": "Identity", + "id": 1177 + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 175, + "character": 18 + } + ] + }, + { + "id": 1146, + "name": "contains", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1147, + "name": "contains", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Determine whether the value has been registered.", + "returns": "`true` if the value has been registered, `false` otherwise\n" + }, + "parameters": [ + { + "id": 1148, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value" + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 64, + "character": 9 + } + ] + }, + { + "id": 1149, + "name": "delete", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1150, + "name": "delete", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Remove from the registry the value for a given identifier.", + "returns": "`true` if the value was removed, `false` otherwise\n" + }, + "parameters": [ + { + "id": 1151, + "name": "id", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The identifier" + }, + "type": { + "type": "reference", + "name": "Identity", + "id": 1177 + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 73, + "character": 7 + } + ] + }, + { + "id": 1162, + "name": "entries", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1163, + "name": "entries", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "tuple", + "elements": [ + { + "type": "reference", + "name": "Identity", + "id": 1177 + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 151, + "character": 8 + } + ] + }, + { + "id": 1143, + "name": "get", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1144, + "name": "get", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Look up a value by its identifier.", + "text": "Throws if no value has been registered for the given identifier.\n", + "returns": "The value\n" + }, + "parameters": [ + { + "id": 1145, + "name": "id", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The identifier" + }, + "type": { + "type": "reference", + "name": "Identity", + "id": 1177 + } + } + ], + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 50, + "character": 4 + } + ] + }, + { + "id": 1152, + "name": "has", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1153, + "name": "has", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Determine whether a value has been registered for the given identifier.", + "returns": "`true` if a value has been registered, `false` otherwise\n" + }, + "parameters": [ + { + "id": 1154, + "name": "id", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The identifier" + }, + "type": { + "type": "reference", + "name": "Identity", + "id": 1177 + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 88, + "character": 4 + } + ] + }, + { + "id": 1155, + "name": "identify", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1156, + "name": "identify", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Look up the identifier for which the given value has been registered.", + "text": "Throws if the value hasn't been registered.\n", + "returns": "The identifier otherwise\n" + }, + "parameters": [ + { + "id": 1157, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value" + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Identity", + "id": 1177 + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 100, + "character": 9 + } + ] + }, + { + "id": 1166, + "name": "ids", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1167, + "name": "ids", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "reference", + "name": "Identity", + "id": 1177 + } + ] + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 171, + "character": 4 + } + ] + }, + { + "id": 1158, + "name": "register", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1159, + "name": "register", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Register a new value with a new identity.", + "text": "Throws if a different value has already been registered for the given identity,\nor if the value has already been registered with a different identity.\n", + "returns": "A handle for deregistering the value. Note that when called repeatedly with\n the same identifier and value combination, the same handle is returned\n" + }, + "parameters": [ + { + "id": 1160, + "name": "id", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The identifier" + }, + "type": { + "type": "reference", + "name": "Identity", + "id": 1177 + } + }, + { + "id": 1161, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value" + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 119, + "character": 9 + } + ] + }, + { + "id": 1164, + "name": "values", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1165, + "name": "values", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 161, + "character": 7 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1141 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1168, + 1146, + 1149, + 1162, + 1143, + 1152, + 1155, + 1166, + 1158, + 1164 + ] + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 34, + "character": 37 + } + ], + "implementedTypes": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "tuple", + "elements": [ + { + "type": "reference", + "name": "Identity", + "id": 1177 + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + ] + } + ] + }, + { + "id": 1131, + "name": "Entry", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1132, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1133, + "name": "handle", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 11, + "character": 16 + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 1134, + "name": "value", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 12, + "character": 15 + } + ], + "type": { + "type": "typeParameter", + "name": "V" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1133, + 1134 + ] + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 10, + "character": 15 + } + ] + }, + { + "id": 1135, + "name": "State", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1136, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "children": [ + { + "id": 1137, + "name": "entryMap", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 16, + "character": 18 + } + ], + "type": { + "type": "reference", + "name": "Map", + "typeArguments": [ + { + "type": "reference", + "name": "Identity", + "id": 1177 + }, + { + "type": "reference", + "name": "Entry", + "id": 1131, + "typeArguments": [ + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + ] + } + }, + { + "id": 1138, + "name": "idMap", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 17, + "character": 15 + } + ], + "type": { + "type": "reference", + "name": "WeakMap", + "typeArguments": [ + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + }, + { + "type": "reference", + "name": "Identity", + "id": 1177 + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1137, + 1138 + ] + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 15, + "character": 15 + } + ] + }, + { + "id": 1177, + "name": "Identity", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Registry identities can be strings or symbols. Note that the empty string is allowed." + }, + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 29, + "character": 20 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + }, + { + "id": 1172, + "name": "privateStateMap", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 20, + "character": 21 + } + ], + "type": { + "type": "reference", + "name": "WeakMap", + "typeArguments": [ + { + "type": "reference", + "name": "IdentityRegistry", + "id": 1139, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + }, + { + "type": "reference", + "name": "State", + "id": 1135, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + ] + }, + "defaultValue": " new WeakMap, State>()" + }, + { + "id": 1173, + "name": "getState", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1174, + "name": "getState", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1175, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "parameters": [ + { + "id": 1176, + "name": "instance", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IdentityRegistry", + "id": 1139, + "typeArguments": [ + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "State", + "id": 1135, + "typeArguments": [ + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 22, + "character": 17 + } + ] + }, + { + "id": 1170, + "name": "noop", + "kind": 64, + "kindString": "Function", + "flags": { + "isConst": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1171, + "name": "noop", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 8, + "character": 10 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1139 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 1131, + 1135 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 1177 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 1172 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1173, + 1170 + ] + } + ], + "sources": [ + { + "fileName": "IdentityRegistry.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1067, + "name": "\"List\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/List.ts", + "children": [ + { + "id": 1068, + "name": "List", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 1069, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1074, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1075, + "name": "new List", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1076, + "name": "source", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + { + "type": "reference", + "name": "ArrayLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "List", + "id": 1068 + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 17, + "character": 2 + } + ] + }, + { + "id": 1072, + "name": "size", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1073, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 15, + "character": 9 + } + ] + }, + { + "id": 1070, + "name": "__@iterator", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1071, + "name": "__@iterator", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 11, + "character": 18 + } + ] + }, + { + "id": 1077, + "name": "add", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1078, + "name": "add", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1079, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "this" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 35, + "character": 4 + } + ] + }, + { + "id": 1080, + "name": "clear", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1081, + "name": "clear", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 40, + "character": 6 + } + ] + }, + { + "id": 1082, + "name": "delete", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1083, + "name": "delete", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1084, + "name": "idx", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 44, + "character": 7 + } + ] + }, + { + "id": 1085, + "name": "entries", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1086, + "name": "entries", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "tuple", + "elements": [ + { + "type": "intrinsic", + "name": "number" + }, + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 53, + "character": 8 + } + ] + }, + { + "id": 1087, + "name": "forEach", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1088, + "name": "forEach", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1089, + "name": "fn", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1090, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1091, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1092, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 1093, + "name": "idx", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 1094, + "name": "list", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "this" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 57, + "character": 12 + } + ] + } + } + }, + { + "id": 1095, + "name": "thisArg", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 57, + "character": 8 + } + ] + }, + { + "id": 1096, + "name": "has", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1097, + "name": "has", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1098, + "name": "idx", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 61, + "character": 4 + } + ] + }, + { + "id": 1099, + "name": "includes", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1100, + "name": "includes", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1101, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 65, + "character": 9 + } + ] + }, + { + "id": 1102, + "name": "indexOf", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1103, + "name": "indexOf", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1104, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 69, + "character": 8 + } + ] + }, + { + "id": 1105, + "name": "join", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1106, + "name": "join", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1107, + "name": "separator", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + }, + "defaultValue": "\",\"" + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 73, + "character": 5 + } + ] + }, + { + "id": 1108, + "name": "keys", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1109, + "name": "keys", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "intrinsic", + "name": "number" + } + ] + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 77, + "character": 5 + } + ] + }, + { + "id": 1110, + "name": "lastIndexOf", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1111, + "name": "lastIndexOf", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1112, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 81, + "character": 12 + } + ] + }, + { + "id": 1116, + "name": "pop", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1117, + "name": "pop", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 89, + "character": 4 + } + ] + }, + { + "id": 1113, + "name": "push", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1114, + "name": "push", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1115, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 85, + "character": 5 + } + ] + }, + { + "id": 1118, + "name": "splice", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1119, + "name": "splice", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1120, + "name": "start", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 1121, + "name": "deleteCount", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 1122, + "name": "newItems", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + } + ], + "type": { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 93, + "character": 7 + } + ] + }, + { + "id": 1123, + "name": "values", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1124, + "name": "values", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 101, + "character": 7 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1074 + ] + }, + { + "title": "Accessors", + "kind": 262144, + "children": [ + 1072 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1070, + 1077, + 1080, + 1082, + 1085, + 1087, + 1096, + 1099, + 1102, + 1105, + 1108, + 1110, + 1116, + 1113, + 1118, + 1123 + ] + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 10, + "character": 25 + } + ] + }, + { + "id": 1125, + "name": "listItems", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "List.ts", + "line": 4, + "character": 15 + } + ], + "type": { + "type": "reference", + "name": "WeakMap", + "typeArguments": [ + { + "type": "reference", + "name": "List", + "id": 1068, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + ] + }, + "defaultValue": " new WeakMap, any[]>()" + }, + { + "id": 1126, + "name": "getListItems", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1127, + "name": "getListItems", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1128, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1129, + "name": "list", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "List", + "id": 1068, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 6, + "character": 21 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1068 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 1125 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1126 + ] + } + ], + "sources": [ + { + "fileName": "List.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1218, + "name": "\"MatchRegistry\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/MatchRegistry.ts", + "children": [ + { + "id": 1223, + "name": "MatchRegistry", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A registry of values tagged with matchers." + }, + "typeParameter": [ + { + "id": 1224, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1226, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Construct a new MatchRegistry, optionally containing a given default value." + }, + "signatures": [ + { + "id": 1227, + "name": "new MatchRegistry", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Construct a new MatchRegistry, optionally containing a given default value." + }, + "parameters": [ + { + "id": 1228, + "name": "defaultValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "T", + "id": 1224 + } + } + ], + "type": { + "type": "reference", + "name": "MatchRegistry", + "id": 1223 + } + } + ], + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 17, + "character": 46 + } + ] + }, + { + "id": 1225, + "name": "_defaultValue", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 16, + "character": 24 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + }, + { + "id": 1229, + "name": "match", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1230, + "name": "match", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return the first entry in this registry that matches the given arguments. If no entry matches and the registry\nwas created with a default value, that value will be returned. Otherwise, an exception is thrown.", + "returns": "the matching value, or a default value if one exists.\n" + }, + "parameters": [ + { + "id": 1231, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 34, + "character": 6 + } + ] + }, + { + "id": 1232, + "name": "register", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1233, + "name": "register", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Register a test + value pair with this registry." + }, + "parameters": [ + { + "id": 1234, + "name": "test", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The test that will be used to determine if the registered value matches a set of arguments." + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Test", + "id": 1237 + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + }, + { + "id": 1235, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A value being registered." + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + }, + { + "id": 1236, + "name": "first", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "If true, the newly registered test and value will be the first entry in the registry.\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 58, + "character": 9 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1226 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 1225 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1229, + 1232 + ] + } + ], + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 15, + "character": 34 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "ProviderRegistry", + "id": 1600 + } + ] + }, + { + "id": 1219, + "name": "Entry", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An entry in a MatchRegistry. Each Entry contains a test to determine whether the Entry is applicable, and a value for\nthe entry." + }, + "typeParameter": [ + { + "id": 1220, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1221, + "name": "test", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 8, + "character": 14 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Test", + "id": 1237 + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + }, + { + "id": 1222, + "name": "value", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 9, + "character": 15 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1221, + 1222 + ] + } + ], + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 7, + "character": 15 + } + ] + }, + { + "id": 1237, + "name": "Test", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The interface that a test function must implement." + }, + "signatures": [ + { + "id": 1238, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The interface that a test function must implement." + }, + "parameters": [ + { + "id": 1239, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "boolean" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + } + ], + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 85, + "character": 21 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1223 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 1219, + 1237 + ] + } + ], + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2323, + "name": "\"MultiMap\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/MultiMap.ts", + "children": [ + { + "id": 2324, + "name": "MultiMap", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A map implmentation that supports multiple keys for specific value." + }, + "typeParameter": [ + { + "id": 2325, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Accepts the type of the value\n" + } + } + ], + "children": [ + { + "id": 2326, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "signatures": [ + { + "id": 2327, + "name": "new MultiMap", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "parameters": [ + { + "id": 2328, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ArrayLike", + "typeArguments": [ + { + "type": "tuple", + "elements": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + }, + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + }, + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "tuple", + "elements": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + }, + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "MultiMap", + "id": 2324 + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 13, + "character": 22 + } + ] + }, + { + "id": 2363, + "name": "__@toStringTag", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 234, + "character": 21 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "defaultValue": "\"MultiMap\"" + }, + { + "id": 2339, + "name": "size", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Returns the size of the map, based on the number of unique keys" + }, + "getSignature": [ + { + "id": 2340, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns the size of the map, based on the number of unique keys" + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 104, + "character": 9 + } + ] + }, + { + "id": 2361, + "name": "__@iterator", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2362, + "name": "__@iterator", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "tuple", + "elements": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + }, + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 230, + "character": 18 + } + ] + }, + { + "id": 2359, + "name": "clear", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2360, + "name": "clear", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Deletes all keys and their associated values." + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 226, + "character": 6 + } + ] + }, + { + "id": 2341, + "name": "delete", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2342, + "name": "delete", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Deletes the entry for the key provided.", + "returns": "boolean trus if the entry was deleted, false if the entry was not found\n" + }, + "parameters": [ + { + "id": 2343, + "name": "keys", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the key of the entry to remove" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 114, + "character": 7 + } + ] + }, + { + "id": 2348, + "name": "entries", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2349, + "name": "entries", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns an iterator that yields each key/value pair as an array.", + "returns": "An iterator for each key/value pair in the instance.\n" + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "tuple", + "elements": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + }, + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 189, + "character": 8 + } + ] + }, + { + "id": 2350, + "name": "forEach", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2351, + "name": "forEach", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Executes a given function for each map entry. The function\nis invoked with three arguments: the element value, the\nelement key, and the associated Map instance." + }, + "parameters": [ + { + "id": 2352, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The function to execute for each map entry," + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2353, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2354, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2355, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 2356, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 2357, + "name": "mapInstance", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "MultiMap", + "id": 2324, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 215, + "character": 18 + } + ] + } + } + }, + { + "id": 2358, + "name": "context", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "The value to use for `this` for each execution of the calback\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reference", + "name": "__type" + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 215, + "character": 8 + } + ] + }, + { + "id": 2333, + "name": "get", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2334, + "name": "get", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns the value entry for the array of keys", + "returns": "The value if found otherwise `undefined`\n" + }, + "parameters": [ + { + "id": 2335, + "name": "keys", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The array of keys to look up the value for\n" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 70, + "character": 4 + } + ] + }, + { + "id": 2336, + "name": "has", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2337, + "name": "has", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns a boolean indicating if the key exists in the map", + "returns": "boolean true if the key exists otherwise false\n" + }, + "parameters": [ + { + "id": 2338, + "name": "keys", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 89, + "character": 4 + } + ] + }, + { + "id": 2346, + "name": "keys", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2347, + "name": "keys", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return an iterator that yields each key array in the map", + "returns": "An iterator containing the instance's keys.\n" + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 166, + "character": 5 + } + ] + }, + { + "id": 2329, + "name": "set", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2330, + "name": "set", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Sets the value for the array of keys provided", + "returns": "the multi map instance\n" + }, + "parameters": [ + { + "id": 2331, + "name": "keys", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The array of keys to store the value against" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 2332, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the value of the map entry\n" + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "this" + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 45, + "character": 4 + } + ] + }, + { + "id": 2344, + "name": "values", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2345, + "name": "values", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return an iterator that yields each value in the map", + "returns": "An iterator containing the instance's values.\n" + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 144, + "character": 7 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 2326 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 2363 + ] + }, + { + "title": "Accessors", + "kind": 262144, + "children": [ + 2339 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 2361, + 2359, + 2341, + 2348, + 2350, + 2333, + 2336, + 2346, + 2329, + 2344 + ] + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 11, + "character": 29 + } + ], + "implementedTypes": [ + { + "type": "reference", + "name": "Map", + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + }, + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 2324 + ] + } + ], + "sources": [ + { + "fileName": "MultiMap.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1540, + "name": "\"Observable\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/Observable.ts", + "children": [ + { + "id": 1541, + "name": "Observable", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 1542, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1595, + "name": "Observable", + "kind": 1024, + "kindString": "Property", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "node_modules/@dojo/shim/Observable.d.ts", + "line": 154, + "character": 29 + } + ], + "type": { + "type": "reference", + "name": "ObservableConstructor" + } + }, + { + "id": 1566, + "name": "filter", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1567, + "name": "filter", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1568, + "name": "filterFunction", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1569, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1570, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1571, + "name": "x", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 76, + "character": 23 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 76, + "character": 7 + } + ] + }, + { + "id": 1559, + "name": "map", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1560, + "name": "map", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1561, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1562, + "name": "mapFunction", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1563, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1564, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1565, + "name": "x", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "typeParameter", + "name": "U" + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 49, + "character": 20 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "typeParameter", + "name": "U" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 49, + "character": 4 + } + ] + }, + { + "id": 1574, + "name": "mergeAll", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1575, + "name": "mergeAll", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1576, + "name": "concurrent", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 125, + "character": 9 + } + ] + }, + { + "id": 1572, + "name": "toArray", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1573, + "name": "toArray", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 104, + "character": 8 + } + ] + }, + { + "id": 1557, + "name": "toPromise", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1558, + "name": "toPromise", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 36, + "character": 10 + } + ] + }, + { + "id": 1593, + "name": "__@observable", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1594, + "name": "__@observable", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "this" + }, + "overwrites": { + "type": "reference", + "name": "ObservableObject.[Symbol.observable]" + }, + "inheritedFrom": { + "type": "reference", + "name": "Observable.[Symbol.observable]" + } + } + ], + "sources": [ + { + "fileName": "node_modules/@dojo/shim/Observable.d.ts", + "line": 24, + "character": 23 + } + ], + "overwrites": { + "type": "reference", + "name": "ObservableObject.[Symbol.observable]" + }, + "inheritedFrom": { + "type": "reference", + "name": "Observable.[Symbol.observable]" + } + }, + { + "id": 1551, + "name": "defer", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1552, + "name": "defer", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1553, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1554, + "name": "deferFunction", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1555, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1556, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Subscribable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 18, + "character": 31 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 18, + "character": 13 + } + ] + }, + { + "id": 1547, + "name": "from", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1548, + "name": "from", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1549, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1550, + "name": "item", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + { + "type": "reference", + "name": "ArrayLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + { + "type": "reference", + "name": "ObservableObject" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 14, + "character": 12 + } + ] + }, + { + "id": 1543, + "name": "of", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1544, + "name": "of", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1545, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1546, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 10, + "character": 10 + } + ] + }, + { + "id": 1577, + "name": "subscribe", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1578, + "name": "subscribe", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Registers handlers for handling emitted values, error and completions from the observable, and\nexecutes the observable's subscriber function, which will take action to set up the underlying data stream.", + "returns": "A Subscription object that can be used to manage the subscription.\n" + }, + "parameters": [ + { + "id": 1579, + "name": "observer", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The observer object that will handle events\n" + }, + "type": { + "type": "reference", + "name": "Observer", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Subscription" + }, + "inheritedFrom": { + "type": "reference", + "name": "Observable.subscribe" + } + }, + { + "id": 1580, + "name": "subscribe", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Registers handlers for handling emitted values, error and completions from the observable, and\nexecutes the observable's subscriber function, which will take action to set up the underlying data stream.", + "returns": "A Subscription object that can be used to manage the subscription.\n" + }, + "parameters": [ + { + "id": 1581, + "name": "onNext", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A function to handle an emitted value. Value is passed in as the first parameter to the function." + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1582, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1583, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1584, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "node_modules/@dojo/shim/Observable.d.ts", + "line": 23, + "character": 21 + } + ] + } + } + }, + { + "id": 1585, + "name": "onError", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function to handle errors that occur during onNext, or during subscription." + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1586, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1587, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1588, + "name": "error", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + ] + } + }, + { + "id": 1589, + "name": "onComplete", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function that gets called when the subscription is complete, and will not send any more values. This function will also get called if an error occurs and onError is not defined.\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1590, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1591, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1592, + "name": "completeValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Subscription" + }, + "inheritedFrom": { + "type": "reference", + "name": "Observable.subscribe" + } + } + ], + "sources": [ + { + "fileName": "node_modules/@dojo/shim/Observable.d.ts", + "line": 12, + "character": 13 + }, + { + "fileName": "node_modules/@dojo/shim/Observable.d.ts", + "line": 23, + "character": 13 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Observable.subscribe" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1595 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1566, + 1559, + 1574, + 1572, + 1557, + 1593, + 1551, + 1547, + 1543, + 1577 + ] + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 9, + "character": 31 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "Observable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + }, + { + "id": 1596, + "name": "isSubscribable", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1597, + "name": "isSubscribable", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1598, + "name": "object", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 5, + "character": 23 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1541 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1596 + ] + } + ], + "sources": [ + { + "fileName": "Observable.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2364, + "name": "\"QueuingEvented\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/QueuingEvented.ts", + "children": [ + { + "id": 2365, + "name": "QueuingEvented", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "An implementation of the Evented class that queues up events when no listeners are\nlistening. When a listener is subscribed, the queue will be published to the listener.\nWhen the queue is full, the oldest events will be discarded to make room for the newest ones.", + "tags": [ + { + "tag": "property", + "text": "maxEvents The number of events to queue before old events are discarded. If zero (default), an unlimited number of events is queued.\n" + } + ] + }, + "typeParameter": [ + { + "id": 2366, + "name": "M", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "id": 2367, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2368, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "children": [ + { + "id": 2386, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "signatures": [ + { + "id": 2387, + "name": "new QueuingEvented", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "type": { + "type": "reference", + "name": "QueuingEvented", + "id": 2365 + }, + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.__constructor", + "id": 966 + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 23, + "character": 27 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.__constructor", + "id": 966 + } + }, + { + "id": 2384, + "name": "__typeMap__", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "Evented.ts", + "line": 64, + "character": 22 + } + ], + "type": { + "type": "reference", + "name": "M", + "id": 2366 + }, + "inheritedFrom": { + "type": "reference", + "name": "Evented.__typeMap__", + "id": 986 + } + }, + { + "id": 2385, + "name": "listenersMap", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "comment": { + "shortText": "map of listeners keyed by event type" + }, + "sources": [ + { + "fileName": "Evented.ts", + "line": 68, + "character": 23 + } + ], + "type": { + "type": "reference", + "name": "Map", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + ] + }, + { + "type": "array", + "elementType": { + "type": "reference", + "name": "EventedCallback", + "id": 1014, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + } + ] + }, + "defaultValue": " new Map()", + "inheritedFrom": { + "type": "reference", + "name": "Evented.listenersMap", + "id": 987 + } + }, + { + "id": 2369, + "name": "maxEvents", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isPublic": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "QueuingEvented.ts", + "line": 19, + "character": 17 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + }, + "defaultValue": "0" + }, + { + "id": 2391, + "name": "destroy", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2392, + "name": "destroy", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Destrpys all handers registered for the instance", + "returns": "a promise that resolves once all handles have been destroyed\n" + }, + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.destroy", + "id": 971 + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 55, + "character": 8 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.destroy", + "id": 971 + } + }, + { + "id": 2370, + "name": "emit", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2371, + "name": "emit", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2372, + "name": "K", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + } + ], + "parameters": [ + { + "id": 2373, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "unknown", + "name": "M[K]" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + }, + "overwrites": { + "type": "reference", + "name": "Evented.emit", + "id": 988 + } + }, + { + "id": 2374, + "name": "emit", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2375, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + }, + "overwrites": { + "type": "reference", + "name": "Evented.emit", + "id": 988 + } + } + ], + "sources": [ + { + "fileName": "QueuingEvented.ts", + "line": 21, + "character": 5 + }, + { + "fileName": "QueuingEvented.ts", + "line": 22, + "character": 5 + }, + { + "fileName": "QueuingEvented.ts", + "line": 23, + "character": 5 + } + ], + "overwrites": { + "type": "reference", + "name": "Evented.emit", + "id": 988 + } + }, + { + "id": 2376, + "name": "on", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2377, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2378, + "name": "K", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + } + ], + "parameters": [ + { + "id": 2379, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + } + }, + { + "id": 2380, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventedCallbackOrArray", + "id": 1020, + "typeArguments": [ + { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + } + } + }, + { + "type": "unknown", + "name": "M[K]" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + }, + "overwrites": { + "type": "reference", + "name": "Evented.on", + "id": 994 + } + }, + { + "id": 2381, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2382, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 2383, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventedCallbackOrArray", + "id": 1020, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + }, + "overwrites": { + "type": "reference", + "name": "Evented.on", + "id": 994 + } + } + ], + "sources": [ + { + "fileName": "QueuingEvented.ts", + "line": 53, + "character": 3 + }, + { + "fileName": "QueuingEvented.ts", + "line": 54, + "character": 3 + }, + { + "fileName": "QueuingEvented.ts", + "line": 55, + "character": 3 + } + ], + "overwrites": { + "type": "reference", + "name": "Evented.on", + "id": 994 + } + }, + { + "id": 2388, + "name": "own", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2389, + "name": "own", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Register handles for the instance that will be destroyed when `this.destroy` is called", + "returns": "a handle for the handle, removes the handle for the instance and calls destroy\n" + }, + "parameters": [ + { + "id": 2390, + "name": "handles", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Handle", + "id": 16 + }, + { + "type": "array", + "elementType": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + }, + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.own", + "id": 968 + } + } + ], + "sources": [ + { + "fileName": "Destroyable.ts", + "line": 38, + "character": 4 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Destroyable.own", + "id": 968 + } + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 2386 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 2384, + 2385, + 2369 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 2391, + 2370, + 2376, + 2388 + ] + } + ], + "sources": [ + { + "fileName": "QueuingEvented.ts", + "line": 12, + "character": 20 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "Evented", + "id": 982, + "typeArguments": [ + { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 2365 + ] + } + ], + "sources": [ + { + "fileName": "QueuingEvented.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2019, + "name": "\"Scheduler\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/Scheduler.ts", + "children": [ + { + "id": 2029, + "name": "Scheduler", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 2056, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2057, + "name": "new Scheduler", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2058, + "name": "kwArgs", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "KwArgs", + "id": 2020 + } + } + ], + "type": { + "type": "reference", + "name": "Scheduler", + "id": 2029 + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 88, + "character": 2 + } + ] + }, + { + "id": 2030, + "name": "_boundDispatch", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 20, + "character": 34 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 2031, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2032, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 20, + "character": 35 + } + ] + } + } + }, + { + "id": 2033, + "name": "_deferred", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 21, + "character": 20 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "reference", + "name": "QueueItem" + } + }, + { + "type": "intrinsic", + "name": "null" + } + ] + }, + "defaultValue": " null" + }, + { + "id": 2034, + "name": "_isProcessing", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 22, + "character": 24 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 2035, + "name": "_queue", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 23, + "character": 26 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "reference", + "name": "QueueItem" + } + } + }, + { + "id": 2036, + "name": "_task", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 24, + "character": 16 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Handle", + "id": 16 + }, + { + "type": "intrinsic", + "name": "null" + } + ] + }, + "defaultValue": " null" + }, + { + "id": 2037, + "name": "deferWhileProcessing", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Determines whether any callbacks registered during should be added to the current batch (`false`)\nor deferred until the next batch (`true`, default)." + }, + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 30, + "character": 21 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "boolean" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + }, + { + "id": 2038, + "name": "queueFunction", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Allows users to specify the function that should be used to schedule callbacks.\nIf no function is provided, then `queueTask` will be used." + }, + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 36, + "character": 14 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 2039, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2040, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2041, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2042, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2043, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2044, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 36, + "character": 26 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 36, + "character": 15 + } + ] + } + } + }, + { + "id": 2045, + "name": "_defer", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2046, + "name": "_defer", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2047, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2048, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2049, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2050, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 38, + "character": 27 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 38, + "character": 17 + } + ] + }, + { + "id": 2051, + "name": "_dispatch", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2052, + "name": "_dispatch", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 53, + "character": 20 + } + ] + }, + { + "id": 2053, + "name": "_schedule", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2054, + "name": "_schedule", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2055, + "name": "item", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "QueueItem" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 82, + "character": 20 + } + ] + }, + { + "id": 2059, + "name": "schedule", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2060, + "name": "schedule", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2061, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2062, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2063, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2064, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 99, + "character": 19 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 99, + "character": 9 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 2056 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 2030, + 2033, + 2034, + 2035, + 2036, + 2037, + 2038 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 2045, + 2051, + 2053, + 2059 + ] + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 19, + "character": 30 + } + ] + }, + { + "id": 2020, + "name": "KwArgs", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 2021, + "name": "deferWhileProcessing", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 15, + "character": 21 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 2022, + "name": "queueFunction", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 16, + "character": 14 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 2023, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2024, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2025, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2026, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2027, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2028, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 16, + "character": 27 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ] + } + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 2021, + 2022 + ] + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 14, + "character": 23 + } + ] + }, + { + "id": 2065, + "name": "getQueueHandle", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2066, + "name": "getQueueHandle", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2067, + "name": "item", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "QueueItem" + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 4, + "character": 23 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 2029 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 2020 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 2065 + ] + } + ], + "sources": [ + { + "fileName": "Scheduler.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1506, + "name": "\"UrlSearchParams\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/UrlSearchParams.ts", + "children": [ + { + "id": 1507, + "name": "UrlSearchParams", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Represents a set of URL query search parameters." + }, + "children": [ + { + "id": 1508, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Constructs a new UrlSearchParams from a query string, an object of parameters and values, or another\nUrlSearchParams." + }, + "signatures": [ + { + "id": 1509, + "name": "new UrlSearchParams", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Constructs a new UrlSearchParams from a query string, an object of parameters and values, or another\nUrlSearchParams." + }, + "parameters": [ + { + "id": 1510, + "name": "input", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "reference", + "name": "ParamList", + "id": 1536 + }, + { + "type": "reference", + "name": "UrlSearchParams", + "id": 1507 + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "UrlSearchParams", + "id": 1507 + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 44, + "character": 38 + } + ] + }, + { + "id": 1511, + "name": "_list", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "comment": { + "shortText": "Maps property keys to arrays of values. The value for any property that has been set will be an array containing\nat least one item. Properties that have been deleted will have a value of 'undefined'." + }, + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 81, + "character": 25 + } + ], + "type": { + "type": "reference", + "name": "Hash", + "id": 19, + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + ] + } + }, + { + "id": 1512, + "name": "append", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1513, + "name": "append", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Appends a new value to the set of values for a key." + }, + "parameters": [ + { + "id": 1514, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The key to add a value for" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1515, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to add\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 88, + "character": 7 + } + ] + }, + { + "id": 1516, + "name": "delete", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1517, + "name": "delete", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Deletes all values for a key." + }, + "parameters": [ + { + "id": 1518, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The key whose values are to be removed\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 103, + "character": 7 + } + ] + }, + { + "id": 1519, + "name": "get", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1520, + "name": "get", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns the first value associated with a key.", + "returns": "The first string value for the key\n" + }, + "parameters": [ + { + "id": 1521, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The key to return the first value for" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 115, + "character": 4 + } + ] + }, + { + "id": 1522, + "name": "getAll", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1523, + "name": "getAll", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns all the values associated with a key.", + "returns": "An array of strings containing all values for the key\n" + }, + "parameters": [ + { + "id": 1524, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The key to return all values for" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 128, + "character": 7 + } + ] + }, + { + "id": 1525, + "name": "has", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1526, + "name": "has", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns true if a key has been set to any value, false otherwise.", + "returns": "A boolean indicating if the key has been set\n" + }, + "parameters": [ + { + "id": 1527, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The key to test for existence" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 140, + "character": 4 + } + ] + }, + { + "id": 1528, + "name": "keys", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1529, + "name": "keys", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns an array of all keys which have been set.", + "returns": "An array of strings containing all keys set in the UrlSearchParams instance\n" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 148, + "character": 5 + } + ] + }, + { + "id": 1530, + "name": "set", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1531, + "name": "set", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Sets the value associated with a key." + }, + "parameters": [ + { + "id": 1532, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The key to set the value of\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1533, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 164, + "character": 4 + } + ] + }, + { + "id": 1534, + "name": "toString", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1535, + "name": "toString", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns this object's data as an encoded query string.", + "returns": "A string in application/x-www-form-urlencoded format containing all of the set keys/values\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 172, + "character": 9 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1508 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 1511 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1512, + 1516, + 1519, + 1522, + 1525, + 1528, + 1530, + 1534 + ] + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 44, + "character": 36 + } + ] + }, + { + "id": 1536, + "name": "ParamList", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Object with string keys and string or string array values that describes a query string." + }, + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 7, + "character": 21 + } + ], + "type": { + "type": "reference", + "name": "Hash", + "id": 19, + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + ] + } + }, + { + "id": 1537, + "name": "parseQueryString", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1538, + "name": "parseQueryString", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Parses a query string, returning a ParamList object." + }, + "parameters": [ + { + "id": 1539, + "name": "input", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "reference", + "name": "ParamList", + "id": 1536 + } + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 12, + "character": 25 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1507 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 1536 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1537 + ] + } + ], + "sources": [ + { + "fileName": "UrlSearchParams.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 455, + "name": "\"aspect\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/aspect.ts", + "children": [ + { + "id": 469, + "name": "Advised", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A meta data structure when applying advice" + }, + "children": [ + { + "id": 471, + "name": "advice", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 38, + "character": 7 + } + ], + "type": { + "type": "reference", + "name": "Function" + } + }, + { + "id": 470, + "name": "id", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 37, + "character": 12 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 473, + "name": "next", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 40, + "character": 5 + } + ], + "type": { + "type": "reference", + "name": "Advised", + "id": 469 + } + }, + { + "id": 472, + "name": "previous", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 39, + "character": 9 + } + ], + "type": { + "type": "reference", + "name": "Advised", + "id": 469 + } + }, + { + "id": 474, + "name": "receiveArguments", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 41, + "character": 26 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 471, + 470, + 473, + 472, + 474 + ] + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 36, + "character": 17 + } + ] + }, + { + "id": 475, + "name": "Dispatcher", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A function that dispatches advice which is decorated with additional\nmeta data about the advice to apply" + }, + "signatures": [ + { + "id": 478, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A function that dispatches advice which is decorated with additional\nmeta data about the advice to apply" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "indexSignature": [ + { + "id": 476, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A function that dispatches advice which is decorated with additional\nmeta data about the advice to apply" + }, + "parameters": [ + { + "id": 477, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Advised", + "id": 469 + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + } + ], + "children": [ + { + "id": 482, + "name": "after", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 54, + "character": 6 + } + ], + "type": { + "type": "reference", + "name": "Advised", + "id": 469 + } + }, + { + "id": 481, + "name": "around", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 53, + "character": 7 + } + ], + "type": { + "type": "reference", + "name": "Advised", + "id": 469 + } + }, + { + "id": 480, + "name": "before", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 52, + "character": 7 + } + ], + "type": { + "type": "reference", + "name": "Advised", + "id": 469 + } + }, + { + "id": 479, + "name": "target", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 51, + "character": 7 + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 482, + 481, + 480, + 479 + ] + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 48, + "character": 20 + } + ] + }, + { + "id": 503, + "name": "GenericFunction", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 504, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 505, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 506, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 96, + "character": 32 + } + ] + }, + { + "id": 466, + "name": "Indexable", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "indexSignature": [ + { + "id": 467, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 468, + "name": "method", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 22, + "character": 26 + } + ] + }, + { + "id": 488, + "name": "JoinPointAfterAdvice", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 489, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 490, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Advice which is applied *after*, receiving the result and arguments from the join point.", + "returns": "The value returned from the advice is then the result of calling the method\n" + }, + "parameters": [ + { + "id": 491, + "name": "result", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The result from the function being advised" + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 492, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "comment": { + "text": "The arguments that were supplied to the advised function" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 63, + "character": 37 + } + ] + }, + { + "id": 493, + "name": "JoinPointAroundAdvice", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 494, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 495, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Advice which is applied *around*. The advising function receives the original function and\nneeds to return a new function which will then invoke the original function.", + "returns": "A new function which will invoke the original function.\n" + }, + "parameters": [ + { + "id": 496, + "name": "origFn", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The original function" + }, + "type": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 497, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 498, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 499, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 82, + "character": 30 + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 74, + "character": 38 + } + ] + }, + { + "id": 500, + "name": "JoinPointBeforeAdvice", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 501, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Advice which is applied *before*, receiving the original arguments, if the advising\nfunction returns a value, it is passed further along taking the place of the original\narguments." + }, + "parameters": [ + { + "id": 502, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "comment": { + "text": "The arguments the method was called with\n" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + }, + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 85, + "character": 38 + } + ] + }, + { + "id": 483, + "name": "JoinPointDispatchAdvice", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 484, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 486, + "name": "after", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 59, + "character": 6 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "reference", + "name": "JoinPointAfterAdvice", + "id": 488, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + }, + { + "id": 485, + "name": "before", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 58, + "character": 7 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "reference", + "name": "JoinPointBeforeAdvice", + "id": 500 + } + } + }, + { + "id": 487, + "name": "joinPoint", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 60, + "character": 19 + } + ], + "type": { + "type": "reference", + "name": "Function" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 486, + 485, + 487 + ] + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 57, + "character": 40 + } + ] + }, + { + "id": 456, + "name": "MapLike", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "An object that provides the necessary APIs to be MapLike" + }, + "typeParameter": [ + { + "id": 457, + "name": "K", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 458, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 459, + "name": "get", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 460, + "name": "get", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 461, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "K" + } + } + ], + "type": { + "type": "typeParameter", + "name": "V" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 9, + "character": 4 + } + ] + }, + { + "id": 462, + "name": "set", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 463, + "name": "set", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 464, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "K" + } + }, + { + "id": 465, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "V", + "id": 458 + } + } + ], + "type": { + "type": "intrinsic", + "name": "this" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 10, + "character": 4 + } + ] + } + ], + "groups": [ + { + "title": "Methods", + "kind": 2048, + "children": [ + 459, + 462 + ] + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 8, + "character": 24 + } + ] + }, + { + "id": 511, + "name": "AdviceType", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 31, + "character": 15 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "before" + }, + { + "type": "stringLiteral", + "value": "after" + }, + { + "type": "stringLiteral", + "value": "around" + } + ] + } + }, + { + "id": 510, + "name": "Targetable", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The types of objects or maps where advice can be applied" + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 29, + "character": 22 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "MapLike", + "id": 456, + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + }, + { + "type": "intrinsic", + "name": "any" + } + ] + }, + { + "type": "reference", + "name": "Indexable", + "id": 466 + } + ] + } + }, + { + "id": 512, + "name": "dispatchAdviceMap", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "comment": { + "shortText": "A weak map of dispatchers used to apply the advice" + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 103, + "character": 23 + } + ], + "type": { + "type": "reference", + "name": "WeakMap", + "typeArguments": [ + { + "type": "reference", + "name": "Function" + }, + { + "type": "reference", + "name": "JoinPointDispatchAdvice", + "id": 483, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + ] + }, + "defaultValue": " new WeakMap>()" + }, + { + "id": 513, + "name": "nextId", + "kind": 32, + "kindString": "Variable", + "flags": { + "isLet": true, + "__visited__": true + }, + "comment": { + "shortText": "A UID for tracking advice ordering" + }, + "sources": [ + { + "fileName": "aspect.ts", + "line": 108, + "character": 10 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + }, + "defaultValue": "0" + }, + { + "id": 520, + "name": "adviseJoinPoint", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 521, + "name": "adviseJoinPoint", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Advise a join point (function) with supplied advice" + }, + "typeParameter": [ + { + "id": 522, + "name": "F", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 523, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 524, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 525, + "name": "joinPoint", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The function to be advised" + }, + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + }, + { + "id": 526, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The type of advice to be applied" + }, + "type": { + "type": "reference", + "name": "AdviceType", + "id": 511 + } + }, + { + "id": 527, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The advice to apply\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "JoinPointBeforeAdvice", + "id": 500 + }, + { + "type": "reference", + "name": "JoinPointAfterAdvice", + "id": 488, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + { + "type": "reference", + "name": "JoinPointAroundAdvice", + "id": 493, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 183, + "character": 24 + } + ] + }, + { + "id": 514, + "name": "adviseObject", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 515, + "name": "adviseObject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Internal function that advises a join point", + "returns": "The handle that will remove the advice\n" + }, + "parameters": [ + { + "id": 516, + "name": "dispatcher", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The current advice dispatcher" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Dispatcher", + "id": 475 + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + }, + { + "id": 517, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The type of before or after advice to apply" + }, + "type": { + "type": "reference", + "name": "AdviceType", + "id": 511 + } + }, + { + "id": 518, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The advice to apply" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Function" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + }, + { + "id": 519, + "name": "receiveArguments", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "If true, the advice will receive the arguments passed to the join point" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 119, + "character": 21 + } + ] + }, + { + "id": 552, + "name": "after", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 553, + "name": "after", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Attaches \"after\" advice to be executed after the original method.\nThe advising function will receive the original method's return value and arguments object.\nThe value it returns will be returned from the method when it is called (even if the return value is undefined).", + "returns": "A handle which will remove the aspect when destroy is called\n" + }, + "parameters": [ + { + "id": 554, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Object whose method will be aspected" + }, + "type": { + "type": "reference", + "name": "Targetable", + "id": 510 + } + }, + { + "id": 555, + "name": "methodName", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Name of method to aspect" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + }, + { + "id": 556, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Advising function which will receive the original method's return value and arguments object" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 557, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 558, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 559, + "name": "originalReturn", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 560, + "name": "originalArgs", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IArguments" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 363, + "character": 8 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 561, + "name": "after", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Apply advice *after* the supplied joinPoint (function)" + }, + "typeParameter": [ + { + "id": 562, + "name": "F", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 563, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 564, + "name": "joinPoint", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A function that should have advice applied to" + }, + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + }, + { + "id": 565, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The after advice\n" + }, + "type": { + "type": "reference", + "name": "JoinPointAfterAdvice", + "id": 488, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 360, + "character": 21 + }, + { + "fileName": "aspect.ts", + "line": 371, + "character": 21 + }, + { + "fileName": "aspect.ts", + "line": 372, + "character": 21 + } + ] + }, + { + "id": 537, + "name": "afterJoinPoint", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 538, + "name": "afterJoinPoint", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Apply advice *after* the supplied joinPoint (function)" + }, + "typeParameter": [ + { + "id": 539, + "name": "F", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 540, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 541, + "name": "joinPoint", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A function that should have advice applied to" + }, + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + }, + { + "id": 542, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The after advice\n" + }, + "type": { + "type": "reference", + "name": "JoinPointAfterAdvice", + "id": 488, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 328, + "character": 23 + } + ] + }, + { + "id": 543, + "name": "afterObject", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 544, + "name": "afterObject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Attaches \"after\" advice to be executed after the original method.\nThe advising function will receive the original method's return value and arguments object.\nThe value it returns will be returned from the method when it is called (even if the return value is undefined).", + "returns": "A handle which will remove the aspect when destroy is called\n" + }, + "parameters": [ + { + "id": 545, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Object whose method will be aspected" + }, + "type": { + "type": "reference", + "name": "Targetable", + "id": 510 + } + }, + { + "id": 546, + "name": "methodName", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Name of method to aspect" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + }, + { + "id": 547, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Advising function which will receive the original method's return value and arguments object" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 548, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 549, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 550, + "name": "originalReturn", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 551, + "name": "originalArgs", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IArguments" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 345, + "character": 8 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 342, + "character": 20 + } + ] + }, + { + "id": 580, + "name": "around", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 581, + "name": "around", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Attaches \"around\" advice around the original method.", + "returns": "A handle which will remove the aspect when destroy is called\n" + }, + "parameters": [ + { + "id": 582, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Object whose method will be aspected" + }, + "type": { + "type": "reference", + "name": "Targetable", + "id": 510 + } + }, + { + "id": 583, + "name": "methodName", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Name of method to aspect" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + }, + { + "id": 584, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Advising function which will receive the original function" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 585, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 586, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 587, + "name": "previous", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Function" + } + } + ], + "type": { + "type": "reference", + "name": "Function" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 440, + "character": 8 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 588, + "name": "around", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Apply advice *around* the supplied joinPoint (function)" + }, + "typeParameter": [ + { + "id": 589, + "name": "F", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 590, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 591, + "name": "joinPoint", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A function that should have advice applied to" + }, + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + }, + { + "id": 592, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The around advice\n" + }, + "type": { + "type": "reference", + "name": "JoinPointAroundAdvice", + "id": 493, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 437, + "character": 22 + }, + { + "fileName": "aspect.ts", + "line": 448, + "character": 22 + }, + { + "fileName": "aspect.ts", + "line": 449, + "character": 22 + } + ] + }, + { + "id": 566, + "name": "aroundJoinPoint", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 567, + "name": "aroundJoinPoint", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Apply advice *around* the supplied joinPoint (function)" + }, + "typeParameter": [ + { + "id": 568, + "name": "F", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 569, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 570, + "name": "joinPoint", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A function that should have advice applied to" + }, + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + }, + { + "id": 571, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The around advice\n" + }, + "type": { + "type": "reference", + "name": "JoinPointAroundAdvice", + "id": 493, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 390, + "character": 31 + } + ] + }, + { + "id": 572, + "name": "aroundObject", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 573, + "name": "aroundObject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Attaches \"around\" advice around the original method.", + "returns": "A handle which will remove the aspect when destroy is called\n" + }, + "parameters": [ + { + "id": 574, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Object whose method will be aspected" + }, + "type": { + "type": "reference", + "name": "Targetable", + "id": 510 + } + }, + { + "id": 575, + "name": "methodName", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Name of method to aspect" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + }, + { + "id": 576, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Advising function which will receive the original function" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 577, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 578, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 579, + "name": "previous", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Function" + } + } + ], + "type": { + "type": "reference", + "name": "Function" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 405, + "character": 8 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 402, + "character": 28 + } + ] + }, + { + "id": 606, + "name": "before", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 607, + "name": "before", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Attaches \"before\" advice to be executed before the original method.", + "returns": "A handle which will remove the aspect when destroy is called\n" + }, + "parameters": [ + { + "id": 608, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Object whose method will be aspected" + }, + "type": { + "type": "reference", + "name": "Targetable", + "id": 510 + } + }, + { + "id": 609, + "name": "methodName", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Name of method to aspect" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + }, + { + "id": 610, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Advising function which will receive the same arguments as the original, and may return new arguments" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 611, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 612, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 613, + "name": "originalArgs", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + }, + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 498, + "character": 8 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 614, + "name": "before", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Apply advice *before* the supplied joinPoint (function)" + }, + "typeParameter": [ + { + "id": 615, + "name": "F", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + ], + "parameters": [ + { + "id": 616, + "name": "joinPoint", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A function that should have advice applied to" + }, + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + }, + { + "id": 617, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The before advice\n" + }, + "type": { + "type": "reference", + "name": "JoinPointBeforeAdvice", + "id": 500 + } + } + ], + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 495, + "character": 22 + }, + { + "fileName": "aspect.ts", + "line": 506, + "character": 22 + }, + { + "fileName": "aspect.ts", + "line": 507, + "character": 22 + } + ] + }, + { + "id": 593, + "name": "beforeJoinPoint", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 594, + "name": "beforeJoinPoint", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Apply advice *before* the supplied joinPoint (function)" + }, + "typeParameter": [ + { + "id": 595, + "name": "F", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + ], + "parameters": [ + { + "id": 596, + "name": "joinPoint", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A function that should have advice applied to" + }, + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + }, + { + "id": 597, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The before advice\n" + }, + "type": { + "type": "reference", + "name": "JoinPointBeforeAdvice", + "id": 500 + } + } + ], + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 467, + "character": 31 + } + ] + }, + { + "id": 598, + "name": "beforeObject", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 599, + "name": "beforeObject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Attaches \"before\" advice to be executed before the original method.", + "returns": "A handle which will remove the aspect when destroy is called\n" + }, + "parameters": [ + { + "id": 600, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Object whose method will be aspected" + }, + "type": { + "type": "reference", + "name": "Targetable", + "id": 510 + } + }, + { + "id": 601, + "name": "methodName", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Name of method to aspect" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + }, + { + "id": 602, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Advising function which will receive the same arguments as the original, and may return new arguments" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 603, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 604, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 605, + "name": "originalArgs", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + }, + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 482, + "character": 8 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 479, + "character": 28 + } + ] + }, + { + "id": 528, + "name": "getDispatcherObject", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 529, + "name": "getDispatcherObject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An internal function that resolves or creates the dispatcher for a given join point", + "returns": "The dispatcher\n" + }, + "parameters": [ + { + "id": 530, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The target object or map" + }, + "type": { + "type": "reference", + "name": "Targetable", + "id": 510 + } + }, + { + "id": 531, + "name": "methodName", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The name of the method that the dispatcher should be resolved for" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Dispatcher", + "id": 475 + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 212, + "character": 28 + } + ] + }, + { + "id": 532, + "name": "getJoinPointDispatcher", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 533, + "name": "getJoinPointDispatcher", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns the dispatcher function for a given joinPoint (method/function)" + }, + "typeParameter": [ + { + "id": 534, + "name": "F", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 535, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 536, + "name": "joinPoint", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The function that is to be advised\n" + }, + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "type": { + "type": "typeParameter", + "name": "F", + "constraint": { + "type": "reference", + "name": "GenericFunction", + "id": 503, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 278, + "character": 31 + } + ] + }, + { + "id": 507, + "name": "isMapLike", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 508, + "name": "isMapLike", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An internal type guard that determines if an value is MapLike or not" + }, + "parameters": [ + { + "id": 509, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to guard against\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 18, + "character": 18 + } + ] + }, + { + "id": 618, + "name": "on", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 619, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Attaches advice to be executed after the original method.\nThe advising function will receive the same arguments as the original method.\nThe value it returns will be returned from the method when it is called *unless* its return value is undefined.", + "returns": "A handle which will remove the aspect when destroy is called\n" + }, + "parameters": [ + { + "id": 620, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Object whose method will be aspected" + }, + "type": { + "type": "reference", + "name": "Targetable", + "id": 510 + } + }, + { + "id": 621, + "name": "methodName", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Name of method to aspect" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + }, + { + "id": 622, + "name": "advice", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Advising function which will receive the same arguments as the original method" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 623, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 624, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 625, + "name": "originalArgs", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 529, + "character": 75 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 529, + "character": 18 + } + ] + } + ], + "groups": [ + { + "title": "Interfaces", + "kind": 256, + "children": [ + 469, + 475, + 503, + 466, + 488, + 493, + 500, + 483, + 456 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 511, + 510 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 512, + 513 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 520, + 514, + 552, + 537, + 543, + 580, + 566, + 572, + 606, + 593, + 598, + 528, + 532, + 507, + 618 + ] + } + ], + "sources": [ + { + "fileName": "aspect.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1356, + "name": "\"async/ExtensiblePromise\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/async/ExtensiblePromise.ts", + "children": [ + { + "id": 1357, + "name": "ExtensiblePromise", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "An extensible base to allow Promises to be extended in ES5. This class basically wraps a native Promise object,\ngiving an API like a native promise." + }, + "typeParameter": [ + { + "id": 1358, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1391, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Creates a new extended Promise.", + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "signatures": [ + { + "id": 1392, + "name": "new ExtensiblePromise", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Creates a new extended Promise.", + "tags": [ + { + "tag": "constructor", + "text": "\n" + } + ] + }, + "parameters": [ + { + "id": 1393, + "name": "executor", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "\nThe executor function is called immediately when the Promise is instantiated. It is responsible for\nstarting the asynchronous operation when it is invoked.\n\nThe executor must call either the passed `resolve` function when the asynchronous operation has completed\nsuccessfully, or the `reject` function when the operation fails.\n" + }, + "type": { + "type": "reference", + "name": "Executor", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357 + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 180, + "character": 31 + } + ] + }, + { + "id": 1413, + "name": "__@toStringTag", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 246, + "character": 30 + } + ], + "type": { + "type": "stringLiteral", + "value": "Promise" + } + }, + { + "id": 1390, + "name": "_promise", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "type", + "text": "{Promise}\nThe wrapped promise\n" + } + ] + }, + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 180, + "character": 18 + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 1394, + "name": "catch", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1395, + "name": "catch", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Adds a callback to be invoked when the wrapped Promise is rejected.", + "returns": "\n" + }, + "typeParameter": [ + { + "id": 1396, + "name": "TResult", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1397, + "name": "onRejected", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function to call to handle the error. The parameter to the function will be the caught error.\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 1398, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1399, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1400, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "TResult" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 206, + "character": 14 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "TResult" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 205, + "character": 6 + } + ] + }, + { + "id": 1401, + "name": "then", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1402, + "name": "then", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Adds a callback to be invoked when the wrapped Promise resolves or is rejected.", + "returns": "\n" + }, + "typeParameter": [ + { + "id": 1403, + "name": "TResult1", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1404, + "name": "TResult2", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1405, + "name": "onFulfilled", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function to call to handle the resolution. The paramter to the function will be the resolved value, if any." + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 1406, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1407, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1408, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult1" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "TResult1" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 220, + "character": 15 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + }, + { + "id": 1409, + "name": "onRejected", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function to call to handle the error. The parameter to the function will be the caught error.\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 1410, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1411, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1412, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult2" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "TResult2" + } + ] + }, + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 221, + "character": 14 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult1" + }, + { + "type": "typeParameter", + "name": "TResult2" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 219, + "character": 5 + } + ] + }, + { + "id": 1370, + "name": "all", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "signatures": [ + { + "id": 1371, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 1372, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1373, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "reference", + "name": "DictionaryOfPromises", + "id": 1417, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "reflection", + "declaration": { + "id": 1374, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 1375, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1376, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 88, + "character": 69 + } + ] + } + } + ] + } + }, + { + "id": 1377, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 1378, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1379, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + } + }, + { + "id": 1380, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 1381, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1382, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + } + }, + { + "id": 1383, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 1384, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1385, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "reference", + "name": "ListOfPromises", + "id": 1422, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 88, + "character": 11 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 101, + "character": 11 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 114, + "character": 11 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 127, + "character": 11 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 140, + "character": 11 + } + ] + }, + { + "id": 1386, + "name": "race", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1387, + "name": "race", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when one of the passed in objects have resolved", + "returns": "\n" + }, + "typeParameter": [ + { + "id": 1388, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1389, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "An iterable of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 170, + "character": 12 + } + ] + }, + { + "id": 1359, + "name": "reject", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Return a rejected promise wrapped in an ExtensiblePromise", + "returns": "An extensible promise\n" + }, + "signatures": [ + { + "id": 1360, + "name": "reject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a rejected promise wrapped in an ExtensiblePromise", + "returns": "An extensible promise\n" + }, + "typeParameter": [ + { + "id": 1361, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1362, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The reason for the rejection" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "intrinsic", + "name": "never" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 44, + "character": 14 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 52, + "character": 14 + } + ] + }, + { + "id": 1363, + "name": "resolve", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1364, + "name": "resolve", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a resolved promise wrapped in an ExtensiblePromise", + "returns": "An extensible promise\n" + }, + "typeParameter": [ + { + "id": 1365, + "name": "P", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "type": { + "type": "typeParameter", + "name": "P", + "constraint": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + }, + { + "id": 1366, + "name": "resolve", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a resolved promise wrapped in an ExtensiblePromise", + "returns": "An extensible promise\n" + }, + "typeParameter": [ + { + "id": 1367, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1368, + "name": "P", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "parameters": [ + { + "id": 1369, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to resolve the promise with\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "type": { + "type": "typeParameter", + "name": "P", + "constraint": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 63, + "character": 15 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 72, + "character": 15 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 73, + "character": 15 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1391 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 1413, + 1390 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1394, + 1401, + 1370, + 1386, + 1359, + 1363 + ] + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 37, + "character": 38 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "Task", + "id": 1430 + }, + { + "type": "reference", + "name": "DelayedRejection", + "id": 2248 + } + ] + }, + { + "id": 1417, + "name": "DictionaryOfPromises", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 1418, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 30, + "character": 32 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 1419, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 1420, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1421, + "name": "_", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 30, + "character": 37 + } + ] + } + } + }, + { + "id": 1422, + "name": "ListOfPromises", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 1423, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 31, + "character": 26 + } + ], + "type": { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + } + }, + { + "id": 1414, + "name": "unwrapPromises", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1415, + "name": "unwrapPromises", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Take a list of values, and if any are ExtensiblePromise objects, insert the wrapped Promise in its place,\notherwise use the original object. We use this to help use the native Promise methods like `all` and `race`.", + "returns": "The list of objects, as an array, with ExtensiblePromises being replaced by Promises.\n" + }, + "parameters": [ + { + "id": 1416, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The list of objects to iterate over" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 13, + "character": 30 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1357 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 1417, + 1422 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1414 + ] + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1424, + "name": "\"async/Task\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/async/Task.ts", + "children": [ + { + "id": 1425, + "name": "State", + "kind": 4, + "kindString": "Enumeration", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Describe the internal state of a task." + }, + "children": [ + { + "id": 1429, + "name": "Canceled", + "kind": 16, + "kindString": "Enumeration member", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "async/Task.ts", + "line": 13, + "character": 9 + } + ], + "defaultValue": "3" + }, + { + "id": 1426, + "name": "Fulfilled", + "kind": 16, + "kindString": "Enumeration member", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "async/Task.ts", + "line": 10, + "character": 10 + } + ], + "defaultValue": "0" + }, + { + "id": 1427, + "name": "Pending", + "kind": 16, + "kindString": "Enumeration member", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "async/Task.ts", + "line": 11, + "character": 8 + } + ], + "defaultValue": "1" + }, + { + "id": 1428, + "name": "Rejected", + "kind": 16, + "kindString": "Enumeration member", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "async/Task.ts", + "line": 12, + "character": 9 + } + ], + "defaultValue": "2" + } + ], + "groups": [ + { + "title": "Enumeration members", + "kind": 16, + "children": [ + 1429, + 1426, + 1427, + 1428 + ] + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 9, + "character": 23 + } + ] + }, + { + "id": 1430, + "name": "Task", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Task is an extension of Promise that supports cancellation and the Task#finally method." + }, + "typeParameter": [ + { + "id": 1431, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1464, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n\nCreate a new task. Executor is run immediately. The canceler will be called when the task is canceled.\n" + } + ] + }, + "signatures": [ + { + "id": 1465, + "name": "new Task", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "constructor", + "text": "\n\nCreate a new task. Executor is run immediately. The canceler will be called when the task is canceled.\n" + } + ] + }, + "parameters": [ + { + "id": 1466, + "name": "executor", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Method that initiates some task" + }, + "type": { + "type": "reference", + "name": "Executor", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 1467, + "name": "canceler", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Method to call when the task is canceled\n\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1468, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1469, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430 + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.__constructor", + "id": 1391 + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 206, + "character": 2 + } + ], + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.__constructor", + "id": 1391 + } + }, + { + "id": 1497, + "name": "__@toStringTag", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 246, + "character": 30 + } + ], + "type": { + "type": "stringLiteral", + "value": "Promise" + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.[Symbol.toStringTag]", + "id": 1413 + } + }, + { + "id": 1496, + "name": "_promise", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "type", + "text": "{Promise}\nThe wrapped promise\n" + } + ] + }, + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 180, + "character": 18 + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise._promise", + "id": 1390 + } + }, + { + "id": 1461, + "name": "_state", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "comment": { + "shortText": "The state of the task" + }, + "sources": [ + { + "fileName": "async/Task.ts", + "line": 202, + "character": 17 + } + ], + "type": { + "type": "reference", + "name": "State", + "id": 1425 + } + }, + { + "id": 1462, + "name": "state", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1463, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "State", + "id": 1425 + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 204, + "character": 10 + } + ] + }, + { + "id": 1470, + "name": "cancel", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1471, + "name": "cancel", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Immediately cancels this task if it has not already resolved. This Task and any descendants are synchronously set\nto the Canceled state and any `finally` added downstream from the canceled Task are invoked." + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 295, + "character": 7 + } + ] + }, + { + "id": 1472, + "name": "catch", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1473, + "name": "catch", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1474, + "name": "TResult", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1475, + "name": "onRejected", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 1476, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1477, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1478, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "TResult" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 302, + "character": 14 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "TResult" + } + ] + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.catch", + "id": 1394 + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 301, + "character": 6 + } + ], + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.catch", + "id": 1394 + } + }, + { + "id": 1479, + "name": "finally", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1480, + "name": "finally", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Allows for cleanup actions to be performed after resolution of a Promise." + }, + "parameters": [ + { + "id": 1481, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1482, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1483, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 310, + "character": 18 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 310, + "character": 8 + } + ] + }, + { + "id": 1484, + "name": "then", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1485, + "name": "then", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Adds a callback to be invoked when the Task resolves or is rejected.", + "returns": "A task\n" + }, + "typeParameter": [ + { + "id": 1486, + "name": "TResult1", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1487, + "name": "TResult2", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1488, + "name": "onFulfilled", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function to call to handle the resolution. The paramter to the function will be the resolved value, if any." + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 1489, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1490, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1491, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult1" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "TResult1" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 339, + "character": 15 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + }, + { + "id": 1492, + "name": "onRejected", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function to call to handle the error. The parameter to the function will be the caught error.\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 1493, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1494, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1495, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult2" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "TResult2" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 340, + "character": 14 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult1" + }, + { + "type": "typeParameter", + "name": "TResult2" + } + ] + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.then", + "id": 1401 + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 338, + "character": 5 + } + ], + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.then", + "id": 1401 + } + }, + { + "id": 1445, + "name": "all", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "signatures": [ + { + "id": 1446, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 1447, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1448, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "reference", + "name": "DictionaryOfPromises", + "id": 1417, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reflection", + "declaration": { + "id": 1449, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 1450, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1451, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 99, + "character": 56 + } + ] + } + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + }, + { + "id": 1452, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 1453, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1454, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + }, + { + "id": 1455, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 1456, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1457, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + }, + { + "id": 1458, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 1459, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1460, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "reference", + "name": "ListOfPromises", + "id": 1422, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 99, + "character": 11 + }, + { + "fileName": "async/Task.ts", + "line": 112, + "character": 11 + }, + { + "fileName": "async/Task.ts", + "line": 125, + "character": 11 + }, + { + "fileName": "async/Task.ts", + "line": 138, + "character": 11 + }, + { + "fileName": "async/Task.ts", + "line": 151, + "character": 11 + } + ], + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + }, + { + "id": 1432, + "name": "race", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1433, + "name": "race", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a Task that resolves when one of the passed in objects have resolved", + "returns": "\n" + }, + "typeParameter": [ + { + "id": 1434, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1435, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "An iterable of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.race", + "id": 1386 + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 43, + "character": 12 + } + ], + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.race", + "id": 1386 + } + }, + { + "id": 1436, + "name": "reject", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1437, + "name": "reject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a rejected promise wrapped in a Task", + "returns": "A task\n" + }, + "typeParameter": [ + { + "id": 1438, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1439, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "The reason for the rejection" + }, + "type": { + "type": "reference", + "name": "Error" + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.reject", + "id": 1359 + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 55, + "character": 14 + } + ], + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.reject", + "id": 1359 + } + }, + { + "id": 1440, + "name": "resolve", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "isPublic": true, + "__visited__": true + }, + "comment": { + "shortText": "Return a resolved task.", + "returns": "A task\n" + }, + "signatures": [ + { + "id": 1441, + "name": "resolve", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a resolved task.", + "returns": "A task\n" + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "intrinsic", + "name": "void" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.resolve", + "id": 1363 + } + }, + { + "id": 1442, + "name": "resolve", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a resolved task.", + "returns": "A task\n" + }, + "typeParameter": [ + { + "id": 1443, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1444, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The value to resolve with\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.resolve", + "id": 1363 + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 66, + "character": 22 + }, + { + "fileName": "async/Task.ts", + "line": 75, + "character": 22 + }, + { + "fileName": "async/Task.ts", + "line": 84, + "character": 22 + } + ], + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.resolve", + "id": 1363 + } + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1464 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 1497, + 1496, + 1461 + ] + }, + { + "title": "Accessors", + "kind": 262144, + "children": [ + 1462 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1470, + 1472, + 1479, + 1484, + 1445, + 1432, + 1436, + 1440 + ] + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 36, + "character": 25 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + }, + { + "id": 1498, + "name": "isTask", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1499, + "name": "isTask", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A type guard that determines if `value` is a `Task`" + }, + "typeParameter": [ + { + "id": 1500, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1501, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to guard\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 20, + "character": 22 + } + ] + }, + { + "id": 1502, + "name": "isThenable", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1503, + "name": "isThenable", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns true if a given value has a `then` method.", + "returns": "A type guard if the value is thenable\n" + }, + "typeParameter": [ + { + "id": 1504, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1505, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check if is Thenable" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 29, + "character": 26 + } + ] + } + ], + "groups": [ + { + "title": "Enumerations", + "kind": 4, + "children": [ + 1425 + ] + }, + { + "title": "Classes", + "kind": 128, + "children": [ + 1430 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1498, + 1502 + ] + } + ], + "sources": [ + { + "fileName": "async/Task.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2125, + "name": "\"async/iteration\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/async/iteration.ts", + "children": [ + { + "id": 2126, + "name": "Filterer", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 2127, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 2128, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2129, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 2130, + "name": "index", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 2131, + "name": "array", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "boolean" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "intrinsic", + "name": "boolean" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 287, + "character": 25 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "Mapper", + "id": 2132, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "intrinsic", + "name": "boolean" + } + ] + } + ] + }, + { + "id": 2132, + "name": "Mapper", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 2133, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2134, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 2135, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2136, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 2137, + "name": "index", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 2138, + "name": "array", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "U" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "U" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 289, + "character": 23 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "Filterer", + "id": 2126 + } + ] + }, + { + "id": 2139, + "name": "Reducer", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 2140, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2141, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 2142, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2143, + "name": "previousValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U" + } + }, + { + "id": 2144, + "name": "currentValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 2145, + "name": "index", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 2146, + "name": "array", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "U" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "U" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 293, + "character": 24 + } + ] + }, + { + "id": 2151, + "name": "ValuesAndResults", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2152, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2153, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 10, + "character": 21 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 2154, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 2156, + "name": "results", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 10, + "character": 64 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "U" + } + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + }, + { + "id": 2155, + "name": "values", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 10, + "character": 38 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 2156, + 2155 + ] + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 10, + "character": 29 + } + ] + } + } + }, + { + "id": 2190, + "name": "every", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2191, + "name": "every", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Test whether all elements in the array pass the provided callback", + "returns": "eventually returns true if all values pass; otherwise false\n" + }, + "typeParameter": [ + { + "id": 2192, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2193, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a collection of synchronous/asynchronous values" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2194, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a synchronous/asynchronous test" + }, + "type": { + "type": "reference", + "name": "Filterer", + "id": 2126, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "boolean" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 148, + "character": 21 + } + ] + }, + { + "id": 2195, + "name": "filter", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2196, + "name": "filter", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns an array of elements which pass the provided callback", + "returns": "eventually returns a new array with only values that have passed\n" + }, + "typeParameter": [ + { + "id": 2197, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2198, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a collection of synchronous/asynchronous values" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2199, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a synchronous/asynchronous test" + }, + "type": { + "type": "reference", + "name": "Filterer", + "id": 2126, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 161, + "character": 22 + } + ] + }, + { + "id": 2200, + "name": "find", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2201, + "name": "find", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Find the first value matching a filter function", + "returns": "a promise eventually containing the item or undefined if a match is not found\n" + }, + "typeParameter": [ + { + "id": 2202, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2203, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a collection of synchronous/asynchronous values" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2204, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a synchronous/asynchronous test" + }, + "type": { + "type": "reference", + "name": "Filterer", + "id": 2126, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 179, + "character": 20 + } + ] + }, + { + "id": 2205, + "name": "findIndex", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2206, + "name": "findIndex", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Find the first index with a value matching the filter function", + "returns": "a promise eventually containing the index of the matching item or -1 if a match is not found\n" + }, + "typeParameter": [ + { + "id": 2207, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2208, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a collection of synchronous/asynchronous values" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2209, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a synchronous/asynchronous test" + }, + "type": { + "type": "reference", + "name": "Filterer", + "id": 2126, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "number" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 195, + "character": 25 + } + ] + }, + { + "id": 2168, + "name": "findLastValueIndex", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2169, + "name": "findLastValueIndex", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2170, + "name": "list", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "ArrayLike", + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + }, + { + "id": 2171, + "name": "offset", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 47, + "character": 27 + } + ] + }, + { + "id": 2163, + "name": "findNextValueIndex", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2164, + "name": "findNextValueIndex", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Finds the index of the next value in a sparse array-like object", + "returns": "the offset of the next index with a value; or -1 if not found\n" + }, + "typeParameter": [ + { + "id": 2165, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2166, + "name": "list", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the sparse array-like object" + }, + "type": { + "type": "reference", + "name": "ArrayLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 2167, + "name": "offset", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the starting offset" + }, + "type": { + "type": "intrinsic", + "name": "number" + }, + "defaultValue": " -1" + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 37, + "character": 27 + } + ] + }, + { + "id": 2172, + "name": "generalReduce", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2173, + "name": "generalReduce", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2174, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2175, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2176, + "name": "findNextIndex", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2177, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2178, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2179, + "name": "list", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "ArrayLike", + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + }, + { + "id": 2180, + "name": "offset", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 58, + "character": 15 + } + ] + } + } + }, + { + "id": 2181, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2182, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Reducer", + "id": 2139, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "U" + } + ] + } + }, + { + "id": 2183, + "name": "initialValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "U", + "id": 2175 + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "U" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 57, + "character": 22 + } + ] + }, + { + "id": 2147, + "name": "isThenable", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2148, + "name": "isThenable", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2149, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2150, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 6, + "character": 19 + } + ] + }, + { + "id": 2210, + "name": "map", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2211, + "name": "map", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "transform a list of items using a mapper function", + "returns": "a promise eventually containing a collection of each transformed value\n" + }, + "typeParameter": [ + { + "id": 2212, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2213, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2214, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a collection of synchronous/asynchronous values" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2215, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a synchronous/asynchronous transform function" + }, + "type": { + "type": "reference", + "name": "Mapper", + "id": 2132, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "U" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "U" + } + }, + { + "type": "intrinsic", + "name": "null" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 218, + "character": 19 + } + ] + }, + { + "id": 2157, + "name": "processValuesAndCallback", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2158, + "name": "processValuesAndCallback", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Processes all items and then applies the callback to each item and eventually returns an object containing the\nprocessed values and callback results", + "returns": "a list of objects holding the synchronous values and synchronous results.\n" + }, + "typeParameter": [ + { + "id": 2159, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2160, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2161, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a list of synchronous/asynchronous values to process" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2162, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a callback that maps values to synchronous/asynchronous results" + }, + "type": { + "type": "reference", + "name": "Mapper", + "id": 2132, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "U" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "reference", + "name": "ValuesAndResults", + "id": 2151, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "U" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 19, + "character": 33 + } + ] + }, + { + "id": 2216, + "name": "reduce", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2217, + "name": "reduce", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "reduce a list of items down to a single value", + "returns": "a promise eventually containing a value that is the result of the reduction\n" + }, + "typeParameter": [ + { + "id": 2218, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2219, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2220, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 2221, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a collection of synchronous/asynchronous values" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2222, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "a synchronous/asynchronous reducer function" + }, + "type": { + "type": "reference", + "name": "Reducer", + "id": 2139, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "U" + } + ] + } + }, + { + "id": 2223, + "name": "initialValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "U", + "id": 2219 + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "U" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 234, + "character": 22 + } + ] + }, + { + "id": 2224, + "name": "reduceRight", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2225, + "name": "reduceRight", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2226, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2227, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2228, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 2229, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2230, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Reducer", + "id": 2139, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "U" + } + ] + } + }, + { + "id": 2231, + "name": "initialValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "U", + "id": 2227 + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "U" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 245, + "character": 27 + } + ] + }, + { + "id": 2232, + "name": "series", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2233, + "name": "series", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2234, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2235, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2236, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2237, + "name": "operation", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Mapper", + "id": 2132, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "U" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "U" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 256, + "character": 22 + } + ] + }, + { + "id": 2238, + "name": "some", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2239, + "name": "some", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2240, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2241, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "reference", + "name": "Array", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + } + ] + } + }, + { + "id": 2242, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Filterer", + "id": 2126, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "boolean" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 280, + "character": 20 + } + ] + }, + { + "id": 2184, + "name": "testAndHaltOnCondition", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2185, + "name": "testAndHaltOnCondition", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2186, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2187, + "name": "condition", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 2188, + "name": "items", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + }, + { + "id": 2189, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Filterer", + "id": 2126, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "boolean" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 107, + "character": 31 + } + ] + } + ], + "groups": [ + { + "title": "Interfaces", + "kind": 256, + "children": [ + 2126, + 2132, + 2139 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 2151 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 2190, + 2195, + 2200, + 2205, + 2168, + 2163, + 2172, + 2147, + 2210, + 2157, + 2216, + 2224, + 2232, + 2238, + 2184 + ] + } + ], + "sources": [ + { + "fileName": "async/iteration.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2243, + "name": "\"async/timing\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/async/timing.ts", + "children": [ + { + "id": 2248, + "name": "DelayedRejection", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A Promise that will reject itself automatically after a time.\nUseful for combining with other promises in Promise.race." + }, + "children": [ + { + "id": 2249, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": {}, + "signatures": [ + { + "id": 2250, + "name": "new DelayedRejection", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": {}, + "parameters": [ + { + "id": 2251, + "name": "milliseconds", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "the number of milliseconds to wait before triggering a rejection" + }, + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 2252, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "the reason for the rejection\n" + }, + "type": { + "type": "reference", + "name": "Error" + } + } + ], + "type": { + "type": "reference", + "name": "DelayedRejection", + "id": 2248 + }, + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.__constructor", + "id": 1391 + } + } + ], + "sources": [ + { + "fileName": "async/timing.ts", + "line": 49, + "character": 52 + } + ], + "overwrites": { + "type": "reference", + "name": "ExtensiblePromise.__constructor", + "id": 1391 + } + }, + { + "id": 2304, + "name": "__@toStringTag", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 246, + "character": 30 + } + ], + "type": { + "type": "stringLiteral", + "value": "Promise" + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.[Symbol.toStringTag]", + "id": 1413 + } + }, + { + "id": 2284, + "name": "_promise", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "tags": [ + { + "tag": "type", + "text": "{Promise}\nThe wrapped promise\n" + } + ] + }, + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 180, + "character": 18 + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise._promise", + "id": 1390 + } + }, + { + "id": 2285, + "name": "catch", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2286, + "name": "catch", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Adds a callback to be invoked when the wrapped Promise is rejected.", + "returns": "\n" + }, + "typeParameter": [ + { + "id": 2287, + "name": "TResult", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2288, + "name": "onRejected", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function to call to handle the error. The parameter to the function will be the caught error.\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 2289, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2290, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2291, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "TResult" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 206, + "character": 14 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "any" + }, + { + "type": "typeParameter", + "name": "TResult" + } + ] + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.catch", + "id": 1394 + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 205, + "character": 6 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.catch", + "id": 1394 + } + }, + { + "id": 2292, + "name": "then", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2293, + "name": "then", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Adds a callback to be invoked when the wrapped Promise resolves or is rejected.", + "returns": "\n" + }, + "typeParameter": [ + { + "id": 2294, + "name": "TResult1", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2295, + "name": "TResult2", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2296, + "name": "onFulfilled", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function to call to handle the resolution. The paramter to the function will be the resolved value, if any." + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 2297, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2298, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2299, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult1" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "TResult1" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 220, + "character": 15 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + }, + { + "id": 2300, + "name": "onRejected", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "A function to call to handle the error. The parameter to the function will be the caught error.\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 2301, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2302, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2303, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult2" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "TResult2" + } + ] + }, + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 221, + "character": 14 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "TResult1" + }, + { + "type": "typeParameter", + "name": "TResult2" + } + ] + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.then", + "id": 1401 + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 219, + "character": 5 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.then", + "id": 1401 + } + }, + { + "id": 2264, + "name": "all", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "signatures": [ + { + "id": 2265, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 2266, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2267, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "reference", + "name": "DictionaryOfPromises", + "id": 1417, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "reflection", + "declaration": { + "id": 2268, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 2269, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2270, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 88, + "character": 69 + } + ] + } + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + }, + { + "id": 2271, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 2272, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2273, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + }, + { + "id": 2274, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 2275, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2276, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + }, + { + "id": 2277, + "name": "all", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value\npair, the returned promise's argument is a key/value pair of the original keys with their resolved values.", + "returns": "An extensible promise\n", + "tags": [ + { + "tag": "example", + "text": "\nExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results));\n// { one: 1, two: 2 }\n" + } + ] + }, + "typeParameter": [ + { + "id": 2278, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2279, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "reference", + "name": "ListOfPromises", + "id": 1422, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 88, + "character": 11 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 101, + "character": 11 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 114, + "character": 11 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 127, + "character": 11 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 140, + "character": 11 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.all", + "id": 1370 + } + }, + { + "id": 2280, + "name": "race", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2281, + "name": "race", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a ExtensiblePromise that resolves when one of the passed in objects have resolved", + "returns": "\n" + }, + "typeParameter": [ + { + "id": 2282, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2283, + "name": "iterable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "An iterable of values to resolve. These can be Promises, ExtensiblePromises, or other objects" + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Iterable", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + ] + }, + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "unknown", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "unknown", + "name": "T" + } + ] + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.race", + "id": 1386 + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 170, + "character": 12 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.race", + "id": 1386 + } + }, + { + "id": 2253, + "name": "reject", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Return a rejected promise wrapped in an ExtensiblePromise", + "returns": "An extensible promise\n" + }, + "signatures": [ + { + "id": 2254, + "name": "reject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a rejected promise wrapped in an ExtensiblePromise", + "returns": "An extensible promise\n" + }, + "typeParameter": [ + { + "id": 2255, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2256, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The reason for the rejection" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "intrinsic", + "name": "never" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.reject", + "id": 1359 + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 44, + "character": 14 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 52, + "character": 14 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.reject", + "id": 1359 + } + }, + { + "id": 2257, + "name": "resolve", + "kind": 2048, + "kindString": "Method", + "flags": { + "isStatic": true, + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2258, + "name": "resolve", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a resolved promise wrapped in an ExtensiblePromise", + "returns": "An extensible promise\n" + }, + "typeParameter": [ + { + "id": 2259, + "name": "P", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "type": { + "type": "typeParameter", + "name": "P", + "constraint": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "intrinsic", + "name": "void" + } + ] + } + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.resolve", + "id": 1363 + } + }, + { + "id": 2260, + "name": "resolve", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return a resolved promise wrapped in an ExtensiblePromise", + "returns": "An extensible promise\n" + }, + "typeParameter": [ + { + "id": 2261, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 2262, + "name": "P", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + } + ], + "parameters": [ + { + "id": 2263, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to resolve the promise with\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "PromiseLike", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "type": { + "type": "typeParameter", + "name": "P", + "constraint": { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + }, + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.resolve", + "id": 1363 + } + } + ], + "sources": [ + { + "fileName": "async/ExtensiblePromise.ts", + "line": 63, + "character": 15 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 72, + "character": 15 + }, + { + "fileName": "async/ExtensiblePromise.ts", + "line": 73, + "character": 15 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "ExtensiblePromise.resolve", + "id": 1363 + } + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 2249 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 2304, + 2284 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 2285, + 2292, + 2264, + 2280, + 2253, + 2257 + ] + } + ], + "sources": [ + { + "fileName": "async/timing.ts", + "line": 49, + "character": 29 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "ExtensiblePromise", + "id": 1357, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + ] + }, + { + "id": 2244, + "name": "Identity", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 2245, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 2246, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2247, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IdentityValue", + "id": 2305, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/timing.ts", + "line": 5, + "character": 25 + } + ] + }, + { + "id": 2305, + "name": "IdentityValue", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 2306, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "sources": [ + { + "fileName": "async/timing.ts", + "line": 4, + "character": 25 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reflection", + "declaration": { + "id": 2307, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2308, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "Thenable", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/timing.ts", + "line": 4, + "character": 34 + } + ] + } + } + ] + } + }, + { + "id": 2309, + "name": "delay", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2310, + "name": "delay", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Used for delaying a Promise chain for a specific number of milliseconds.", + "returns": "a function producing a promise that eventually returns the value or executes the value function passed to it; usable with Thenable.then()\n" + }, + "typeParameter": [ + { + "id": 2311, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2312, + "name": "milliseconds", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the number of milliseconds to delay" + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "reference", + "name": "Identity", + "id": 2244, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/timing.ts", + "line": 15, + "character": 21 + } + ] + }, + { + "id": 2313, + "name": "timeout", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2314, + "name": "timeout", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Reject a promise chain if a result hasn't been found before the timeout", + "returns": "a function that produces a promise that is rejected or resolved based on your timeout\n" + }, + "typeParameter": [ + { + "id": 2315, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 2316, + "name": "milliseconds", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "after this number of milliseconds a rejection will be returned" + }, + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 2317, + "name": "reason", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The reason for the rejection" + }, + "type": { + "type": "reference", + "name": "Error" + } + } + ], + "type": { + "type": "reference", + "name": "Identity", + "id": 2244, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "async/timing.ts", + "line": 32, + "character": 23 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 2248 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 2244 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 2305 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 2309, + 2313 + ] + } + ], + "sources": [ + { + "fileName": "async/timing.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 626, + "name": "\"base64\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/base64.ts", + "children": [ + { + "id": 627, + "name": "decode", + "kind": 32, + "kindString": "Variable", + "flags": { + "isExported": true, + "isConst": true, + "__visited__": true + }, + "comment": { + "shortText": "Take a string encoded in base64 and decode it", + "tags": [ + { + "tag": "param", + "text": "The base64 encoded string\n", + "param": "encodedString" + } + ] + }, + "sources": [ + { + "fileName": "base64.ts", + "line": 11, + "character": 19 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 628, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 629, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 630, + "name": "encodedString", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "base64.ts", + "line": 11, + "character": 20 + } + ] + } + }, + "defaultValue": " has('atob')\n\t? function(encodedString: string) {\n\t\t\t/* this allows for utf8 characters to be decoded properly */\n\t\t\treturn decodeURIComponent(\n\t\t\t\tArray.prototype.map\n\t\t\t\t\t.call(\n\t\t\t\t\t\tatob(encodedString),\n\t\t\t\t\t\t(char: string) => '%' + ('00' + char.charCodeAt(0).toString(16)).slice(-2)\n\t\t\t\t\t)\n\t\t\t\t\t.join('')\n\t\t\t);\n\t\t}\n\t: function(encodedString: string): string {\n\t\t\treturn new Buffer(encodedString.toString(), 'base64').toString('utf8');\n\t\t}" + }, + { + "id": 631, + "name": "encode", + "kind": 32, + "kindString": "Variable", + "flags": { + "isExported": true, + "isConst": true, + "__visited__": true + }, + "comment": { + "shortText": "Take a string and encode it to base64", + "tags": [ + { + "tag": "param", + "text": "The string to encode\n", + "param": "rawString" + } + ] + }, + "sources": [ + { + "fileName": "base64.ts", + "line": 31, + "character": 19 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 632, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 633, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 634, + "name": "rawString", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "base64.ts", + "line": 31, + "character": 20 + } + ] + } + }, + "defaultValue": " has('btoa')\n\t? function(decodedString: string) {\n\t\t\t/* this allows for utf8 characters to be encoded properly */\n\t\t\treturn btoa(\n\t\t\t\tencodeURIComponent(decodedString).replace(/%([0-9A-F]{2})/g, (match, code: string) =>\n\t\t\t\t\tString.fromCharCode(Number('0x' + code))\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t: function(rawString: string): string {\n\t\t\treturn new Buffer(rawString.toString(), 'utf8').toString('base64');\n\t\t}" + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 627, + 631 + ] + } + ], + "sources": [ + { + "fileName": "base64.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 635, + "name": "\"compare\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/compare.ts", + "children": [ + { + "id": 675, + "name": "CustomDiff", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A class which is used when making a custom comparison of a non-plain object or array" + }, + "typeParameter": [ + { + "id": 676, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 677, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 678, + "name": "new CustomDiff", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 679, + "name": "diff", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "CustomDiffFunction", + "id": 731, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "CustomDiff", + "id": 675 + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 278, + "character": 40 + } + ] + }, + { + "id": 680, + "name": "diff", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 681, + "name": "diff", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Get the difference of the `value`" + }, + "parameters": [ + { + "id": 682, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to diff" + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 683, + "name": "nameOrIndex", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A `string` if comparing a property or a `number` if comparing an array element" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 684, + "name": "parent", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The outer parent that this value is part of\n" + }, + "type": { + "type": "intrinsic", + "name": "object" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 290, + "character": 5 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 677 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 680 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 277, + "character": 23 + } + ] + }, + { + "id": 649, + "name": "AnonymousConstructRecord", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A record that describes a constructor function and arguments necessary to create an instance of\nan object" + }, + "children": [ + { + "id": 651, + "name": "Ctor", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The constructor function to use to create the instance" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 82, + "character": 5 + } + ], + "type": { + "type": "reference", + "name": "Constructor", + "id": 640 + } + }, + { + "id": 650, + "name": "args", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Any arguments to pass to the constructor function" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 77, + "character": 5 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 652, + "name": "descriptor", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The partial descriptor that is used to set the value of the instance" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 87, + "character": 11 + } + ], + "type": { + "type": "reference", + "name": "ConstructDescriptor", + "id": 645 + } + }, + { + "id": 653, + "name": "propertyRecords", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Any patches to properties that need to occur on the instance" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 92, + "character": 16 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reflection", + "declaration": { + "id": 654, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 655, + "name": "descriptor", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A property descriptor that describes the property in `name`" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 122, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "PropertyDescriptor" + } + }, + { + "id": 656, + "name": "name", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The name of the property on the Object" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 127, + "character": 7 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 657, + "name": "type", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The type of the patch" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 132, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "add" + }, + { + "type": "stringLiteral", + "value": "update" + }, + { + "type": "stringLiteral", + "value": "delete" + } + ] + } + }, + { + "id": 658, + "name": "valueRecords", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Additional patch records which describe the value of the property" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 137, + "character": 15 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reference", + "name": "PatchRecord", + "id": 697 + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 655, + 656, + 657, + 658 + ] + } + ] + } + } + ] + } + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 651, + 650, + 652, + 653 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 73, + "character": 41 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + } + ] + }, + { + "id": 645, + "name": "ConstructDescriptor", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A partial property descriptor that provides the property descriptor flags supported by the\ncomplex property construction of `patch()`", + "text": "All properties are value properties, with the value being supplied by the `ConstructRecord`\n" + }, + "children": [ + { + "id": 646, + "name": "configurable", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Is the property configurable?" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 56, + "character": 13 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 647, + "name": "enumerable", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Is the property enumerable?" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 61, + "character": 11 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 648, + "name": "writable", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Is the property configurable?" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 66, + "character": 9 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 646, + 647, + 648 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 52, + "character": 36 + } + ] + }, + { + "id": 659, + "name": "ConstructRecord", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 662, + "name": "Ctor", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The constructor function to use to create the instance" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 82, + "character": 5 + } + ], + "type": { + "type": "reference", + "name": "Constructor", + "id": 640 + }, + "inheritedFrom": { + "type": "reference", + "name": "AnonymousConstructRecord.Ctor", + "id": 651 + } + }, + { + "id": 661, + "name": "args", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Any arguments to pass to the constructor function" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 77, + "character": 5 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + }, + "inheritedFrom": { + "type": "reference", + "name": "AnonymousConstructRecord.args", + "id": 650 + } + }, + { + "id": 663, + "name": "descriptor", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The partial descriptor that is used to set the value of the instance" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 87, + "character": 11 + } + ], + "type": { + "type": "reference", + "name": "ConstructDescriptor", + "id": 645 + }, + "inheritedFrom": { + "type": "reference", + "name": "AnonymousConstructRecord.descriptor", + "id": 652 + } + }, + { + "id": 660, + "name": "name", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The name of the property on the Object" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 99, + "character": 5 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 664, + "name": "propertyRecords", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Any patches to properties that need to occur on the instance" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 92, + "character": 16 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reflection", + "declaration": { + "id": 665, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 666, + "name": "descriptor", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A property descriptor that describes the property in `name`" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 122, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "PropertyDescriptor" + } + }, + { + "id": 667, + "name": "name", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The name of the property on the Object" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 127, + "character": 7 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 668, + "name": "type", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The type of the patch" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 132, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "add" + }, + { + "type": "stringLiteral", + "value": "update" + }, + { + "type": "stringLiteral", + "value": "delete" + } + ] + } + }, + { + "id": 669, + "name": "valueRecords", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Additional patch records which describe the value of the property" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 137, + "character": 15 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reference", + "name": "PatchRecord", + "id": 697 + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 666, + 667, + 668, + 669 + ] + } + ] + } + } + ] + } + }, + "inheritedFrom": { + "type": "reference", + "name": "AnonymousConstructRecord.propertyRecords", + "id": 653 + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 662, + 661, + 663, + 660, + 664 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 95, + "character": 32 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "AnonymousConstructRecord", + "id": 649 + } + ] + }, + { + "id": 640, + "name": "Constructor", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Interface for a generic constructor function" + }, + "children": [ + { + "id": 641, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 642, + "name": "new Constructor", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 643, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "object" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 41, + "character": 30 + } + ] + }, + { + "id": 644, + "name": "prototype", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 43, + "character": 10 + } + ], + "type": { + "type": "intrinsic", + "name": "object" + } + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 641 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 644 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 41, + "character": 28 + } + ] + }, + { + "id": 636, + "name": "DiffOptions", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 637, + "name": "allowFunctionValues", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Allow functions to be values. Values will be considered equal if the `typeof` both values are `function`.\nWhen adding or updating the property, the value of the property of `a` will be used in the record, which\nwill be a reference to the function." + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 22, + "character": 20 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 638, + "name": "ignoreProperties", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "An array of strings or regular expressions which flag certain properties to be ignored. Alternatively\na function, which returns `true` to have the property ignored or `false` to diff the property." + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 28, + "character": 17 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "reference", + "name": "RegExp" + } + ] + } + }, + { + "type": "reference", + "name": "IgnorePropertyFunction", + "id": 691 + } + ] + } + }, + { + "id": 639, + "name": "ignorePropertyValues", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "An array of strings or regular expressions which flag certain values to be ignored. For flagged properties,\nif the property is present in both `a` and `b` the value will be ignored. If adding the property,\nwhatever the value of the property of `a` will be used, which could be a reference." + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 35, + "character": 21 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "reference", + "name": "RegExp" + } + ] + } + }, + { + "type": "reference", + "name": "IgnorePropertyFunction", + "id": 691 + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 637, + 638, + 639 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 16, + "character": 28 + } + ] + }, + { + "id": 670, + "name": "SpliceRecord", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A record that describes a splice operation to perform on an array to make the array look like another array" + }, + "children": [ + { + "id": 671, + "name": "add", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Any items that are being added to the array" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 152, + "character": 4 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 672, + "name": "deleteCount", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The number of items in the array to delete" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 157, + "character": 12 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 674, + "name": "start", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The index of where to start the splice" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 167, + "character": 6 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 673, + "name": "type", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The type, set to `splice`" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 162, + "character": 5 + } + ], + "type": { + "type": "stringLiteral", + "value": "splice" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 671, + 672, + 674, + 673 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 148, + "character": 29 + } + ] + }, + { + "id": 731, + "name": "CustomDiffFunction", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A function that returns a constructor record or `undefined` when diffing a value" + }, + "typeParameter": [ + { + "id": 732, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 268, + "character": 30 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 733, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 734, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 735, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + }, + { + "id": 736, + "name": "nameOrIndex", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 737, + "name": "parent", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "object" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "AnonymousConstructRecord", + "id": 649 + }, + { + "type": "intrinsic", + "name": "void" + } + ] + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 268, + "character": 35 + } + ] + } + } + }, + { + "id": 691, + "name": "IgnorePropertyFunction", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 14, + "character": 34 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 692, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 693, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 694, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 695, + "name": "a", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 696, + "name": "b", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 14, + "character": 36 + } + ] + } + } + }, + { + "id": 697, + "name": "PatchRecord", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A record that describes the mutations necessary to a property of an object to make that property look\nlike another" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 106, + "character": 23 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 698, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 699, + "name": "descriptor", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A property descriptor that describes the property in `name`" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 122, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "PropertyDescriptor" + } + }, + { + "id": 700, + "name": "name", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The name of the property on the Object" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 127, + "character": 7 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 701, + "name": "type", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The type of the patch" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 132, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "add" + }, + { + "type": "stringLiteral", + "value": "update" + }, + { + "type": "stringLiteral", + "value": "delete" + } + ] + } + }, + { + "id": 702, + "name": "valueRecords", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Additional patch records which describe the value of the property" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 137, + "character": 15 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reference", + "name": "PatchRecord", + "id": 697 + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 699, + 700, + 701, + 702 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 106, + "character": 25 + } + ] + } + } + }, + { + "id": 703, + "name": "PatchTypes", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The different types of patch records supported" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 143, + "character": 22 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "add" + }, + { + "type": "stringLiteral", + "value": "update" + }, + { + "type": "stringLiteral", + "value": "delete" + } + ] + } + }, + { + "id": 687, + "name": "defineProperty", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 9, + "character": 20 + } + ], + "type": { + "type": "reference", + "name": "defineProperty" + }, + "defaultValue": " Object.defineProperty" + }, + { + "id": 686, + "name": "hasOwnProperty", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 8, + "character": 20 + } + ], + "type": { + "type": "reference", + "name": "hasOwnProperty" + }, + "defaultValue": " Object.prototype.hasOwnProperty" + }, + { + "id": 688, + "name": "isArray", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 10, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "isArray" + }, + "defaultValue": " Array.isArray" + }, + { + "id": 689, + "name": "isFrozen", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 11, + "character": 14 + } + ], + "type": { + "type": "reference", + "name": "isFrozen" + }, + "defaultValue": " Object.isFrozen" + }, + { + "id": 690, + "name": "isSealed", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 12, + "character": 14 + } + ], + "type": { + "type": "reference", + "name": "isSealed" + }, + "defaultValue": " Object.isSealed" + }, + { + "id": 685, + "name": "objectCreate", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 7, + "character": 18 + } + ], + "type": { + "type": "reference", + "name": "create" + }, + "defaultValue": " Object.create" + }, + { + "id": 704, + "name": "createConstructRecord", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 705, + "name": "createConstructRecord", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A record that describes how to instantiate a new object via a constructor function" + }, + "parameters": [ + { + "id": 706, + "name": "Ctor", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The constructor function" + }, + "type": { + "type": "reference", + "name": "Constructor", + "id": 640 + } + }, + { + "id": 707, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "Any arguments to be passed to the constructor function\n" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 708, + "name": "descriptor", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "ConstructDescriptor", + "id": 645 + } + } + ], + "type": { + "type": "reference", + "name": "AnonymousConstructRecord", + "id": 649 + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 176, + "character": 37 + } + ] + }, + { + "id": 709, + "name": "createPatchRecord", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 710, + "name": "createPatchRecord", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An internal function that returns a new patch record" + }, + "parameters": [ + { + "id": 711, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The type of patch record" + }, + "type": { + "type": "reference", + "name": "PatchTypes", + "id": 703 + } + }, + { + "id": 712, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The property name the record refers to" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 713, + "name": "descriptor", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "The property descriptor to be installed on the object" + }, + "type": { + "type": "reference", + "name": "PropertyDescriptor" + } + }, + { + "id": 714, + "name": "valueRecords", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "Any subsequenet patch recrds to be applied to the value of the descriptor\n" + }, + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reflection", + "declaration": { + "id": 715, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 716, + "name": "descriptor", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A property descriptor that describes the property in `name`" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 122, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "PropertyDescriptor" + } + }, + { + "id": 717, + "name": "name", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The name of the property on the Object" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 127, + "character": 7 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 718, + "name": "type", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The type of the patch" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 132, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "add" + }, + { + "type": "stringLiteral", + "value": "update" + }, + { + "type": "stringLiteral", + "value": "delete" + } + ] + } + }, + { + "id": 719, + "name": "valueRecords", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Additional patch records which describe the value of the property" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 137, + "character": 15 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reference", + "name": "PatchRecord", + "id": 697 + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 716, + 717, + 718, + 719 + ] + } + ] + } + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "PatchRecord", + "id": 697 + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 200, + "character": 26 + } + ] + }, + { + "id": 720, + "name": "createSpliceRecord", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 721, + "name": "createSpliceRecord", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An internal function that returns a new splice record" + }, + "parameters": [ + { + "id": 722, + "name": "start", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Where in the array to start the splice" + }, + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 723, + "name": "deleteCount", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The number of elements to delete from the array" + }, + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 724, + "name": "add", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "Elements to be added to the target\n" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 228, + "character": 27 + } + ] + }, + { + "id": 725, + "name": "createValuePropertyDescriptor", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 726, + "name": "createValuePropertyDescriptor", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A function that produces a value property descriptor, which assumes that properties are enumerable, writable and configurable\nunless specified" + }, + "parameters": [ + { + "id": 727, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value for the descriptor" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 728, + "name": "writable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Defaults to `true` if not specified" + }, + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "defaultValue": "true" + }, + { + "id": 729, + "name": "enumerable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Defaults to `true` if not specified" + }, + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "defaultValue": "true" + }, + { + "id": 730, + "name": "configurable", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Defaults to `true` if not specified\n" + }, + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "defaultValue": "true" + } + ], + "type": { + "type": "reference", + "name": "PropertyDescriptor" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 251, + "character": 38 + } + ] + }, + { + "id": 823, + "name": "diff", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 824, + "name": "diff", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Compares two plain objects or arrays and return a set of records which describe the differences between the two", + "text": "The records describe what would need to be applied to the second argument to make it look like the first argument\n" + }, + "parameters": [ + { + "id": 825, + "name": "a", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The plain object or array to compare with" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 826, + "name": "b", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The plain object or array to compare to" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 827, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "An options bag that allows configuration of the behaviour of `diff()`\n" + }, + "type": { + "type": "reference", + "name": "DiffOptions", + "id": 636 + }, + "defaultValue": " {}" + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reflection", + "declaration": { + "id": 828, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 829, + "name": "descriptor", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A property descriptor that describes the property in `name`" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 122, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "PropertyDescriptor" + } + }, + { + "id": 830, + "name": "name", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The name of the property on the Object" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 127, + "character": 7 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 831, + "name": "type", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The type of the patch" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 132, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "add" + }, + { + "type": "stringLiteral", + "value": "update" + }, + { + "type": "stringLiteral", + "value": "delete" + } + ] + } + }, + { + "id": 832, + "name": "valueRecords", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Additional patch records which describe the value of the property" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 137, + "character": 15 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reference", + "name": "PatchRecord", + "id": 697 + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 829, + 830, + 831, + 832 + ] + } + ] + } + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 712, + "character": 20 + } + ] + }, + { + "id": 738, + "name": "diffArray", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 739, + "name": "diffArray", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Internal function that detects the differences between an array and another value and returns a set of splice records that\ndescribe the differences" + }, + "parameters": [ + { + "id": 740, + "name": "a", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The first array to compare to" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 741, + "name": "b", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The second value to compare to" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 742, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "An options bag that allows configuration of the behaviour of `diffArray()`\n" + }, + "type": { + "type": "reference", + "name": "DiffOptions", + "id": 636 + } + } + ], + "type": { + "type": "array", + "elementType": { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 306, + "character": 18 + } + ] + }, + { + "id": 743, + "name": "diffPlainObject", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 744, + "name": "diffPlainObject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Internal function that detects the differences between plain objects and returns a set of patch records that\ndescribe the differences" + }, + "parameters": [ + { + "id": 745, + "name": "a", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The first plain object to compare to" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 746, + "name": "b", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The second plain bject to compare to" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 747, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "An options bag that allows configuration of the behaviour of `diffPlainObject()`\n" + }, + "type": { + "type": "reference", + "name": "DiffOptions", + "id": 636 + } + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reflection", + "declaration": { + "id": 748, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 749, + "name": "descriptor", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A property descriptor that describes the property in `name`" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 122, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "PropertyDescriptor" + } + }, + { + "id": 750, + "name": "name", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The name of the property on the Object" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 127, + "character": 7 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 751, + "name": "type", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The type of the patch" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 132, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "add" + }, + { + "type": "stringLiteral", + "value": "update" + }, + { + "type": "stringLiteral", + "value": "delete" + } + ] + } + }, + { + "id": 752, + "name": "valueRecords", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Additional patch records which describe the value of the property" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 137, + "character": 15 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reference", + "name": "PatchRecord", + "id": 697 + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 749, + 750, + 751, + 752 + ] + } + ] + } + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 411, + "character": 24 + } + ] + }, + { + "id": 753, + "name": "getComparableObjects", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 754, + "name": "getComparableObjects", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Takes two plain objects to be compared, as well as options customizing the behavior of the comparison, and returns\ntwo new objects that contain only those properties that should be compared. If a property is ignored\nit will not be included in either returned object. If a property's value should be ignored it will be excluded\nif it is present in both objects." + }, + "parameters": [ + { + "id": 755, + "name": "a", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The first object to compare" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 756, + "name": "b", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The second object to compare" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 757, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "An options bag indicating which properties should be ignored or have their values ignored, if any.\n" + }, + "type": { + "type": "reference", + "name": "DiffOptions", + "id": 636 + } + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 758, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 759, + "name": "comparableA", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 541, + "character": 21 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 760, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 761, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 762, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + }, + { + "id": 763, + "name": "comparableB", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 541, + "character": 34 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 764, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 765, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 766, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + }, + { + "id": 767, + "name": "ignore", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 541, + "character": 42 + } + ], + "type": { + "type": "reference", + "name": "Set", + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 759, + 763, + 767 + ] + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 499, + "character": 36 + } + ] + }, + { + "id": 768, + "name": "isConstructRecord", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 769, + "name": "isConstructRecord", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A guard that determines if the value is a `ConstructRecord`" + }, + "parameters": [ + { + "id": 770, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 548, + "character": 26 + } + ] + }, + { + "id": 789, + "name": "isCustomDiff", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 790, + "name": "isCustomDiff", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A guard that determines if the value is a `CustomDiff`" + }, + "typeParameter": [ + { + "id": 791, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 792, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 616, + "character": 21 + } + ] + }, + { + "id": 771, + "name": "isIgnoredPropertyValue", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 772, + "name": "isIgnoredPropertyValue", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 773, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 774, + "name": "a", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 775, + "name": "b", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 776, + "name": "ignoredPropertyValues", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "reference", + "name": "RegExp" + } + ] + } + }, + { + "type": "reference", + "name": "IgnorePropertyFunction", + "id": 691 + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 552, + "character": 31 + } + ] + }, + { + "id": 777, + "name": "isPatchRecord", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 778, + "name": "isPatchRecord", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A guard that determines if the value is a `PatchRecord`" + }, + "parameters": [ + { + "id": 779, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 570, + "character": 22 + } + ] + }, + { + "id": 780, + "name": "isPatchRecordArray", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 781, + "name": "isPatchRecordArray", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A guard that determines if the value is an array of `PatchRecord`s" + }, + "parameters": [ + { + "id": 782, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 579, + "character": 27 + } + ] + }, + { + "id": 783, + "name": "isPlainObject", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 784, + "name": "isPlainObject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A guard that determines if the value is a plain object. A plain object is an object that has\neither no constructor (e.g. `Object.create(null)`) or has Object as its constructor." + }, + "parameters": [ + { + "id": 785, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 589, + "character": 22 + } + ] + }, + { + "id": 786, + "name": "isPrimitive", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 787, + "name": "isPrimitive", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A guard that determines if the value is a primitive (including `null`), as these values are\nfine to just copy." + }, + "parameters": [ + { + "id": 788, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 601, + "character": 20 + } + ] + }, + { + "id": 793, + "name": "isSpliceRecord", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 794, + "name": "isSpliceRecord", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A guard that determines if the value is a `SpliceRecord`" + }, + "parameters": [ + { + "id": 795, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 625, + "character": 23 + } + ] + }, + { + "id": 796, + "name": "isSpliceRecordArray", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 797, + "name": "isSpliceRecordArray", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A guard that determines if the value is an array of `SpliceRecord`s" + }, + "parameters": [ + { + "id": 798, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 634, + "character": 28 + } + ] + }, + { + "id": 833, + "name": "patch", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 834, + "name": "patch", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Apply a set of patch records to a target." + }, + "parameters": [ + { + "id": 835, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The plain object or array that the patch records should be applied to" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 836, + "name": "records", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A set of patch records to be applied to the target\n" + }, + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reflection", + "declaration": { + "id": 837, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 838, + "name": "descriptor", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A property descriptor that describes the property in `name`" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 122, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "PropertyDescriptor" + } + }, + { + "id": 839, + "name": "name", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The name of the property on the Object" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 127, + "character": 7 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 840, + "name": "type", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The type of the patch" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 132, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "add" + }, + { + "type": "stringLiteral", + "value": "update" + }, + { + "type": "stringLiteral", + "value": "delete" + } + ] + } + }, + { + "id": 841, + "name": "valueRecords", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Additional patch records which describe the value of the property" + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 137, + "character": 15 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + }, + { + "type": "reference", + "name": "PatchRecord", + "id": 697 + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 838, + 839, + 840, + 841 + ] + } + ] + } + }, + { + "type": "reference", + "name": "SpliceRecord", + "id": 670 + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 738, + "character": 21 + } + ] + }, + { + "id": 815, + "name": "patchConstruct", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 816, + "name": "patchConstruct", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 817, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 818, + "name": "record", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "ConstructRecord", + "id": 659 + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 675, + "character": 23 + } + ] + }, + { + "id": 807, + "name": "patchPatch", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 808, + "name": "patchPatch", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An internal function that patches a target with a `PatchRecord`" + }, + "parameters": [ + { + "id": 809, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 810, + "name": "record", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "PatchRecord", + "id": 697 + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 655, + "character": 19 + } + ] + }, + { + "id": 799, + "name": "patchSplice", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 800, + "name": "patchSplice", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An internal function that patches a target with a `SpliceRecord`" + }, + "parameters": [ + { + "id": 801, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 802, + "name": "__namedParameters", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "originalName": "__1", + "type": { + "type": "reflection", + "declaration": { + "id": 803, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 804, + "name": "add", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 641, + "character": 41 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + }, + { + "id": 805, + "name": "deleteCount", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 641, + "character": 54 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 806, + "name": "start", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 641, + "character": 61 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 804, + 805, + 806 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 641, + "character": 35 + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 641, + "character": 20 + } + ] + }, + { + "id": 819, + "name": "resolveTargetValue", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 820, + "name": "resolveTargetValue", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "An internal function that takes a value from array being patched and the target value from the same\nindex and determines the value that should actually be patched into the target array" + }, + "parameters": [ + { + "id": 821, + "name": "patchValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 822, + "name": "targetValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 691, + "character": 27 + } + ] + }, + { + "id": 811, + "name": "defaultConstructDescriptor", + "kind": 2097152, + "kindString": "Object literal", + "flags": { + "isConst": true, + "__visited__": true + }, + "children": [ + { + "id": 812, + "name": "configurable", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 670, + "character": 13 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "defaultValue": "true" + }, + { + "id": 813, + "name": "enumerable", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 671, + "character": 11 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "defaultValue": "true" + }, + { + "id": 814, + "name": "writable", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "compare.ts", + "line": 672, + "character": 9 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "defaultValue": "true" + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 812, + 813, + 814 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 669, + "character": 32 + } + ], + "type": { + "type": "intrinsic", + "name": "object" + } + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 675 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 649, + 645, + 659, + 640, + 636, + 670 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 731, + 691, + 697, + 703 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 687, + 686, + 688, + 689, + 690, + 685 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 704, + 709, + 720, + 725, + 823, + 738, + 743, + 753, + 768, + 789, + 771, + 777, + 780, + 783, + 786, + 793, + 796, + 833, + 815, + 807, + 799, + 819 + ] + }, + { + "title": "Object literals", + "kind": 2097152, + "children": [ + 811 + ] + } + ], + "sources": [ + { + "fileName": "compare.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1066, + "name": "\"global\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/global.ts", + "sources": [ + { + "fileName": "global.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1023, + "name": "\"has\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/has.ts", + "sources": [ + { + "fileName": "has.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1024, + "name": "\"instrument\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/instrument.ts", + "children": [ + { + "id": 1025, + "name": "DeprecatedOptions", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 1026, + "name": "message", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The message to use when warning" + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 17, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1027, + "name": "name", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The name of the method or function to use" + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 22, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1032, + "name": "url", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Reference an URL for more information when warning" + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 32, + "character": 4 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1028, + "name": "warn", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "An alternative function to log the warning to" + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 27, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1029, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1030, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1031, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ] + } + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1026, + 1027, + 1032, + 1028 + ] + } + ], + "sources": [ + { + "fileName": "instrument.ts", + "line": 13, + "character": 34 + } + ] + }, + { + "id": 1033, + "name": "DEFAULT_DEPRECATED_MESSAGE", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "comment": { + "shortText": "The default message to warn when no other is provided" + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 6, + "character": 32 + } + ], + "type": { + "type": "stringLiteral", + "value": "This function will be removed in future versions." + }, + "defaultValue": "\"This function will be removed in future versions.\"" + }, + { + "id": 1034, + "name": "globalWarn", + "kind": 32, + "kindString": "Variable", + "flags": { + "isLet": true, + "__visited__": true + }, + "comment": { + "shortText": "When set, globalWarn will be used instead of `console.warn`" + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 11, + "character": 14 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 1035, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1036, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1037, + "name": "message", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1038, + "name": "optionalParams", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "instrument.ts", + "line": 11, + "character": 15 + } + ] + } + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + }, + { + "id": 1039, + "name": "deprecated", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1040, + "name": "deprecated", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A function that will console warn that a function has been deprecated" + }, + "parameters": [ + { + "id": 1041, + "name": "__namedParameters", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "originalName": "__0", + "type": { + "type": "reflection", + "declaration": { + "id": 1042, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 1043, + "name": "message", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 40, + "character": 36 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1044, + "name": "name", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 40, + "character": 42 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1049, + "name": "url", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 40, + "character": 53 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1045, + "name": "warn", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "instrument.ts", + "line": 40, + "character": 48 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1046, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1047, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1048, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ] + } + } + ] + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 1043, + 1044, + 1049, + 1045 + ] + } + ], + "sources": [ + { + "fileName": "instrument.ts", + "line": 40, + "character": 27 + } + ] + } + }, + "defaultValue": " {}" + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "instrument.ts", + "line": 40, + "character": 26 + } + ] + }, + { + "id": 1050, + "name": "deprecatedAdvice", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1051, + "name": "deprecatedAdvice", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A function that generates before advice that can be used to warn when an API has been deprecated" + }, + "parameters": [ + { + "id": 1052, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "Provide options which change the display of the message\n" + }, + "type": { + "type": "reference", + "name": "DeprecatedOptions", + "id": 1025 + } + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 1053, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1054, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1055, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "sources": [ + { + "fileName": "instrument.ts", + "line": 63, + "character": 62 + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "instrument.ts", + "line": 63, + "character": 32 + } + ] + }, + { + "id": 1056, + "name": "deprecatedDecorator", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1057, + "name": "deprecatedDecorator", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A method decorator that will console warn when a method if invoked that is deprecated" + }, + "parameters": [ + { + "id": 1058, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "Provide options which change the display of the message\n" + }, + "type": { + "type": "reference", + "name": "DeprecatedOptions", + "id": 1025 + } + } + ], + "type": { + "type": "reference", + "name": "MethodDecorator" + } + } + ], + "sources": [ + { + "fileName": "instrument.ts", + "line": 75, + "character": 35 + } + ] + }, + { + "id": 1059, + "name": "setWarn", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1060, + "name": "setWarn", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A function that will set the warn function that will be used instead of `console.warn` when\nlogging warning messages" + }, + "parameters": [ + { + "id": 1061, + "name": "warn", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "The function (or `undefined`) to use instead of `console.warn`\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1062, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1063, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1064, + "name": "message", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1065, + "name": "optionalParams", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ] + } + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "instrument.ts", + "line": 98, + "character": 23 + } + ] + } + ], + "groups": [ + { + "title": "Interfaces", + "kind": 256, + "children": [ + 1025 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 1033, + 1034 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1039, + 1050, + 1056, + 1059 + ] + } + ], + "sources": [ + { + "fileName": "instrument.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1, + "name": "\"interfaces\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/interfaces.ts", + "children": [ + { + "id": 26, + "name": "AmdConfig", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The interfaces to the `@dojo/loader` AMD loader" + }, + "children": [ + { + "id": 27, + "name": "baseUrl", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The base URL that the loader will use to resolve modules" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 76, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 28, + "name": "map", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "A map of module identifiers and their replacement meta data" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 81, + "character": 4 + } + ], + "type": { + "type": "reference", + "name": "AmdModuleMap", + "id": 76 + } + }, + { + "id": 29, + "name": "packages", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "An array of packages that the loader should use when resolving a module ID" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 86, + "character": 9 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "reference", + "name": "AmdPackage", + "id": 95 + } + } + }, + { + "id": 30, + "name": "paths", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "A map of paths to use when resolving modules names" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 91, + "character": 6 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 31, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 32, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 33, + "name": "path", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + } + ] + } + }, + { + "id": 34, + "name": "pkgs", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "A map of packages that the loader should use when resolving a module ID" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 96, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 35, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 36, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 37, + "name": "path", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "reference", + "name": "AmdPackage", + "id": 95 + } + } + ] + } + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 27, + 28, + 29, + 30, + 34 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 72, + "character": 26 + } + ] + }, + { + "id": 38, + "name": "AmdDefine", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 39, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Define a module" + }, + "parameters": [ + { + "id": 40, + "name": "moduleId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the MID to use for the module" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 41, + "name": "dependencies", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "an array of MIDs this module depends upon" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + }, + { + "id": 42, + "name": "factory", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the factory function that will return the module\n" + }, + "type": { + "type": "reference", + "name": "AmdFactory", + "id": 54 + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + }, + { + "id": 43, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Define a module" + }, + "parameters": [ + { + "id": 44, + "name": "dependencies", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "an array of MIDs this module depends upon" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + }, + { + "id": 45, + "name": "factory", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the factory function that will return the module\n" + }, + "type": { + "type": "reference", + "name": "AmdFactory", + "id": 54 + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + }, + { + "id": 46, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Define a module" + }, + "parameters": [ + { + "id": 47, + "name": "factory", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the factory function that will return the module\n" + }, + "type": { + "type": "reference", + "name": "AmdFactory", + "id": 54 + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + }, + { + "id": 48, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Define a module" + }, + "parameters": [ + { + "id": 49, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the value for the module\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "children": [ + { + "id": 50, + "name": "amd", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Meta data about this particular AMD loader" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 134, + "character": 4 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 51, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 52, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 53, + "name": "prop", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "number" + }, + { + "type": "intrinsic", + "name": "boolean" + } + ] + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 134, + "character": 5 + } + ] + } + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 50 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 99, + "character": 26 + } + ] + }, + { + "id": 54, + "name": "AmdFactory", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 55, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The module factory" + }, + "parameters": [ + { + "id": 56, + "name": "modules", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "comment": { + "text": "The arguments that represent the resolved versions of the module dependencies\n" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 137, + "character": 27 + } + ] + }, + { + "id": 57, + "name": "AmdHas", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 58, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Determine if a feature is present" + }, + "parameters": [ + { + "id": 59, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "the feature name to check\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "children": [ + { + "id": 60, + "name": "add", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 61, + "name": "add", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Register a feature test" + }, + "parameters": [ + { + "id": 62, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The name of the feature to register" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 63, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The test for the feature" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 64, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 65, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 66, + "name": "global", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Window" + } + }, + { + "id": 67, + "name": "document", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "HTMLDocument" + } + }, + { + "id": 68, + "name": "element", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "HTMLDivElement" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 164, + "character": 8 + } + ] + } + } + }, + { + "id": 69, + "name": "now", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "If `true` the test will be executed immediatly, if not, it will be lazily executed" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 70, + "name": "force", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "If `true` the test value will be overwritten if already registered\n" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + }, + { + "id": 71, + "name": "add", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 72, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 73, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 74, + "name": "now", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 75, + "name": "force", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 162, + "character": 4 + }, + { + "fileName": "interfaces.ts", + "line": 168, + "character": 4 + } + ] + } + ], + "groups": [ + { + "title": "Methods", + "kind": 2048, + "children": [ + 60 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 146, + "character": 23 + } + ] + }, + { + "id": 76, + "name": "AmdModuleMap", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "indexSignature": [ + { + "id": 79, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 80, + "name": "mid", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 171, + "character": 29 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "AmdModuleMapItem", + "id": 81 + } + ] + }, + { + "id": 81, + "name": "AmdModuleMapItem", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "indexSignature": [ + { + "id": 82, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 83, + "name": "mid", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 175, + "character": 33 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "AmdModuleMap", + "id": 76 + }, + { + "type": "reference", + "name": "AmdModuleMapReplacement", + "id": 84 + } + ] + }, + { + "id": 84, + "name": "AmdModuleMapReplacement", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "indexSignature": [ + { + "id": 87, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 88, + "name": "mid", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 179, + "character": 40 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "AmdModuleMapItem", + "id": 81 + } + ] + }, + { + "id": 95, + "name": "AmdPackage", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 96, + "name": "location", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The path to the root of the package" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 192, + "character": 9 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 97, + "name": "main", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The main module of the package (defaults to `main.js`)" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 197, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 98, + "name": "name", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The package name" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 202, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 96, + 97, + 98 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 188, + "character": 27 + } + ] + }, + { + "id": 99, + "name": "AmdRequire", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 100, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Resolve a list of module dependencies and pass them to the callback" + }, + "parameters": [ + { + "id": 101, + "name": "dependencies", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The array of MIDs to resolve" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + }, + { + "id": 102, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The function to invoke with the resolved dependencies\n" + }, + "type": { + "type": "reference", + "name": "AmdRequireCallback", + "id": 113 + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + }, + { + "id": 103, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Resolve and return a single module (compatability with CommonJS `require`)" + }, + "typeParameter": [ + { + "id": 104, + "name": "ModuleType", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 105, + "name": "moduleId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The module ID to resolve and return\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "typeParameter", + "name": "ModuleType" + } + } + ], + "children": [ + { + "id": 106, + "name": "nodeRequire", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "If running in the node environment, a reference to the original NodeJS `require`" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 224, + "character": 12 + } + ], + "type": { + "type": "reference", + "name": "NodeRequire", + "id": 89 + } + }, + { + "id": 107, + "name": "toAbsMid", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 108, + "name": "toAbsMid", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Take a relative MID and return an absolute MID" + }, + "parameters": [ + { + "id": 109, + "name": "moduleId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The relative module ID to resolve\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 231, + "character": 9 + } + ] + }, + { + "id": 110, + "name": "toUrl", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 111, + "name": "toUrl", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Take a path and resolve the full URL for the path" + }, + "parameters": [ + { + "id": 112, + "name": "path", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The path to resolve and return as a URL\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 238, + "character": 6 + } + ] + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 106 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 107, + 110 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 205, + "character": 27 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "AmdRootRequire", + "id": 116 + } + ] + }, + { + "id": 113, + "name": "AmdRequireCallback", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 114, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The `require` callback" + }, + "parameters": [ + { + "id": 115, + "name": "modules", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "comment": { + "text": "The arguments that represent the resolved versions of dependencies\n" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 241, + "character": 35 + } + ] + }, + { + "id": 116, + "name": "AmdRootRequire", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 135, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Resolve a list of module dependencies and pass them to the callback" + }, + "parameters": [ + { + "id": 136, + "name": "dependencies", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The array of MIDs to resolve" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + }, + { + "id": 137, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The function to invoke with the resolved dependencies\n" + }, + "type": { + "type": "reference", + "name": "AmdRequireCallback", + "id": 113 + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + }, + { + "id": 138, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Resolve and return a single module (compatability with CommonJS `require`)" + }, + "typeParameter": [ + { + "id": 139, + "name": "ModuleType", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 140, + "name": "moduleId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The module ID to resolve and return\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "typeParameter", + "name": "ModuleType" + } + } + ], + "children": [ + { + "id": 117, + "name": "has", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The minimalist `has` API integrated with the `@dojo/loader`" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 254, + "character": 4 + } + ], + "type": { + "type": "reference", + "name": "AmdHas", + "id": 57 + } + }, + { + "id": 141, + "name": "nodeRequire", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "If running in the node environment, a reference to the original NodeJS `require`" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 224, + "character": 12 + } + ], + "type": { + "type": "reference", + "name": "NodeRequire", + "id": 89 + }, + "inheritedFrom": { + "type": "reference", + "name": "AmdRequire.nodeRequire", + "id": 106 + } + }, + { + "id": 126, + "name": "config", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 127, + "name": "config", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Configure the loader" + }, + "parameters": [ + { + "id": 128, + "name": "config", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The configuration to apply to the loader\n" + }, + "type": { + "type": "reference", + "name": "AmdConfig", + "id": 26 + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 269, + "character": 7 + } + ] + }, + { + "id": 129, + "name": "inspect", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "signatures": [ + { + "id": 130, + "name": "inspect", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return internal values of loader for debug purposes" + }, + "parameters": [ + { + "id": 131, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The name of the internal label\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 276, + "character": 8 + } + ] + }, + { + "id": 118, + "name": "on", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 119, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Register an event listener" + }, + "parameters": [ + { + "id": 120, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The event type to listen for" + }, + "type": { + "type": "reference", + "name": "AmdRequireOnSignalType", + "id": 149 + } + }, + { + "id": 121, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The listener to call when the event is emitted\n" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 122, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 123, + "name": "remove", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 262, + "character": 58 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 124, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 125, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 262, + "character": 59 + } + ] + } + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 123 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 262, + "character": 49 + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 262, + "character": 3 + } + ] + }, + { + "id": 142, + "name": "toAbsMid", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 143, + "name": "toAbsMid", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Take a relative MID and return an absolute MID" + }, + "parameters": [ + { + "id": 144, + "name": "moduleId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The relative module ID to resolve\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "inheritedFrom": { + "type": "reference", + "name": "AmdRequire.toAbsMid", + "id": 107 + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 231, + "character": 9 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "AmdRequire.toAbsMid", + "id": 107 + } + }, + { + "id": 145, + "name": "toUrl", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 146, + "name": "toUrl", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Take a path and resolve the full URL for the path" + }, + "parameters": [ + { + "id": 147, + "name": "path", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The path to resolve and return as a URL\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "inheritedFrom": { + "type": "reference", + "name": "AmdRequire.toUrl", + "id": 110 + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 238, + "character": 6 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "AmdRequire.toUrl", + "id": 110 + } + }, + { + "id": 132, + "name": "undef", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 133, + "name": "undef", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Undefine a module, based on absolute MID that should be removed from the loader cache" + }, + "parameters": [ + { + "id": 134, + "name": "moduleId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 281, + "character": 6 + } + ] + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 117, + 141 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 126, + 129, + 118, + 142, + 145, + 132 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 250, + "character": 31 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "AmdRequire", + "id": 99 + } + ] + }, + { + "id": 9, + "name": "EventCancelableObject", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "An interface for an object which provides a cancelable event API. By calling the\n`.preventDefault()` method on the object, the event should be cancelled and not\nproceed any further" + }, + "typeParameter": [ + { + "id": 10, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 11, + "name": "cancelable", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Can the event be canceled?" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 29, + "character": 20 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 12, + "name": "defaultPrevented", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Was the event canceled?" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 34, + "character": 26 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 15, + "name": "type", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The type of the event" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 10, + "character": 14 + } + ], + "type": { + "type": "typeParameter", + "name": "T" + }, + "inheritedFrom": { + "type": "reference", + "name": "EventObject.type", + "id": 4 + } + }, + { + "id": 13, + "name": "preventDefault", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 14, + "name": "preventDefault", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Cancel the event" + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 39, + "character": 15 + } + ] + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 11, + 12, + 15 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 13 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 25, + "character": 38 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + }, + { + "id": 5, + "name": "EventErrorObject", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 6, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 7, + "name": "error", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The error that is the subject of this event" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 17, + "character": 15 + } + ], + "type": { + "type": "reference", + "name": "Error" + } + }, + { + "id": 8, + "name": "type", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The type of the event" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 10, + "character": 14 + } + ], + "type": { + "type": "typeParameter", + "name": "T" + }, + "inheritedFrom": { + "type": "reference", + "name": "EventObject.type", + "id": 4 + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 7, + 8 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 13, + "character": 33 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + }, + { + "id": 2, + "name": "EventObject", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The base event object, which provides a `type` property" + }, + "typeParameter": [ + { + "id": 3, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 4, + "name": "type", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The type of the event" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 10, + "character": 14 + } + ], + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 4 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 6, + "character": 28 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "EventErrorObject", + "id": 5 + }, + { + "type": "reference", + "name": "EventCancelableObject", + "id": 9 + }, + { + "type": "reference", + "name": "DOMEventObject", + "id": 1254 + } + ] + }, + { + "id": 16, + "name": "Handle", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Used through the toolkit as a consistent API to manage how callers can \"cleanup\"\nwhen doing a function." + }, + "children": [ + { + "id": 17, + "name": "destroy", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 18, + "name": "destroy", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Perform the destruction/cleanup logic associated with this handle" + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 50, + "character": 8 + } + ] + } + ], + "groups": [ + { + "title": "Methods", + "kind": 2048, + "children": [ + 17 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 46, + "character": 23 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "PausableHandle", + "id": 1259 + } + ] + }, + { + "id": 19, + "name": "Hash", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A general interface that can be used to renference a general index map of values of a particular type" + }, + "typeParameter": [ + { + "id": 20, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "indexSignature": [ + { + "id": 21, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A general interface that can be used to renference a general index map of values of a particular type" + }, + "parameters": [ + { + "id": 22, + "name": "id", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 56, + "character": 21 + } + ] + }, + { + "id": 89, + "name": "NodeRequire", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 90, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 91, + "name": "moduleId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "children": [ + { + "id": 92, + "name": "resolve", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 93, + "name": "resolve", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 94, + "name": "moduleId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 185, + "character": 8 + } + ] + } + ], + "groups": [ + { + "title": "Methods", + "kind": 2048, + "children": [ + 92 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 183, + "character": 28 + } + ] + }, + { + "id": 23, + "name": "StylesMap", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "A base map of styles where each key is the name of the style attribute and the value is a string\nwhich represents the style" + }, + "indexSignature": [ + { + "id": 24, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A base map of styles where each key is the name of the style attribute and the value is a string\nwhich represents the style" + }, + "parameters": [ + { + "id": 25, + "name": "style", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 64, + "character": 26 + } + ] + }, + { + "id": 149, + "name": "AmdRequireOnSignalType", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "The signal type for the `require.on` API" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 287, + "character": 34 + } + ], + "type": { + "type": "stringLiteral", + "value": "error" + } + }, + { + "id": 148, + "name": "EventType", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 1, + "character": 21 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "symbol" + } + ] + } + } + ], + "groups": [ + { + "title": "Interfaces", + "kind": 256, + "children": [ + 26, + 38, + 54, + 57, + 76, + 81, + 84, + 95, + 99, + 113, + 116, + 9, + 5, + 2, + 16, + 19, + 89, + 23 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 149, + 148 + ] + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 150, + "name": "\"lang\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/lang.ts", + "children": [ + { + "id": 151, + "name": "MixinArgs", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 152, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 153, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "children": [ + { + "id": 158, + "name": "copied", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "lang.ts", + "line": 45, + "character": 7 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 154, + "name": "deep", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "lang.ts", + "line": 41, + "character": 5 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 155, + "name": "inherited", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "lang.ts", + "line": 42, + "character": 10 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 156, + "name": "sources", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "lang.ts", + "line": 43, + "character": 8 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "null" + }, + { + "type": "unknown", + "name": "U" + } + ] + } + } + }, + { + "id": 157, + "name": "target", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "lang.ts", + "line": 44, + "character": 7 + } + ], + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 158, + 154, + 155, + 156, + 157 + ] + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 40, + "character": 19 + } + ] + }, + { + "id": 160, + "name": "hasOwnProperty", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "lang.ts", + "line": 7, + "character": 20 + } + ], + "type": { + "type": "reference", + "name": "hasOwnProperty" + }, + "defaultValue": " Object.prototype.hasOwnProperty" + }, + { + "id": 159, + "name": "slice", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "lang.ts", + "line": 6, + "character": 11 + } + ], + "type": { + "type": "reference", + "name": "slice" + }, + "defaultValue": " Array.prototype.slice" + }, + { + "id": 169, + "name": "_mixin", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 170, + "name": "_mixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 171, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 172, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 173, + "name": "kwArgs", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "MixinArgs", + "id": 151, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 48, + "character": 15 + } + ] + }, + { + "id": 164, + "name": "copyArray", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 165, + "name": "copyArray", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 166, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 167, + "name": "array", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + }, + { + "id": 168, + "name": "inherited", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "type": { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 23, + "character": 18 + } + ] + }, + { + "id": 174, + "name": "create", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 175, + "name": "create", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Creates a new object from the given prototype, and copies all enumerable own properties of one or more\nsource objects to the newly created target object.", + "returns": "The new object\n" + }, + "typeParameter": [ + { + "id": 176, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 177, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 178, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 179, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 180, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 181, + "name": "Y", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 182, + "name": "Z", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 183, + "name": "prototype", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The prototype to create a new object from" + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 184, + "name": "mixin1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 185, + "name": "mixin2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 186, + "name": "mixin3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 187, + "name": "mixin4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 188, + "name": "mixin5", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 189, + "name": "mixin6", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Z", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Z", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 190, + "name": "create", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 191, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 192, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 193, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 194, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 195, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 196, + "name": "Y", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 197, + "name": "prototype", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 198, + "name": "mixin1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 199, + "name": "mixin2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 200, + "name": "mixin3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 201, + "name": "mixin4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 202, + "name": "mixin5", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 203, + "name": "create", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 204, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 205, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 206, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 207, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 208, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 209, + "name": "prototype", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 210, + "name": "mixin1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 211, + "name": "mixin2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 212, + "name": "mixin3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 213, + "name": "mixin4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 214, + "name": "create", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 215, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 216, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 217, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 218, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 219, + "name": "prototype", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 220, + "name": "mixin1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 221, + "name": "mixin2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 222, + "name": "mixin3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 223, + "name": "create", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 224, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 225, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 226, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 227, + "name": "prototype", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 228, + "name": "mixin1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 229, + "name": "mixin2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 230, + "name": "create", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 231, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 232, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 233, + "name": "prototype", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 234, + "name": "mixin", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 235, + "name": "create", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 236, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 237, + "name": "prototype", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 100, + "character": 22 + }, + { + "fileName": "lang.ts", + "line": 109, + "character": 22 + }, + { + "fileName": "lang.ts", + "line": 117, + "character": 22 + }, + { + "fileName": "lang.ts", + "line": 124, + "character": 22 + }, + { + "fileName": "lang.ts", + "line": 130, + "character": 22 + }, + { + "fileName": "lang.ts", + "line": 131, + "character": 22 + }, + { + "fileName": "lang.ts", + "line": 132, + "character": 22 + }, + { + "fileName": "lang.ts", + "line": 133, + "character": 22 + } + ] + }, + { + "id": 452, + "name": "createCompositeHandle", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 453, + "name": "createCompositeHandle", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns a single handle that can be used to destroy multiple handles simultaneously.", + "returns": "The handle object\n" + }, + "parameters": [ + { + "id": 454, + "name": "handles", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "comment": { + "text": "An array of handles with `destroy` methods" + }, + "type": { + "type": "array", + "elementType": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 381, + "character": 37 + } + ] + }, + { + "id": 447, + "name": "createHandle", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 448, + "name": "createHandle", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns an object with a destroy method that, when called, calls the passed-in destructor.\nThis is intended to provide a unified interface for creating \"remove\" / \"destroy\" handlers for\nevent listeners, timers, etc.", + "returns": "The handle object\n" + }, + "parameters": [ + { + "id": 449, + "name": "destructor", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "A function that will be called when the handle's `destroy` method is invoked" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 450, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 451, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 366, + "character": 40 + } + ] + } + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 366, + "character": 28 + } + ] + }, + { + "id": 238, + "name": "deepAssign", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 239, + "name": "deepAssign", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Copies the values of all enumerable own properties of one or more source objects to the target object,\nrecursively copying all nested objects and arrays as well.", + "returns": "The modified target object\n" + }, + "typeParameter": [ + { + "id": 240, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 241, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 242, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 243, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 244, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 245, + "name": "Y", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 246, + "name": "Z", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 247, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The target object to receive values from source objects" + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 248, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 249, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 250, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 251, + "name": "source4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 252, + "name": "source5", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 253, + "name": "source6", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Z", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Z", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 254, + "name": "deepAssign", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 255, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 256, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 257, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 258, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 259, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 260, + "name": "Y", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 261, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 262, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 263, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 264, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 265, + "name": "source4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 266, + "name": "source5", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 267, + "name": "deepAssign", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 268, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 269, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 270, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 271, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 272, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 273, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 274, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 275, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 276, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 277, + "name": "source4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 278, + "name": "deepAssign", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 279, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 280, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 281, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 282, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 283, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 284, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 285, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 286, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 287, + "name": "deepAssign", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 288, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 289, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 290, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 291, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 292, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 293, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 294, + "name": "deepAssign", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 295, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 296, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 297, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 298, + "name": "source", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 152, + "character": 26 + }, + { + "fileName": "lang.ts", + "line": 161, + "character": 26 + }, + { + "fileName": "lang.ts", + "line": 169, + "character": 26 + }, + { + "fileName": "lang.ts", + "line": 176, + "character": 26 + }, + { + "fileName": "lang.ts", + "line": 182, + "character": 26 + }, + { + "fileName": "lang.ts", + "line": 183, + "character": 26 + }, + { + "fileName": "lang.ts", + "line": 184, + "character": 26 + } + ] + }, + { + "id": 299, + "name": "deepMixin", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 300, + "name": "deepMixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Copies the values of all enumerable (own or inherited) properties of one or more source objects to the\ntarget object, recursively copying all nested objects and arrays as well.", + "returns": "The modified target object\n" + }, + "typeParameter": [ + { + "id": 301, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 302, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 303, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 304, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 305, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 306, + "name": "Y", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 307, + "name": "Z", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 308, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The target object to receive values from source objects" + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 309, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 310, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 311, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 312, + "name": "source4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 313, + "name": "source5", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 314, + "name": "source6", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Z", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Z", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 315, + "name": "deepMixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 316, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 317, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 318, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 319, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 320, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 321, + "name": "Y", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 322, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 323, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 324, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 325, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 326, + "name": "source4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 327, + "name": "source5", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 328, + "name": "deepMixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 329, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 330, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 331, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 332, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 333, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 334, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 335, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 336, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 337, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 338, + "name": "source4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 339, + "name": "deepMixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 340, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 341, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 342, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 343, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 344, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 345, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 346, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 347, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 348, + "name": "deepMixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 349, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 350, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 351, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 352, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 353, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 354, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 355, + "name": "deepMixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 356, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 357, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 358, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 359, + "name": "source", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 201, + "character": 25 + }, + { + "fileName": "lang.ts", + "line": 210, + "character": 25 + }, + { + "fileName": "lang.ts", + "line": 218, + "character": 25 + }, + { + "fileName": "lang.ts", + "line": 225, + "character": 25 + }, + { + "fileName": "lang.ts", + "line": 231, + "character": 25 + }, + { + "fileName": "lang.ts", + "line": 232, + "character": 25 + }, + { + "fileName": "lang.ts", + "line": 233, + "character": 25 + } + ] + }, + { + "id": 360, + "name": "duplicate", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 361, + "name": "duplicate", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Creates a new object using the provided source's prototype as the prototype for the new object, and then\ndeep copies the provided source's values into the new target.", + "returns": "The new object\n" + }, + "typeParameter": [ + { + "id": 362, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 363, + "name": "source", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The object to duplicate" + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 249, + "character": 25 + } + ] + }, + { + "id": 364, + "name": "isIdentical", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 365, + "name": "isIdentical", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Determines whether two values are the same value.", + "returns": "true if the values are the same; false otherwise\n" + }, + "parameters": [ + { + "id": 366, + "name": "a", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "First value to compare" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 367, + "name": "b", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Second value to compare" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 262, + "character": 27 + } + ] + }, + { + "id": 368, + "name": "lateBind", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 369, + "name": "lateBind", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns a function that binds a method to the specified object at runtime. This is similar to\n`Function.prototype.bind`, but instead of a function it takes the name of a method on an object.\nAs a result, the function returned by `lateBind` will always call the function currently assigned to\nthe specified property on the object as of the moment the function it returns is called.", + "returns": "The bound function\n" + }, + "parameters": [ + { + "id": 370, + "name": "instance", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The context object" + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 371, + "name": "method", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The name of the method on the context object to bind to itself" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 372, + "name": "suppliedArgs", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "comment": { + "text": "An optional array of values to prepend to the `instance[method]` arguments list" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 373, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 374, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 375, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 281, + "character": 79 + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 281, + "character": 24 + } + ] + }, + { + "id": 376, + "name": "mixin", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 377, + "name": "mixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Copies the values of all enumerable (own or inherited) properties of one or more source objects to the\ntarget object.", + "returns": "The modified target object\n" + }, + "typeParameter": [ + { + "id": 378, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 379, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 380, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 381, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 382, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 383, + "name": "Y", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 384, + "name": "Z", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 385, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 386, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 387, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 388, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 389, + "name": "source4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 390, + "name": "source5", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 391, + "name": "source6", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Z", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Z", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 392, + "name": "mixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 393, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 394, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 395, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 396, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 397, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 398, + "name": "Y", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 399, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 400, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 401, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 402, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 403, + "name": "source4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 404, + "name": "source5", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "Y", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 405, + "name": "mixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 406, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 407, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 408, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 409, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 410, + "name": "X", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 411, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 412, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 413, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 414, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 415, + "name": "source4", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "X", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 416, + "name": "mixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 417, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 418, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 419, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 420, + "name": "W", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 421, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 422, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 423, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 424, + "name": "source3", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "W", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 425, + "name": "mixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 426, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 427, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 428, + "name": "V", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 429, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 430, + "name": "source1", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 431, + "name": "source2", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "V", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + }, + { + "id": 432, + "name": "mixin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 433, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + }, + { + "id": 434, + "name": "U", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "__type" + } + } + ], + "parameters": [ + { + "id": 435, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + } + }, + { + "id": 436, + "name": "source", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + } + ], + "type": { + "type": "intersection", + "types": [ + { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reference", + "name": "__type" + } + }, + { + "type": "typeParameter", + "name": "U", + "constraint": { + "type": "reference", + "name": "__type" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 301, + "character": 21 + }, + { + "fileName": "lang.ts", + "line": 310, + "character": 21 + }, + { + "fileName": "lang.ts", + "line": 318, + "character": 21 + }, + { + "fileName": "lang.ts", + "line": 325, + "character": 21 + }, + { + "fileName": "lang.ts", + "line": 331, + "character": 21 + }, + { + "fileName": "lang.ts", + "line": 332, + "character": 21 + }, + { + "fileName": "lang.ts", + "line": 333, + "character": 21 + } + ] + }, + { + "id": 437, + "name": "partial", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 438, + "name": "partial", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns a function which invokes the given function with the given arguments prepended to its argument list.\nLike `Function.prototype.bind`, but does not alter execution context.", + "returns": "The bound function\n" + }, + "parameters": [ + { + "id": 439, + "name": "targetFunction", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The function that needs to be bound" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 440, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 441, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 442, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 350, + "character": 39 + } + ] + } + } + }, + { + "id": 443, + "name": "suppliedArgs", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "comment": { + "text": "An optional array of arguments to prepend to the `targetFunction` arguments list" + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 444, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 445, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 446, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 350, + "character": 89 + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 350, + "character": 23 + } + ] + }, + { + "id": 161, + "name": "shouldDeepCopyObject", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 162, + "name": "shouldDeepCopyObject", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Type guard that ensures that the value can be coerced to Object\nto weed out host objects that do not derive from Object.\nThis function is used to check if we want to deep copy an object or not.\nNote: In ES6 it is possible to modify an object's Symbol.toStringTag property, which will\nchange the value returned by `toString`. This is a rare edge case that is difficult to handle,\nso it is not handled here.", + "returns": "If the value is coercible into an Object\n" + }, + "parameters": [ + { + "id": 163, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The value to check" + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 19, + "character": 29 + } + ] + } + ], + "groups": [ + { + "title": "Interfaces", + "kind": 256, + "children": [ + 151 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 160, + 159 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 169, + 164, + 174, + 452, + 447, + 238, + 299, + 360, + 364, + 368, + 376, + 437, + 161 + ] + } + ], + "sources": [ + { + "fileName": "lang.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1201, + "name": "\"load\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/load.ts", + "children": [ + { + "id": 1202, + "name": "Load", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1203, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1204, + "name": "require", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Require", + "id": 1208 + } + }, + { + "id": 1205, + "name": "moduleIds", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + }, + { + "id": 1206, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1207, + "name": "moduleIds", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "load.ts", + "line": 7, + "character": 21 + } + ] + }, + { + "id": 1208, + "name": "Require", + "kind": 4194304, + "kindString": "Type alias", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "load.ts", + "line": 5, + "character": 19 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "AmdRequire", + "id": 99 + }, + { + "type": "reference", + "name": "NodeRequire", + "id": 89 + } + ] + } + }, + { + "id": 1210, + "name": "define", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "load.ts", + "line": 14, + "character": 20 + } + ], + "type": { + "type": "reference", + "name": "AmdDefine", + "id": 38 + } + }, + { + "id": 1217, + "name": "load", + "kind": 32, + "kindString": "Variable", + "flags": { + "isExported": true, + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "load.ts", + "line": 24, + "character": 10 + } + ], + "type": { + "type": "reference", + "name": "Load", + "id": 1202 + }, + "defaultValue": " (function(): Load {\n\tconst resolver = isAmdRequire(require)\n\t\t? require.toUrl\n\t\t: isNodeRequire(require) ? require.resolve : (resourceId: string) => resourceId;\n\n\tfunction pluginLoad(moduleIds: string[], load: Load, loader: (modulesIds: string[]) => Promise) {\n\t\tconst pluginResourceIds: string[] = [];\n\t\tmoduleIds = moduleIds.map((id: string, i: number) => {\n\t\t\tconst parts = id.split('!');\n\t\t\tpluginResourceIds[i] = parts[1];\n\t\t\treturn parts[0];\n\t\t});\n\n\t\treturn loader(moduleIds).then((modules: any[]) => {\n\t\t\tpluginResourceIds.forEach((resourceId: string, i: number) => {\n\t\t\t\tif (typeof resourceId === 'string') {\n\t\t\t\t\tconst module = modules[i];\n\t\t\t\t\tconst defaultExport = module['default'] || module;\n\n\t\t\t\t\tif (isPlugin(defaultExport)) {\n\t\t\t\t\t\tresourceId =\n\t\t\t\t\t\t\ttypeof defaultExport.normalize === 'function'\n\t\t\t\t\t\t\t\t? defaultExport.normalize(resourceId, resolver)\n\t\t\t\t\t\t\t\t: resolver(resourceId);\n\n\t\t\t\t\t\tmodules[i] = defaultExport.load(resourceId, load);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn Promise.all(modules);\n\t\t});\n\t}\n\n\tif (typeof module === 'object' && typeof module.exports === 'object') {\n\t\treturn function load(contextualRequire: any, ...moduleIds: string[]): Promise {\n\t\t\tif (typeof contextualRequire === 'string') {\n\t\t\t\tmoduleIds.unshift(contextualRequire);\n\t\t\t\tcontextualRequire = require;\n\t\t\t}\n\n\t\t\treturn pluginLoad(moduleIds, load, (moduleIds: string[]) => {\n\t\t\t\ttry {\n\t\t\t\t\treturn Promise.resolve(\n\t\t\t\t\t\tmoduleIds.map(function(moduleId): any {\n\t\t\t\t\t\t\treturn contextualRequire(moduleId.split('!')[0]);\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn Promise.reject(error);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t} else if (typeof define === 'function' && define.amd) {\n\t\treturn function load(contextualRequire: any, ...moduleIds: string[]): Promise {\n\t\t\tif (typeof contextualRequire === 'string') {\n\t\t\t\tmoduleIds.unshift(contextualRequire);\n\t\t\t\tcontextualRequire = require;\n\t\t\t}\n\n\t\t\treturn pluginLoad(moduleIds, load, (moduleIds: string[]) => {\n\t\t\t\treturn new Promise(function(resolve, reject) {\n\t\t\t\t\tlet errorHandle: { remove: () => void };\n\n\t\t\t\t\tif (typeof contextualRequire.on === 'function') {\n\t\t\t\t\t\terrorHandle = contextualRequire.on('error', (error: Error) => {\n\t\t\t\t\t\t\terrorHandle.remove();\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tcontextualRequire(moduleIds, function(...modules: any[]) {\n\t\t\t\t\t\terrorHandle && errorHandle.remove();\n\t\t\t\t\t\tresolve(modules);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\t\t};\n\t} else {\n\t\treturn function() {\n\t\t\treturn Promise.reject(new Error('Unknown loader'));\n\t\t};\n\t}\n})()" + }, + { + "id": 1209, + "name": "require", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "load.ts", + "line": 12, + "character": 21 + } + ], + "type": { + "type": "reference", + "name": "Require", + "id": 1208 + } + }, + { + "id": 1211, + "name": "isAmdRequire", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1212, + "name": "isAmdRequire", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1213, + "name": "object", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "load.ts", + "line": 16, + "character": 28 + } + ] + }, + { + "id": 1214, + "name": "isNodeRequire", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1215, + "name": "isNodeRequire", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1216, + "name": "object", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "load.ts", + "line": 20, + "character": 29 + } + ] + } + ], + "groups": [ + { + "title": "Interfaces", + "kind": 256, + "children": [ + 1202 + ] + }, + { + "title": "Type aliases", + "kind": 4194304, + "children": [ + 1208 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 1210, + 1217, + 1209 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1211, + 1214 + ] + } + ], + "sources": [ + { + "fileName": "load.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1178, + "name": "\"load/util\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/load/util.ts", + "children": [ + { + "id": 1179, + "name": "LoadPlugin", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 1180, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1181, + "name": "normalize", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "An optional method that normmalizes a resource id.", + "tags": [ + { + "tag": "param", + "text": "\nThe raw resource id.\n", + "param": "resourceId" + }, + { + "tag": "param", + "text": "\nA method that can resolve an id to an absolute path. Depending on the environment, this will\nusually be either `require.toUrl` or `require.resolve`.\n", + "param": "resolver" + } + ] + }, + "sources": [ + { + "fileName": "load/util.ts", + "line": 15, + "character": 10 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1182, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1183, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1184, + "name": "resourceId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1185, + "name": "resolver", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1186, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1187, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1188, + "name": "resourceId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "load/util.ts", + "line": 15, + "character": 43 + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + } + ] + } + }, + { + "id": 1189, + "name": "load", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1190, + "name": "load", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A method that loads the specified resource.", + "returns": "\nA promise that resolves to the loaded resource.\n" + }, + "parameters": [ + { + "id": 1191, + "name": "resourceId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "\nThe id of the resource to load.\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1192, + "name": "load", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "\nThe `load` method that was used to load and execute the plugin.\n" + }, + "type": { + "type": "reference", + "name": "Load", + "id": 1202 + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "load/util.ts", + "line": 29, + "character": 5 + } + ] + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1181 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1189 + ] + } + ], + "sources": [ + { + "fileName": "load/util.ts", + "line": 4, + "character": 27 + } + ] + }, + { + "id": 1193, + "name": "isPlugin", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1194, + "name": "isPlugin", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1195, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "load/util.ts", + "line": 32, + "character": 24 + } + ] + }, + { + "id": 1196, + "name": "useDefault", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1197, + "name": "useDefault", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1198, + "name": "modules", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 1199, + "name": "useDefault", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1200, + "name": "module", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "load/util.ts", + "line": 36, + "character": 26 + }, + { + "fileName": "load/util.ts", + "line": 37, + "character": 26 + }, + { + "fileName": "load/util.ts", + "line": 38, + "character": 26 + } + ] + } + ], + "groups": [ + { + "title": "Interfaces", + "kind": 256, + "children": [ + 1179 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1193, + 1196 + ] + } + ], + "sources": [ + { + "fileName": "load/util.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2396, + "name": "\"load/webpack\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/load/webpack.ts", + "children": [ + { + "id": 2403, + "name": "BundleLoaderCallback", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2404, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 2405, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2406, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 8, + "character": 30 + } + ] + }, + { + "id": 2397, + "name": "ModuleIdMap", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 2398, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2399, + "name": "path", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 2400, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 2401, + "name": "id", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 5, + "character": 21 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 2402, + "name": "lazy", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 5, + "character": 35 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 2401, + 2402 + ] + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 5, + "character": 16 + } + ] + } + } + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 4, + "character": 21 + } + ] + }, + { + "id": 2407, + "name": "WebpackRequire", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 2408, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 2409, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2410, + "name": "id", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "reference", + "name": "BundleLoaderCallback", + "id": 2403, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 12, + "character": 24 + } + ] + }, + { + "id": 2411, + "name": "__modules__", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "comment": { + "shortText": "A global map (set by the build) of resolved module paths to webpack-specific module data." + }, + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 19, + "character": 25 + } + ], + "type": { + "type": "reference", + "name": "ModuleIdMap", + "id": 2397 + } + }, + { + "id": 2412, + "name": "__webpack_require__", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "comment": { + "shortText": "The webpack-specific require function, set globally by webpack." + }, + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 24, + "character": 33 + } + ], + "type": { + "type": "reference", + "name": "WebpackRequire", + "id": 2407, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + }, + { + "id": 2417, + "name": "getBasePath", + "kind": 64, + "kindString": "Function", + "flags": { + "isPrivate": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2418, + "name": "getBasePath", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "isPrivate": true, + "__visited__": true + }, + "comment": { + "returns": "\nThe parent directory of the path returned by the context function.\n" + }, + "parameters": [ + { + "id": 2419, + "name": "context", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "\nA function that returns the context module ID.\n" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2420, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2421, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 77, + "character": 29 + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 77, + "character": 20 + } + ] + }, + { + "id": 2422, + "name": "load", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2423, + "name": "load", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "A webpack-specific function that replaces `@dojo/core/load` in its builds. In order for a module to be loaded,\nit must first be included in a webpack chunk, whether that chunk is included in the main build, or lazy-loaded.\nNote that this module is not intended for direct use, but rather is intended for use by a webpack plugin\nthat sets the module ID map used to translate resolved module paths to webpack module IDs.", + "returns": "\nA promise to the loaded module values.\n" + }, + "parameters": [ + { + "id": 2424, + "name": "contextRequire", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "\nAn optional function that returns the base path to use when resolving relative module IDs.\n" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2425, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2426, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 99, + "character": 44 + } + ] + } + } + }, + { + "id": 2427, + "name": "mids", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + }, + { + "id": 2428, + "name": "load", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2429, + "name": "mids", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + ] + } + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 99, + "character": 28 + }, + { + "fileName": "load/webpack.ts", + "line": 100, + "character": 28 + }, + { + "fileName": "load/webpack.ts", + "line": 101, + "character": 28 + } + ] + }, + { + "id": 2413, + "name": "resolveRelative", + "kind": 64, + "kindString": "Function", + "flags": { + "isPrivate": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2414, + "name": "resolveRelative", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "isPrivate": true, + "__visited__": true + }, + "comment": { + "returns": "\nThe resolved absolute module path.\n" + }, + "parameters": [ + { + "id": 2415, + "name": "base", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "\nThe absolute base path.\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 2416, + "name": "mid", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "\nThe relative module ID\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 39, + "character": 24 + } + ] + } + ], + "groups": [ + { + "title": "Interfaces", + "kind": 256, + "children": [ + 2403, + 2397, + 2407 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 2411, + 2412 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 2417, + 2422, + 2413 + ] + } + ], + "sources": [ + { + "fileName": "load/webpack.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2318, + "name": "\"main\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/main.ts", + "children": [ + { + "id": 2319, + "name": "async", + "kind": 2097152, + "kindString": "Object literal", + "flags": { + "isConst": true, + "__visited__": true + }, + "children": [ + { + "id": 2321, + "name": "Task", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "main.ts", + "line": 24, + "character": 5 + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430 + } + }, + { + "id": 2320, + "name": "iteration", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "main.ts", + "line": 23, + "character": 10 + } + ], + "type": { + "type": "reference", + "name": "\"src/async/iteration\"", + "id": 2125 + } + }, + { + "id": 2322, + "name": "timing", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "main.ts", + "line": 25, + "character": 7 + } + ], + "type": { + "type": "reference", + "name": "\"src/async/timing\"", + "id": 2243 + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 2321, + 2320, + 2322 + ] + } + ], + "sources": [ + { + "fileName": "main.ts", + "line": 22, + "character": 11 + } + ], + "type": { + "type": "intrinsic", + "name": "object" + } + } + ], + "groups": [ + { + "title": "Object literals", + "kind": 2097152, + "children": [ + 2319 + ] + } + ], + "sources": [ + { + "fileName": "main.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1240, + "name": "\"on\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/on.ts", + "children": [ + { + "id": 1254, + "name": "DOMEventObject", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1257, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1255, + "name": "bubbles", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "on.ts", + "line": 15, + "character": 8 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 1256, + "name": "cancelable", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "on.ts", + "line": 16, + "character": 11 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 1258, + "name": "type", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "The type of the event" + }, + "sources": [ + { + "fileName": "interfaces.ts", + "line": 10, + "character": 14 + } + ], + "type": { + "type": "typeParameter", + "name": "T" + }, + "inheritedFrom": { + "type": "reference", + "name": "EventObject.type", + "id": 4 + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1255, + 1256, + 1258 + ] + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 14, + "character": 24 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "EventObject", + "id": 2 + } + ] + }, + { + "id": 1241, + "name": "EventCallback", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 1242, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "signatures": [ + { + "id": 1243, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1244, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "O" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 5, + "character": 30 + } + ] + }, + { + "id": 1245, + "name": "EventEmitter", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 1246, + "name": "on", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1247, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1248, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1249, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241 + } + } + ], + "type": { + "type": "reference", + "name": "EventEmitter", + "id": 1245 + } + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 10, + "character": 3 + } + ] + }, + { + "id": 1250, + "name": "removeListener", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1251, + "name": "removeListener", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1252, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1253, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241 + } + } + ], + "type": { + "type": "reference", + "name": "EventEmitter", + "id": 1245 + } + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 11, + "character": 15 + } + ] + } + ], + "groups": [ + { + "title": "Methods", + "kind": 2048, + "children": [ + 1246, + 1250 + ] + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 9, + "character": 29 + } + ] + }, + { + "id": 1259, + "name": "PausableHandle", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 1264, + "name": "destroy", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1265, + "name": "destroy", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Perform the destruction/cleanup logic associated with this handle" + }, + "type": { + "type": "intrinsic", + "name": "void" + }, + "inheritedFrom": { + "type": "reference", + "name": "Handle.destroy", + "id": 17 + } + } + ], + "sources": [ + { + "fileName": "interfaces.ts", + "line": 50, + "character": 8 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Handle.destroy", + "id": 17 + } + }, + { + "id": 1260, + "name": "pause", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1261, + "name": "pause", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 177, + "character": 6 + } + ] + }, + { + "id": 1262, + "name": "resume", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1263, + "name": "resume", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 178, + "character": 7 + } + ] + } + ], + "groups": [ + { + "title": "Methods", + "kind": 2048, + "children": [ + 1264, + 1260, + 1262 + ] + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 176, + "character": 31 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "Handle", + "id": 16 + } + ] + }, + { + "id": 1266, + "name": "emit", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1267, + "name": "emit", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Provides a normalized mechanism for dispatching events for event emitters, Evented objects, or DOM nodes.", + "returns": "Boolean indicating if preventDefault was called on the event object (only relevant for DOM events;\n always false for other event emitters)\n" + }, + "typeParameter": [ + { + "id": 1268, + "name": "M", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "id": 1269, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1270, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + }, + { + "id": 1271, + "name": "K", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + } + ], + "parameters": [ + { + "id": 1272, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The target to emit the event from" + }, + "type": { + "type": "reference", + "name": "Evented", + "id": 982, + "typeArguments": [ + { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + }, + { + "id": 1273, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The event object to emit" + }, + "type": { + "type": "unknown", + "name": "M[K]" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 1274, + "name": "emit", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1275, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1276, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "parameters": [ + { + "id": 1277, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Evented", + "id": 982, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + }, + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + }, + { + "id": 1278, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 1279, + "name": "emit", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1280, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + ], + "parameters": [ + { + "id": 1281, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "EventTarget" + }, + { + "type": "reference", + "name": "EventEmitter", + "id": 1245 + } + ] + } + }, + { + "id": 1282, + "name": "event", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 26, + "character": 20 + }, + { + "fileName": "on.ts", + "line": 32, + "character": 20 + }, + { + "fileName": "on.ts", + "line": 33, + "character": 20 + }, + { + "fileName": "on.ts", + "line": 37, + "character": 20 + } + ] + }, + { + "id": 1283, + "name": "on", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1284, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Provides a normalized mechanism for listening to events from event emitters, Evented objects, or DOM nodes.", + "returns": "A handle which will remove the listener when destroy is called\n" + }, + "typeParameter": [ + { + "id": 1285, + "name": "M", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "id": 1286, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1287, + "name": "K", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + }, + { + "id": 1288, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "parameters": [ + { + "id": 1289, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Target to listen for event on" + }, + "type": { + "type": "reference", + "name": "Evented", + "id": 982, + "typeArguments": [ + { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + }, + { + "id": 1290, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Event event type(s) to listen for; may a string or an array of strings" + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + }, + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + } + } + ] + } + }, + { + "id": 1291, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Callback to handle the event when it fires" + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241, + "typeArguments": [ + { + "type": "unknown", + "name": "M[K]" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 1292, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1293, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1294, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "parameters": [ + { + "id": 1295, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Evented", + "id": 982, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + }, + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + }, + { + "id": 1296, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + } + }, + { + "id": 1297, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241, + "typeArguments": [ + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 1298, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1299, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventEmitter", + "id": 1245 + } + }, + { + "id": 1300, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + }, + { + "id": 1301, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241 + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 1302, + "name": "on", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1303, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventTarget" + } + }, + { + "id": 1304, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + }, + { + "id": 1305, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241 + } + }, + { + "id": 1306, + "name": "capture", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 83, + "character": 26 + }, + { + "fileName": "on.ts", + "line": 89, + "character": 26 + }, + { + "fileName": "on.ts", + "line": 94, + "character": 26 + }, + { + "fileName": "on.ts", + "line": 95, + "character": 26 + }, + { + "fileName": "on.ts", + "line": 101, + "character": 26 + } + ] + }, + { + "id": 1307, + "name": "once", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1308, + "name": "once", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Provides a mechanism for listening to the next occurrence of an event from event\nemitters, Evented objects, or DOM nodes.", + "returns": "A handle which will remove the listener when destroy is called\n" + }, + "typeParameter": [ + { + "id": 1309, + "name": "M", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "id": 1310, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1311, + "name": "K", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + }, + { + "id": 1312, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "parameters": [ + { + "id": 1313, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Target to listen for event on" + }, + "type": { + "type": "reference", + "name": "Evented", + "id": 982, + "typeArguments": [ + { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + }, + { + "id": 1314, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Event event type(s) to listen for; may be a string or an array of strings" + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + }, + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + } + } + ] + } + }, + { + "id": 1315, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Callback to handle the event when it fires" + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241, + "typeArguments": [ + { + "type": "unknown", + "name": "M[K]" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 1316, + "name": "once", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1317, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1318, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "parameters": [ + { + "id": 1319, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Evented", + "id": 982, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + }, + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + }, + { + "id": 1320, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + } + }, + { + "id": 1321, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241, + "typeArguments": [ + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 1322, + "name": "once", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1323, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventTarget" + } + }, + { + "id": 1324, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + }, + { + "id": 1325, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241 + } + }, + { + "id": 1326, + "name": "capture", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + }, + { + "id": 1327, + "name": "once", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1328, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventEmitter", + "id": 1245 + } + }, + { + "id": 1329, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + }, + { + "id": 1330, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241 + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 147, + "character": 20 + }, + { + "fileName": "on.ts", + "line": 153, + "character": 20 + }, + { + "fileName": "on.ts", + "line": 158, + "character": 20 + }, + { + "fileName": "on.ts", + "line": 159, + "character": 20 + }, + { + "fileName": "on.ts", + "line": 160, + "character": 20 + } + ] + }, + { + "id": 1331, + "name": "pausable", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1332, + "name": "pausable", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Provides a mechanism for creating pausable listeners for events from event emitters, Evented objects, or DOM nodes.", + "returns": "A handle with additional pause and resume methods; the listener will never fire when paused\n" + }, + "typeParameter": [ + { + "id": 1333, + "name": "M", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "id": 1334, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1335, + "name": "K", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + }, + { + "id": 1336, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "parameters": [ + { + "id": 1337, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Target to listen for event on" + }, + "type": { + "type": "reference", + "name": "Evented", + "id": 982, + "typeArguments": [ + { + "type": "typeParameter", + "name": "M", + "constraint": { + "type": "reference", + "name": "CustomEventTypes", + "id": 978 + } + }, + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + }, + { + "id": 1338, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Event event type(s) to listen for; may a string or an array of strings" + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + }, + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "K", + "constraint": { + "type": "typeOperator", + "operator": "keyof", + "target": { + "type": "typeParameter", + "name": "M" + } + } + } + } + ] + } + }, + { + "id": 1339, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Callback to handle the event when it fires" + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241, + "typeArguments": [ + { + "type": "unknown", + "name": "M[K]" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "PausableHandle", + "id": 1259 + } + }, + { + "id": 1340, + "name": "pausable", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1341, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + }, + { + "id": 1342, + "name": "O", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "parameters": [ + { + "id": 1343, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Evented", + "id": 982, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + }, + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + }, + { + "id": 1344, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "typeParameter", + "name": "T" + }, + { + "type": "array", + "elementType": { + "type": "typeParameter", + "name": "T" + } + } + ] + } + }, + { + "id": 1345, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241, + "typeArguments": [ + { + "type": "typeParameter", + "name": "O", + "constraint": { + "type": "reference", + "name": "EventObject", + "id": 2, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "PausableHandle", + "id": 1259 + } + }, + { + "id": 1346, + "name": "pausable", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1347, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventTarget" + } + }, + { + "id": 1348, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + }, + { + "id": 1349, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241 + } + }, + { + "id": 1350, + "name": "capture", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "PausableHandle", + "id": 1259 + } + }, + { + "id": 1351, + "name": "pausable", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1352, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventEmitter", + "id": 1245 + } + }, + { + "id": 1353, + "name": "type", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + }, + { + "id": 1354, + "name": "listener", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "EventCallback", + "id": 1241 + } + } + ], + "type": { + "type": "reference", + "name": "PausableHandle", + "id": 1259 + } + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 189, + "character": 24 + }, + { + "fileName": "on.ts", + "line": 195, + "character": 24 + }, + { + "fileName": "on.ts", + "line": 200, + "character": 24 + }, + { + "fileName": "on.ts", + "line": 206, + "character": 24 + }, + { + "fileName": "on.ts", + "line": 207, + "character": 24 + } + ] + } + ], + "groups": [ + { + "title": "Interfaces", + "kind": 256, + "children": [ + 1254, + 1241, + 1245, + 1259 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1266, + 1283, + 1307, + 1331 + ] + } + ], + "sources": [ + { + "fileName": "on.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1355, + "name": "\"queue\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/queue.ts", + "sources": [ + { + "fileName": "queue.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1985, + "name": "\"request\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/request.ts", + "children": [ + { + "id": 1986, + "name": "providerRegistry", + "kind": 32, + "kindString": "Variable", + "flags": { + "isExported": true, + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request.ts", + "line": 7, + "character": 29 + } + ], + "type": { + "type": "reference", + "name": "ProviderRegistry", + "id": 1600 + }, + "defaultValue": " new ProviderRegistry()" + }, + { + "id": 1987, + "name": "request", + "kind": 32, + "kindString": "Variable", + "flags": { + "isExported": true, + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request.ts", + "line": 9, + "character": 13 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 1988, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1989, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1990, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1991, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "RequestOptions" + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "Response" + } + ] + } + } + ], + "children": [ + { + "id": 1992, + "name": "delete", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1993, + "name": "delete", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1994, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1995, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "RequestOptions" + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "Response" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request.ts", + "line": 11, + "character": 7 + } + ] + }, + { + "id": 1996, + "name": "get", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1997, + "name": "get", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1998, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1999, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "RequestOptions" + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "Response" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request.ts", + "line": 12, + "character": 4 + } + ] + }, + { + "id": 2000, + "name": "head", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2001, + "name": "head", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2002, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 2003, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "RequestOptions" + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "Response" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request.ts", + "line": 13, + "character": 5 + } + ] + }, + { + "id": 2004, + "name": "options", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2005, + "name": "options", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2006, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 2007, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "RequestOptions" + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "Response" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request.ts", + "line": 14, + "character": 8 + } + ] + }, + { + "id": 2008, + "name": "post", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2009, + "name": "post", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2010, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 2011, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "RequestOptions" + } + } + ], + "type": { + "type": "reference", + "name": "UploadObservableTask", + "typeArguments": [ + { + "type": "reference", + "name": "Response" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request.ts", + "line": 15, + "character": 5 + } + ] + }, + { + "id": 2012, + "name": "put", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2013, + "name": "put", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2014, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 2015, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "RequestOptions" + } + } + ], + "type": { + "type": "reference", + "name": "UploadObservableTask", + "typeArguments": [ + { + "type": "reference", + "name": "Response" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request.ts", + "line": 16, + "character": 4 + } + ] + }, + { + "id": 2016, + "name": "setDefaultProvider", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2017, + "name": "setDefaultProvider", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2018, + "name": "provider", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Provider" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request.ts", + "line": 18, + "character": 19 + } + ] + } + ], + "groups": [ + { + "title": "Functions", + "kind": 64, + "children": [ + 1992, + 1996, + 2000, + 2004, + 2008, + 2012, + 2016 + ] + } + ], + "sources": [ + { + "fileName": "request.ts", + "line": 9, + "character": 14 + } + ] + } + }, + "defaultValue": " function request(url: string, options: RequestOptions = {}): Task {\n\ttry {\n\t\treturn providerRegistry.match(url, options)(url, options);\n\t} catch (error) {\n\t\treturn Task.reject(error);\n\t}\n}" + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 1986, + 1987 + ] + } + ], + "sources": [ + { + "fileName": "request.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1658, + "name": "\"request/Headers\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/request/Headers.ts", + "children": [ + { + "id": 1659, + "name": "Headers", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 1661, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1662, + "name": "new Headers", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1663, + "name": "headers", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "reflection", + "declaration": { + "id": 1664, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 1665, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1666, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 16, + "character": 22 + } + ] + } + }, + { + "type": "reference", + "name": "HeadersInterface" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Headers", + "id": 1659 + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 14, + "character": 45 + } + ] + }, + { + "id": 1660, + "name": "map", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 14, + "character": 14 + } + ], + "type": { + "type": "reference", + "name": "Map", + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + ] + }, + "defaultValue": " new Map()" + }, + { + "id": 1693, + "name": "__@iterator", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1694, + "name": "__@iterator", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "intrinsic", + "name": "Object" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 96, + "character": 18 + } + ] + }, + { + "id": 1667, + "name": "append", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1668, + "name": "append", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1669, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1670, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 32, + "character": 7 + } + ] + }, + { + "id": 1671, + "name": "delete", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1672, + "name": "delete", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1673, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 42, + "character": 7 + } + ] + }, + { + "id": 1674, + "name": "entries", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1675, + "name": "entries", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "tuple", + "elements": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 46, + "character": 8 + } + ] + }, + { + "id": 1676, + "name": "get", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1677, + "name": "get", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1678, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 56, + "character": 4 + } + ] + }, + { + "id": 1679, + "name": "getAll", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1680, + "name": "getAll", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1681, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "string" + } + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 66, + "character": 7 + } + ] + }, + { + "id": 1682, + "name": "has", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1683, + "name": "has", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1684, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 76, + "character": 4 + } + ] + }, + { + "id": 1685, + "name": "keys", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1686, + "name": "keys", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 80, + "character": 5 + } + ] + }, + { + "id": 1687, + "name": "set", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1688, + "name": "set", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1689, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1690, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 84, + "character": 4 + } + ] + }, + { + "id": 1691, + "name": "values", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1692, + "name": "values", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IterableIterator", + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 88, + "character": 7 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1661 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 1660 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1693, + 1667, + 1671, + 1674, + 1676, + 1679, + 1682, + 1685, + 1687, + 1691 + ] + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 13, + "character": 28 + } + ], + "implementedTypes": [ + { + "type": "reference", + "name": "Headers" + } + ] + }, + { + "id": 1695, + "name": "isHeadersLike", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1696, + "name": "isHeadersLike", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1697, + "name": "object", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 5, + "character": 22 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1659 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1695 + ] + } + ], + "sources": [ + { + "fileName": "request/Headers.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1599, + "name": "\"request/ProviderRegistry\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/request/ProviderRegistry.ts", + "children": [ + { + "id": 1600, + "name": "ProviderRegistry", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 1610, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Construct a new MatchRegistry, optionally containing a given default value." + }, + "signatures": [ + { + "id": 1611, + "name": "new ProviderRegistry", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Construct a new MatchRegistry, optionally containing a given default value." + }, + "parameters": [ + { + "id": 1612, + "name": "defaultValue", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "T", + "id": 3 + } + } + ], + "type": { + "type": "reference", + "name": "ProviderRegistry", + "id": 1600 + }, + "inheritedFrom": { + "type": "reference", + "name": "MatchRegistry.__constructor", + "id": 1226 + } + } + ], + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 17, + "character": 46 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "MatchRegistry.__constructor", + "id": 1226 + } + }, + { + "id": 1609, + "name": "_defaultValue", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isProtected": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 16, + "character": 24 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Provider" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "MatchRegistry._defaultValue", + "id": 1225 + } + }, + { + "id": 1613, + "name": "match", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1614, + "name": "match", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Return the first entry in this registry that matches the given arguments. If no entry matches and the registry\nwas created with a default value, that value will be returned. Otherwise, an exception is thrown.", + "returns": "the matching value, or a default value if one exists.\n" + }, + "parameters": [ + { + "id": 1615, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "reference", + "name": "Provider" + }, + "inheritedFrom": { + "type": "reference", + "name": "MatchRegistry.match", + "id": 1229 + } + } + ], + "sources": [ + { + "fileName": "MatchRegistry.ts", + "line": 34, + "character": 6 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "MatchRegistry.match", + "id": 1229 + } + }, + { + "id": 1604, + "name": "register", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1605, + "name": "register", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1606, + "name": "test", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "reference", + "name": "RegExp" + }, + { + "type": "reference", + "name": "ProviderTest" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + }, + { + "id": 1607, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Provider" + } + }, + { + "id": 1608, + "name": "first", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + }, + "overwrites": { + "type": "reference", + "name": "MatchRegistry.register", + "id": 1232 + } + } + ], + "sources": [ + { + "fileName": "request/ProviderRegistry.ts", + "line": 10, + "character": 9 + } + ], + "overwrites": { + "type": "reference", + "name": "MatchRegistry.register", + "id": 1232 + } + }, + { + "id": 1601, + "name": "setDefaultProvider", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1602, + "name": "setDefaultProvider", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1603, + "name": "provider", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Provider" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/ProviderRegistry.ts", + "line": 6, + "character": 19 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1610 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 1609 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1613, + 1604, + 1601 + ] + } + ], + "sources": [ + { + "fileName": "request/ProviderRegistry.ts", + "line": 5, + "character": 37 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "MatchRegistry", + "id": 1223, + "typeArguments": [ + { + "type": "reference", + "name": "Provider" + } + ] + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1600 + ] + } + ], + "sources": [ + { + "fileName": "request/ProviderRegistry.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1698, + "name": "\"request/Response\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/request/Response.ts", + "children": [ + { + "id": 1702, + "name": "Response", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "children": [ + { + "id": 1708, + "name": "bodyUsed", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 17, + "character": 27 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 1711, + "name": "data", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 21, + "character": 23 + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + }, + { + "id": 1710, + "name": "download", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 20, + "character": 27 + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 1703, + "name": "headers", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 12, + "character": 26 + } + ], + "type": { + "type": "reference", + "name": "Headers" + } + }, + { + "id": 1704, + "name": "ok", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 13, + "character": 21 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + }, + { + "id": 1709, + "name": "requestOptions", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 18, + "character": 33 + } + ], + "type": { + "type": "reference", + "name": "RequestOptions" + } + }, + { + "id": 1705, + "name": "status", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 14, + "character": 25 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 1706, + "name": "statusText", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 15, + "character": 29 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1707, + "name": "url", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 16, + "character": 22 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1715, + "name": "arrayBuffer", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1716, + "name": "arrayBuffer", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "ArrayBuffer" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 27, + "character": 21 + } + ] + }, + { + "id": 1717, + "name": "blob", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1718, + "name": "blob", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "Blob" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 28, + "character": 14 + } + ] + }, + { + "id": 1719, + "name": "formData", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1720, + "name": "formData", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "FormData" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 29, + "character": 18 + } + ] + }, + { + "id": 1712, + "name": "json", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1713, + "name": "json", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1714, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 23, + "character": 5 + } + ] + }, + { + "id": 1721, + "name": "text", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "isAbstract": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1722, + "name": "text", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 30, + "character": 14 + } + ] + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1708, + 1711, + 1710, + 1703, + 1704, + 1709, + 1705, + 1706, + 1707 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1715, + 1717, + 1719, + 1712, + 1721 + ] + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 11, + "character": 23 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "XhrResponse", + "id": 1790 + }, + { + "type": "reference", + "name": "NodeResponse", + "id": 1925 + } + ], + "implementedTypes": [ + { + "type": "reference", + "name": "Response" + } + ] + }, + { + "id": 1699, + "name": "ResponseData", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 1700, + "name": "task", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 7, + "character": 5 + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + }, + { + "id": 1701, + "name": "used", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/Response.ts", + "line": 8, + "character": 5 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1700, + 1701 + ] + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 6, + "character": 29 + } + ] + }, + { + "id": 1730, + "name": "getArrayBufferFromBlob", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1731, + "name": "getArrayBufferFromBlob", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1732, + "name": "blob", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Blob" + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "reference", + "name": "ArrayBuffer" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 53, + "character": 38 + } + ] + }, + { + "id": 1723, + "name": "getFileReaderPromise", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1724, + "name": "getFileReaderPromise", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1725, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "parameters": [ + { + "id": 1726, + "name": "reader", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "FileReader" + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 35, + "character": 36 + } + ] + }, + { + "id": 1733, + "name": "getTextFromArrayBuffer", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1734, + "name": "getTextFromArrayBuffer", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1735, + "name": "buffer", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "ArrayBuffer" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 60, + "character": 38 + } + ] + }, + { + "id": 1727, + "name": "getTextFromBlob", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1728, + "name": "getTextFromBlob", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1729, + "name": "blob", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Blob" + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 46, + "character": 31 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1702 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 1699 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1730, + 1723, + 1733, + 1727 + ] + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1736, + "name": "\"request/SubscriptionPool\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/request/SubscriptionPool.ts", + "children": [ + { + "id": 1737, + "name": "SubscriptionPool", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "typeParameter": [ + { + "id": 1738, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "children": [ + { + "id": 1739, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1740, + "name": "new SubscriptionPool", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1741, + "name": "maxLength", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "number" + }, + "defaultValue": "10" + } + ], + "type": { + "type": "reference", + "name": "SubscriptionPool", + "id": 1737 + } + } + ], + "sources": [ + { + "fileName": "request/SubscriptionPool.ts", + "line": 6, + "character": 33 + } + ] + }, + { + "id": 1742, + "name": "add", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1743, + "name": "add", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1744, + "name": "subscription", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "SubscriptionObserver", + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "(Anonymous function)" + } + } + ], + "sources": [ + { + "fileName": "request/SubscriptionPool.ts", + "line": 12, + "character": 4 + } + ] + }, + { + "id": 1748, + "name": "complete", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1749, + "name": "complete", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/SubscriptionPool.ts", + "line": 39, + "character": 9 + } + ] + }, + { + "id": 1745, + "name": "next", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1746, + "name": "next", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1747, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "typeParameter", + "name": "T" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/SubscriptionPool.ts", + "line": 24, + "character": 5 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1739 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1742, + 1748, + 1745 + ] + } + ], + "sources": [ + { + "fileName": "request/SubscriptionPool.ts", + "line": 3, + "character": 37 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1737 + ] + } + ], + "sources": [ + { + "fileName": "request/SubscriptionPool.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1750, + "name": "\"request/TimeoutError\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/request/TimeoutError.ts", + "children": [ + { + "id": 1751, + "name": "TimeoutError", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "children": [ + { + "id": 1755, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1756, + "name": "new TimeoutError", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1757, + "name": "message", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "TimeoutError", + "id": 1751 + } + } + ], + "sources": [ + { + "fileName": "request/TimeoutError.ts", + "line": 6, + "character": 2 + } + ] + }, + { + "id": 1752, + "name": "message", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/TimeoutError.ts", + "line": 2, + "character": 17 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1753, + "name": "name", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1754, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "request/TimeoutError.ts", + "line": 4, + "character": 9 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1755 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 1752 + ] + }, + { + "title": "Accessors", + "kind": 262144, + "children": [ + 1753 + ] + } + ], + "sources": [ + { + "fileName": "request/TimeoutError.ts", + "line": 1, + "character": 33 + } + ], + "implementedTypes": [ + { + "type": "reference", + "name": "Error" + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1751 + ] + } + ], + "sources": [ + { + "fileName": "request/TimeoutError.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1837, + "name": "\"request/providers/node\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/request/providers/node.ts", + "children": [ + { + "id": 1925, + "name": "NodeResponse", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Turn a node native response object into something that resembles the fetch api" + }, + "children": [ + { + "id": 1943, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1944, + "name": "new NodeResponse", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1945, + "name": "response", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IncomingMessage" + } + } + ], + "type": { + "type": "reference", + "name": "NodeResponse", + "id": 1925 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 242, + "character": 2 + } + ] + }, + { + "id": 1930, + "name": "downloadBody", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 218, + "character": 13 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "defaultValue": "true" + }, + { + "id": 1926, + "name": "headers", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 213, + "character": 17 + } + ], + "type": { + "type": "reference", + "name": "Headers", + "id": 1659 + }, + "overwrites": { + "type": "reference", + "name": "Response.headers", + "id": 1703 + } + }, + { + "id": 1927, + "name": "ok", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 214, + "character": 12 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "overwrites": { + "type": "reference", + "name": "Response.ok", + "id": 1704 + } + }, + { + "id": 1928, + "name": "status", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 215, + "character": 16 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + }, + "overwrites": { + "type": "reference", + "name": "Response.status", + "id": 1705 + } + }, + { + "id": 1929, + "name": "statusText", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 216, + "character": 20 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "overwrites": { + "type": "reference", + "name": "Response.statusText", + "id": 1706 + } + }, + { + "id": 1931, + "name": "bodyUsed", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1932, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "overwrites": { + "type": "reference", + "name": "Response.bodyUsed", + "id": 1708 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 220, + "character": 13 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.bodyUsed", + "id": 1708 + } + }, + { + "id": 1941, + "name": "data", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1942, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.data", + "id": 1711 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 240, + "character": 9 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.data", + "id": 1711 + } + }, + { + "id": 1939, + "name": "download", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1940, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "number" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.download", + "id": 1710 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 236, + "character": 13 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.download", + "id": 1710 + } + }, + { + "id": 1933, + "name": "nativeResponse", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1934, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "IncomingMessage" + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 224, + "character": 19 + } + ] + }, + { + "id": 1935, + "name": "requestOptions", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1936, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "NodeRequestOptions", + "id": 1838 + }, + "overwrites": { + "type": "reference", + "name": "Response.requestOptions", + "id": 1709 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 228, + "character": 19 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.requestOptions", + "id": 1709 + } + }, + { + "id": 1937, + "name": "url", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1938, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + }, + "overwrites": { + "type": "reference", + "name": "Response.url", + "id": 1707 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 232, + "character": 8 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.url", + "id": 1707 + } + }, + { + "id": 1946, + "name": "arrayBuffer", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1947, + "name": "arrayBuffer", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "ArrayBuffer" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.arrayBuffer", + "id": 1715 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 265, + "character": 12 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.arrayBuffer", + "id": 1715 + } + }, + { + "id": 1948, + "name": "blob", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1949, + "name": "blob", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "Blob" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.blob", + "id": 1717 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 275, + "character": 5 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.blob", + "id": 1717 + } + }, + { + "id": 1950, + "name": "formData", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1951, + "name": "formData", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "FormData" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.formData", + "id": 1719 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 280, + "character": 9 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.formData", + "id": 1719 + } + }, + { + "id": 1954, + "name": "json", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1955, + "name": "json", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1956, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Response.json", + "id": 1712 + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 23, + "character": 5 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Response.json", + "id": 1712 + } + }, + { + "id": 1952, + "name": "text", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1953, + "name": "text", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.text", + "id": 1721 + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 284, + "character": 5 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.text", + "id": 1721 + } + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1943 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 1930, + 1926, + 1927, + 1928, + 1929 + ] + }, + { + "title": "Accessors", + "kind": 262144, + "children": [ + 1931, + 1941, + 1939, + 1933, + 1935, + 1937 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1946, + 1948, + 1950, + 1954, + 1952 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 212, + "character": 25 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "Response", + "id": 1702 + } + ], + "implementedTypes": [ + { + "type": "reference", + "name": "Response" + } + ] + }, + { + "id": 1892, + "name": "HttpsOptions", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "HTTPS specific options for node" + }, + "children": [ + { + "id": 1901, + "name": "agent", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 137, + "character": 6 + } + ], + "type": { + "type": "intrinsic", + "name": "any" + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.agent", + "id": 1879 + } + }, + { + "id": 1902, + "name": "auth", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 138, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.auth", + "id": 1880 + } + }, + { + "id": 1893, + "name": "ca", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 153, + "character": 3 + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1894, + "name": "cert", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 154, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1895, + "name": "ciphers", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 155, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1903, + "name": "headers", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 139, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1904, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 1905, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1906, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.headers", + "id": 1881 + } + }, + { + "id": 1907, + "name": "host", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 140, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.host", + "id": 1885 + } + }, + { + "id": 1908, + "name": "hostname", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 141, + "character": 9 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.hostname", + "id": 1886 + } + }, + { + "id": 1896, + "name": "key", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 156, + "character": 4 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1909, + "name": "localAddress", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 142, + "character": 13 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.localAddress", + "id": 1887 + } + }, + { + "id": 1910, + "name": "method", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 143, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.method", + "id": 1888 + } + }, + { + "id": 1897, + "name": "passphrase", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 157, + "character": 11 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1911, + "name": "path", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 144, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.path", + "id": 1889 + } + }, + { + "id": 1898, + "name": "pfx", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 158, + "character": 4 + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1912, + "name": "port", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 145, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.port", + "id": 1890 + } + }, + { + "id": 1899, + "name": "rejectUnauthorized", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 159, + "character": 19 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 1900, + "name": "secureProtocol", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 160, + "character": 15 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1913, + "name": "socketPath", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 146, + "character": 11 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Options.socketPath", + "id": 1891 + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1901, + 1902, + 1893, + 1894, + 1895, + 1903, + 1907, + 1908, + 1896, + 1909, + 1910, + 1897, + 1911, + 1898, + 1912, + 1899, + 1900, + 1913 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 152, + "character": 22 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "Options", + "id": 1878 + } + ] + }, + { + "id": 1838, + "name": "NodeRequestOptions", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Request options specific to a node request. For HTTPS options, see\nhttps://nodejs.org/api/tls.html#tls_tls_connect_options_callback for more details." + }, + "children": [ + { + "id": 1854, + "name": "acceptCompression", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Whether or not to add the gzip and deflate accept headers (default true)" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 85, + "character": 18 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 1839, + "name": "agent", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "User-agent header" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 28, + "character": 6 + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1868, + "name": "body", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Body to send along with the http request" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 47, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Blob" + }, + { + "type": "reference", + "name": "BufferSource" + }, + { + "type": "reference", + "name": "FormData" + }, + { + "type": "reference", + "name": "UrlSearchParams", + "id": 1507 + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.body" + } + }, + { + "id": 1840, + "name": "bodyStream", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "If specified, the request body is read from the stream specified here, rather than from the `body` field." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 32, + "character": 11 + } + ], + "type": { + "type": "reference", + "name": "Readable" + } + }, + { + "id": 1841, + "name": "ca", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTPS optionally override the trusted CA certificates" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 36, + "character": 3 + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1866, + "name": "cacheBust", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Enable cache busting (default false). Cache busting will make a new URL by appending a parameter to the\nrequested URL" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 42, + "character": 10 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.cacheBust" + } + }, + { + "id": 1842, + "name": "cert", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTPS optional cert chains in PEM format. One cert chain should be provided per private key." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 40, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1843, + "name": "ciphers", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTPS optional cipher suite specification" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 44, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1867, + "name": "credentials", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 43, + "character": 12 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "omit" + }, + { + "type": "stringLiteral", + "value": "same-origin" + }, + { + "type": "stringLiteral", + "value": "include" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.credentials" + } + }, + { + "id": 1844, + "name": "dataEncoding", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 45, + "character": 13 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1845, + "name": "followRedirects", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Whether or not to automatically follow redirects (default true)" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 49, + "character": 16 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 1869, + "name": "headers", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Headers to send along with the http request" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 51, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Headers" + }, + { + "type": "reflection", + "declaration": { + "id": 1870, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 1871, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1872, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 51, + "character": 20 + } + ] + } + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.headers" + } + }, + { + "id": 1846, + "name": "key", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTPS optional private key in PEM format." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 53, + "character": 4 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1847, + "name": "localAddress", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Local interface to bind for network connections." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 57, + "character": 13 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1873, + "name": "method", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTP method" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 55, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.method" + } + }, + { + "id": 1848, + "name": "passphrase", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTPS optional shared passphrase used for a single private key and/or a PFX." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 61, + "character": 11 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1874, + "name": "password", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Password for HTTP authentication" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 59, + "character": 9 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.password" + } + }, + { + "id": 1849, + "name": "pfx", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTPS optional PFX or PKCS12 encoded private key and certificate chain." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 65, + "character": 4 + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1850, + "name": "proxy", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Optional proxy address. If specified, requests will be sent through this url." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 69, + "character": 6 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1877, + "name": "query", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Optional query parameter(s) for the URL. The requested url will have these query parameters appended." + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 71, + "character": 6 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "reference", + "name": "ParamList", + "id": 1536 + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.query" + } + }, + { + "id": 1861, + "name": "redirectOptions", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Options to control redirect follow logic" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 110, + "character": 16 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1862, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 1864, + "name": "count", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 116, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 1865, + "name": "keepOriginalMethod", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Whether or not to keep the original HTTP method during 301 redirects (default false)." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 120, + "character": 20 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 1863, + "name": "limit", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "The limit to the number of redirects that will be followed (default 15). This is used to prevent infinite\nredirect loops." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 115, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 1864, + 1865, + 1863 + ] + } + ] + } + } + ] + } + }, + { + "id": 1851, + "name": "rejectUnauthorized", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTPS If not false the server will reject any connection which is not authorized with the list of supplied CAs" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 73, + "character": 19 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 1852, + "name": "secureProtocol", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTPS optional SSL method to use, default is \"SSLv23_method\"" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 77, + "character": 15 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1855, + "name": "socketOptions", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "A set of options to set on the HTTP request" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 89, + "character": 14 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1856, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 1857, + "name": "keepAlive", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Enable/disable keep-alive functionality, and optionally set the initial delay before the first keepalive probe is sent on an idle socket." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 93, + "character": 11 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 1858, + "name": "noDelay", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Disables the Nagle algorithm. By default TCP connections use the Nagle algorithm, they buffer data before sending it off." + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 97, + "character": 9 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 1859, + "name": "timeout", + "kind": 32, + "kindString": "Variable", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Number of milliseconds before the HTTP request times out" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 101, + "character": 9 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 1857, + 1858, + 1859 + ] + } + ] + } + } + ] + } + }, + { + "id": 1853, + "name": "socketPath", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Unix Domain Socket (use one of host:port or socketPath)" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 81, + "character": 11 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1860, + "name": "streamEncoding", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Stream encoding on incoming HTTP response" + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 106, + "character": 15 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1875, + "name": "timeout", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Number of milliseconds before the request times out and is canceled" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 63, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.timeout" + } + }, + { + "id": 1876, + "name": "user", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "User for HTTP authentication" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 67, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.user" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1854, + 1839, + 1868, + 1840, + 1841, + 1866, + 1842, + 1843, + 1867, + 1844, + 1845, + 1869, + 1846, + 1847, + 1873, + 1848, + 1874, + 1849, + 1850, + 1877, + 1861, + 1851, + 1852, + 1855, + 1853, + 1860, + 1875, + 1876 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 24, + "character": 35 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "RequestOptions" + } + ] + }, + { + "id": 1878, + "name": "Options", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Options to be passed to node's request" + }, + "children": [ + { + "id": 1879, + "name": "agent", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 137, + "character": 6 + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1880, + "name": "auth", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 138, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1881, + "name": "headers", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 139, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "reflection", + "declaration": { + "id": 1882, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 1883, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1884, + "name": "name", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ] + } + } + ] + } + }, + { + "id": 1885, + "name": "host", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 140, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1886, + "name": "hostname", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 141, + "character": 9 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1887, + "name": "localAddress", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 142, + "character": 13 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1888, + "name": "method", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 143, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1889, + "name": "path", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 144, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + }, + { + "id": 1890, + "name": "port", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 145, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 1891, + "name": "socketPath", + "kind": 1024, + "kindString": "Property", + "flags": { + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 146, + "character": 11 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1879, + 1880, + 1881, + 1885, + 1886, + 1887, + 1888, + 1889, + 1890, + 1891 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 136, + "character": 17 + } + ], + "extendedBy": [ + { + "type": "reference", + "name": "HttpsOptions", + "id": 1892 + } + ] + }, + { + "id": 1914, + "name": "RequestData", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 1916, + "name": "buffer", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 165, + "character": 7 + } + ], + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + }, + { + "id": 1917, + "name": "data", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 166, + "character": 5 + } + ], + "type": { + "type": "reference", + "name": "Buffer" + } + }, + { + "id": 1924, + "name": "dataObservable", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 173, + "character": 15 + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + }, + { + "id": 1923, + "name": "downloadObservable", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 172, + "character": 19 + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 1920, + "name": "nativeResponse", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 169, + "character": 15 + } + ], + "type": { + "type": "reference", + "name": "IncomingMessage" + } + }, + { + "id": 1921, + "name": "requestOptions", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 170, + "character": 15 + } + ], + "type": { + "type": "reference", + "name": "NodeRequestOptions", + "id": 1838 + } + }, + { + "id": 1918, + "name": "size", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 167, + "character": 5 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + } + }, + { + "id": 1915, + "name": "task", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 164, + "character": 5 + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "IncomingMessage" + } + ] + } + }, + { + "id": 1922, + "name": "url", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 171, + "character": 4 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1919, + "name": "used", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 168, + "character": 5 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1916, + 1917, + 1924, + 1923, + 1920, + 1921, + 1918, + 1915, + 1922, + 1919 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 163, + "character": 21 + } + ] + }, + { + "id": 1958, + "name": "DEFAULT_REDIRECT_LIMIT", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "comment": { + "shortText": "If not overridden, redirects will only be processed this many times before aborting (per request).", + "tags": [ + { + "tag": "type", + "text": "{number}\n" + } + ] + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 131, + "character": 28 + } + ], + "type": { + "type": "unknown", + "name": "15" + }, + "defaultValue": "15" + }, + { + "id": 1959, + "name": "dataMap", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 176, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "WeakMap", + "typeArguments": [ + { + "type": "reference", + "name": "NodeResponse", + "id": 1925 + }, + { + "type": "reference", + "name": "RequestData", + "id": 1914 + } + ] + }, + "defaultValue": " new WeakMap()" + }, + { + "id": 1960, + "name": "discardedDuplicates", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 177, + "character": 25 + } + ], + "type": { + "type": "reference", + "name": "Set", + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "defaultValue": " new Set([\n\t'age',\n\t'authorization',\n\t'content-length',\n\t'content-type',\n\t'etag',\n\t'expires',\n\t'from',\n\t'host',\n\t'if-modified-since',\n\t'if-unmodified-since',\n\t'last-modified',\n\t'location',\n\t'max-forwards',\n\t'proxy-authorization',\n\t'referer',\n\t'retry-after',\n\t'user-agent'\n])" + }, + { + "id": 1957, + "name": "version", + "kind": 32, + "kindString": "Variable", + "flags": { + "isLet": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 125, + "character": 11 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "defaultValue": "\"2.0.0-pre\"" + }, + { + "id": 1977, + "name": "getAuth", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1978, + "name": "getAuth", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1979, + "name": "proxyAuth", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + }, + { + "id": 1980, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "NodeRequestOptions", + "id": 1838 + } + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "undefined" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 330, + "character": 23 + } + ] + }, + { + "id": 1961, + "name": "getDataTask", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1962, + "name": "getDataTask", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1963, + "name": "response", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "NodeResponse", + "id": 1925 + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "RequestData", + "id": 1914 + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 197, + "character": 20 + } + ] + }, + { + "id": 1981, + "name": "node", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1982, + "name": "node", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1983, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1984, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "NodeRequestOptions", + "id": 1838 + }, + "defaultValue": " {}" + } + ], + "type": { + "type": "reference", + "name": "UploadObservableTask", + "typeArguments": [ + { + "type": "reference", + "name": "NodeResponse", + "id": 1925 + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 342, + "character": 28 + } + ] + }, + { + "id": 1964, + "name": "redirect", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1965, + "name": "redirect", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1966, + "name": "resolve", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1967, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1968, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1969, + "name": "p", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 292, + "character": 9 + } + ] + } + } + }, + { + "id": 1970, + "name": "reject", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1971, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1972, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1973, + "name": "_", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Error" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 293, + "character": 8 + } + ] + } + } + }, + { + "id": 1974, + "name": "originalUrl", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1975, + "name": "redirectUrl", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + }, + { + "id": 1976, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "NodeRequestOptions", + "id": 1838 + } + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 291, + "character": 17 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1925 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 1892, + 1838, + 1878, + 1914 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 1958, + 1959, + 1960, + 1957 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1977, + 1961, + 1981, + 1964 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/node.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1766, + "name": "\"request/providers/xhr\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/request/providers/xhr.ts", + "children": [ + { + "id": 1790, + "name": "XhrResponse", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Wraps an XHR request in a response that mimics the fetch API" + }, + "children": [ + { + "id": 1807, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1808, + "name": "new XhrResponse", + "kind": 16384, + "kindString": "Constructor signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1809, + "name": "request", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "XMLHttpRequest" + } + } + ], + "type": { + "type": "reference", + "name": "XhrResponse", + "id": 1790 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 85, + "character": 2 + } + ] + }, + { + "id": 1791, + "name": "headers", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 58, + "character": 17 + } + ], + "type": { + "type": "reference", + "name": "Headers", + "id": 1659 + }, + "overwrites": { + "type": "reference", + "name": "Response.headers", + "id": 1703 + } + }, + { + "id": 1792, + "name": "ok", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 59, + "character": 12 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "overwrites": { + "type": "reference", + "name": "Response.ok", + "id": 1704 + } + }, + { + "id": 1793, + "name": "status", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 60, + "character": 16 + } + ], + "type": { + "type": "intrinsic", + "name": "number" + }, + "overwrites": { + "type": "reference", + "name": "Response.status", + "id": 1705 + } + }, + { + "id": 1794, + "name": "statusText", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 61, + "character": 20 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "overwrites": { + "type": "reference", + "name": "Response.statusText", + "id": 1706 + } + }, + { + "id": 1795, + "name": "bodyUsed", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1796, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "overwrites": { + "type": "reference", + "name": "Response.bodyUsed", + "id": 1708 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 63, + "character": 13 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.bodyUsed", + "id": 1708 + } + }, + { + "id": 1805, + "name": "data", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1806, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.data", + "id": 1711 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 83, + "character": 9 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.data", + "id": 1711 + } + }, + { + "id": 1803, + "name": "download", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1804, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "number" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.download", + "id": 1710 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 79, + "character": 13 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.download", + "id": 1710 + } + }, + { + "id": 1797, + "name": "nativeResponse", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1798, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "XMLHttpRequest" + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 67, + "character": 19 + } + ] + }, + { + "id": 1799, + "name": "requestOptions", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1800, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "XhrRequestOptions", + "id": 1767 + }, + "overwrites": { + "type": "reference", + "name": "Response.requestOptions", + "id": 1709 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 71, + "character": 19 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.requestOptions", + "id": 1709 + } + }, + { + "id": 1801, + "name": "url", + "kind": 262144, + "kindString": "Accessor", + "flags": { + "isExported": true, + "__visited__": true + }, + "getSignature": [ + { + "id": 1802, + "name": "__get", + "kind": 524288, + "kindString": "Get signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + }, + "overwrites": { + "type": "reference", + "name": "Response.url", + "id": 1707 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 75, + "character": 8 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.url", + "id": 1707 + } + }, + { + "id": 1810, + "name": "arrayBuffer", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1811, + "name": "arrayBuffer", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "ArrayBuffer" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.arrayBuffer", + "id": 1715 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 109, + "character": 12 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.arrayBuffer", + "id": 1715 + } + }, + { + "id": 1812, + "name": "blob", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1813, + "name": "blob", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "Blob" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.blob", + "id": 1717 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 113, + "character": 5 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.blob", + "id": 1717 + } + }, + { + "id": 1814, + "name": "formData", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1815, + "name": "formData", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "FormData" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.formData", + "id": 1719 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 117, + "character": 9 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.formData", + "id": 1719 + } + }, + { + "id": 1820, + "name": "json", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1821, + "name": "json", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "typeParameter": [ + { + "id": 1822, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "typeParameter", + "name": "T" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "Response.json", + "id": 1712 + } + } + ], + "sources": [ + { + "fileName": "request/Response.ts", + "line": 23, + "character": 5 + } + ], + "inheritedFrom": { + "type": "reference", + "name": "Response.json", + "id": 1712 + } + }, + { + "id": 1816, + "name": "text", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1817, + "name": "text", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "overwrites": { + "type": "reference", + "name": "Response.text", + "id": 1721 + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 121, + "character": 5 + } + ], + "overwrites": { + "type": "reference", + "name": "Response.text", + "id": 1721 + } + }, + { + "id": 1818, + "name": "xml", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1819, + "name": "xml", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "Document" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 127, + "character": 4 + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 1807 + ] + }, + { + "title": "Properties", + "kind": 1024, + "children": [ + 1791, + 1792, + 1793, + 1794 + ] + }, + { + "title": "Accessors", + "kind": 262144, + "children": [ + 1795, + 1805, + 1803, + 1797, + 1799, + 1801 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 1810, + 1812, + 1814, + 1820, + 1816, + 1818 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 57, + "character": 24 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "Response", + "id": 1702 + } + ], + "implementedTypes": [ + { + "type": "reference", + "name": "Response" + } + ] + }, + { + "id": 1782, + "name": "RequestData", + "kind": 256, + "kindString": "Interface", + "flags": { + "__visited__": true + }, + "children": [ + { + "id": 1789, + "name": "dataObservable", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 37, + "character": 15 + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "any" + } + ] + } + }, + { + "id": 1788, + "name": "downloadObservable", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 36, + "character": 19 + } + ], + "type": { + "type": "reference", + "name": "Observable", + "id": 1541, + "typeArguments": [ + { + "type": "intrinsic", + "name": "number" + } + ] + } + }, + { + "id": 1786, + "name": "nativeResponse", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 34, + "character": 15 + } + ], + "type": { + "type": "reference", + "name": "XMLHttpRequest" + } + }, + { + "id": 1785, + "name": "requestOptions", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 33, + "character": 15 + } + ], + "type": { + "type": "reference", + "name": "XhrRequestOptions", + "id": 1767 + } + }, + { + "id": 1783, + "name": "task", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 31, + "character": 5 + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "XMLHttpRequest" + } + ] + } + }, + { + "id": 1787, + "name": "url", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 35, + "character": 4 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1784, + "name": "used", + "kind": 1024, + "kindString": "Property", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 32, + "character": 5 + } + ], + "type": { + "type": "intrinsic", + "name": "boolean" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1789, + 1788, + 1786, + 1785, + 1783, + 1787, + 1784 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 30, + "character": 21 + } + ] + }, + { + "id": 1767, + "name": "XhrRequestOptions", + "kind": 256, + "kindString": "Interface", + "flags": { + "isExported": true, + "__visited__": true + }, + "comment": { + "shortText": "Request options specific to an XHR request" + }, + "children": [ + { + "id": 1768, + "name": "blockMainThread", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Controls whether or not the request is synchronous (blocks the main thread) or asynchronous (default)." + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 22, + "character": 16 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 1772, + "name": "body", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Body to send along with the http request" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 47, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Blob" + }, + { + "type": "reference", + "name": "BufferSource" + }, + { + "type": "reference", + "name": "FormData" + }, + { + "type": "reference", + "name": "UrlSearchParams", + "id": 1507 + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.body" + } + }, + { + "id": 1770, + "name": "cacheBust", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Enable cache busting (default false). Cache busting will make a new URL by appending a parameter to the\nrequested URL" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 42, + "character": 10 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.cacheBust" + } + }, + { + "id": 1771, + "name": "credentials", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 43, + "character": 12 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "stringLiteral", + "value": "omit" + }, + { + "type": "stringLiteral", + "value": "same-origin" + }, + { + "type": "stringLiteral", + "value": "include" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.credentials" + } + }, + { + "id": 1773, + "name": "headers", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Headers to send along with the http request" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 51, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "reference", + "name": "Headers" + }, + { + "type": "reflection", + "declaration": { + "id": 1774, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 1775, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1776, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 51, + "character": 20 + } + ] + } + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.headers" + } + }, + { + "id": 1769, + "name": "includeRequestedWithHeader", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Controls whether or not the X-Requested-With header is added to the request (default true). Set to false to not\ninclude the header." + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 27, + "character": 27 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "true" + }, + { + "type": "intrinsic", + "name": "false" + } + ] + } + }, + { + "id": 1777, + "name": "method", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "HTTP method" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 55, + "character": 7 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.method" + } + }, + { + "id": 1778, + "name": "password", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Password for HTTP authentication" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 59, + "character": 9 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.password" + } + }, + { + "id": 1781, + "name": "query", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Optional query parameter(s) for the URL. The requested url will have these query parameters appended." + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 71, + "character": 6 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "reference", + "name": "ParamList", + "id": 1536 + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.query" + } + }, + { + "id": 1779, + "name": "timeout", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "Number of milliseconds before the request times out and is canceled" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 63, + "character": 8 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.timeout" + } + }, + { + "id": 1780, + "name": "user", + "kind": 1024, + "kindString": "Property", + "flags": { + "isExported": true, + "isOptional": true, + "__visited__": true + }, + "comment": { + "shortText": "User for HTTP authentication" + }, + "sources": [ + { + "fileName": "request/interfaces.d.ts", + "line": 67, + "character": 5 + } + ], + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "string" + } + ] + }, + "inheritedFrom": { + "type": "reference", + "name": "RequestOptions.user" + } + } + ], + "groups": [ + { + "title": "Properties", + "kind": 1024, + "children": [ + 1768, + 1772, + 1770, + 1771, + 1773, + 1769, + 1777, + 1778, + 1781, + 1779, + 1780 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 18, + "character": 34 + } + ], + "extendedTypes": [ + { + "type": "reference", + "name": "RequestOptions" + } + ] + }, + { + "id": 1823, + "name": "dataMap", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 40, + "character": 13 + } + ], + "type": { + "type": "reference", + "name": "WeakMap", + "typeArguments": [ + { + "type": "reference", + "name": "XhrResponse", + "id": 1790 + }, + { + "type": "reference", + "name": "RequestData", + "id": 1782 + } + ] + }, + "defaultValue": " new WeakMap()" + }, + { + "id": 1824, + "name": "getDataTask", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1825, + "name": "getDataTask", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1826, + "name": "response", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "XhrResponse", + "id": 1790 + } + } + ], + "type": { + "type": "reference", + "name": "Task", + "id": 1430, + "typeArguments": [ + { + "type": "reference", + "name": "XMLHttpRequest" + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 42, + "character": 20 + } + ] + }, + { + "id": 1827, + "name": "noop", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1828, + "name": "noop", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 174, + "character": 13 + } + ] + }, + { + "id": 1829, + "name": "setOnError", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1830, + "name": "setOnError", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1831, + "name": "request", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "XMLHttpRequest" + } + }, + { + "id": 1832, + "name": "reject", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "Function" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 176, + "character": 19 + } + ] + }, + { + "id": 1833, + "name": "xhr", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1834, + "name": "xhr", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1835, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1836, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "XhrRequestOptions", + "id": 1767 + }, + "defaultValue": " {}" + } + ], + "type": { + "type": "reference", + "name": "UploadObservableTask", + "typeArguments": [ + { + "type": "reference", + "name": "XhrResponse", + "id": 1790 + } + ] + } + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 182, + "character": 27 + } + ] + } + ], + "groups": [ + { + "title": "Classes", + "kind": 128, + "children": [ + 1790 + ] + }, + { + "title": "Interfaces", + "kind": 256, + "children": [ + 1782, + 1767 + ] + }, + { + "title": "Variables", + "kind": 32, + "children": [ + 1823 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 1824, + 1827, + 1829, + 1833 + ] + } + ], + "sources": [ + { + "fileName": "request/providers/xhr.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1758, + "name": "\"request/util\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/request/util.ts", + "children": [ + { + "id": 1759, + "name": "generateRequestUrl", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1760, + "name": "generateRequestUrl", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns a URL formatted with optional query string and cache-busting segments." + }, + "parameters": [ + { + "id": 1761, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The base URL." + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 1762, + "name": "options", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The RequestOptions used to generate the query string or cacheBust.\n" + }, + "type": { + "type": "reference", + "name": "RequestOptions" + }, + "defaultValue": " {}" + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "request/util.ts", + "line": 10, + "character": 34 + } + ] + }, + { + "id": 1763, + "name": "getStringFromFormData", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1764, + "name": "getStringFromFormData", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1765, + "name": "formData", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "request/util.ts", + "line": 20, + "character": 37 + } + ] + } + ], + "groups": [ + { + "title": "Functions", + "kind": 64, + "children": [ + 1759, + 1763 + ] + } + ], + "sources": [ + { + "fileName": "request/util.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2068, + "name": "\"stringExtras\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/stringExtras.ts", + "children": [ + { + "id": 2069, + "name": "escapeRegExpPattern", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 3, + "character": 25 + } + ], + "type": { + "type": "reference", + "name": "RegExp" + }, + "defaultValue": " /[[\\]{}()|\\/\\\\^$.*+?]/g" + }, + { + "id": 2071, + "name": "escapeXmlForPattern", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 5, + "character": 25 + } + ], + "type": { + "type": "reference", + "name": "RegExp" + }, + "defaultValue": " /[&<>'\"]/g" + }, + { + "id": 2070, + "name": "escapeXmlPattern", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 4, + "character": 22 + } + ], + "type": { + "type": "reference", + "name": "RegExp" + }, + "defaultValue": " /[&<]/g" + }, + { + "id": 2078, + "name": "escapeRegExp", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2079, + "name": "escapeRegExp", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Escapes a string so that it can safely be passed to the RegExp constructor.", + "returns": "The escaped string\n" + }, + "parameters": [ + { + "id": 2080, + "name": "text", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The string to be escaped" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 19, + "character": 28 + } + ] + }, + { + "id": 2081, + "name": "escapeXml", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2082, + "name": "escapeXml", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Sanitizes a string to protect against tag injection.", + "returns": "The escaped string\n" + }, + "parameters": [ + { + "id": 2083, + "name": "xml", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "The string to be escaped" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 2084, + "name": "forAttribute", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Whether to also escape ', \", and > in addition to < and &" + }, + "type": { + "type": "intrinsic", + "name": "boolean" + }, + "defaultValue": "true" + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 29, + "character": 25 + } + ] + }, + { + "id": 2072, + "name": "escapeXmlMap", + "kind": 2097152, + "kindString": "Object literal", + "flags": { + "isConst": true, + "__visited__": true + }, + "children": [ + { + "id": 2076, + "name": "\"", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 10, + "character": 4 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "defaultValue": "\""\"" + }, + { + "id": 2073, + "name": "&", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 7, + "character": 4 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "defaultValue": "\"&\"" + }, + { + "id": 2077, + "name": "'", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 11, + "character": 4 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "defaultValue": "\"'\"" + }, + { + "id": 2074, + "name": "<", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 8, + "character": 4 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "defaultValue": "\"<\"" + }, + { + "id": 2075, + "name": ">", + "kind": 32, + "kindString": "Variable", + "flags": { + "__visited__": true + }, + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 9, + "character": 4 + } + ], + "type": { + "type": "intrinsic", + "name": "string" + }, + "defaultValue": "\">\"" + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 2076, + 2073, + 2077, + 2074, + 2075 + ] + } + ], + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 6, + "character": 18 + } + ], + "type": { + "type": "intrinsic", + "name": "object" + } + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 2069, + 2071, + 2070 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 2078, + 2081 + ] + }, + { + "title": "Object literals", + "kind": 2097152, + "children": [ + 2072 + ] + } + ], + "sources": [ + { + "fileName": "stringExtras.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2085, + "name": "\"text\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/text.ts", + "children": [ + { + "id": 2090, + "name": "getText", + "kind": 32, + "kindString": "Variable", + "flags": { + "isLet": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "text.ts", + "line": 29, + "character": 11 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 2091, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2092, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2093, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 2094, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2095, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2096, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2097, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 29, + "character": 36 + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 29, + "character": 12 + } + ] + } + } + }, + { + "id": 2102, + "name": "pending", + "kind": 32, + "kindString": "Variable", + "flags": { + "isLet": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "text.ts", + "line": 64, + "character": 11 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 2103, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 2104, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2105, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 64, + "character": 12 + } + ] + } + } + }, + { + "id": 2086, + "name": "require", + "kind": 32, + "kindString": "Variable", + "flags": { + "isConst": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "text.ts", + "line": 7, + "character": 21 + } + ], + "type": { + "type": "reference", + "name": "Require", + "id": 1208 + } + }, + { + "id": 2098, + "name": "textCache", + "kind": 32, + "kindString": "Variable", + "flags": { + "isLet": true, + "__visited__": true + }, + "sources": [ + { + "fileName": "text.ts", + "line": 59, + "character": 13 + } + ], + "type": { + "type": "reflection", + "declaration": { + "id": 2099, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "indexSignature": [ + { + "id": 2100, + "name": "__index", + "kind": 8192, + "kindString": "Index signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2101, + "name": "key", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 59, + "character": 14 + } + ] + } + } + }, + { + "id": 2106, + "name": "get", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2107, + "name": "get", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2108, + "name": "url", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "reference", + "name": "Promise", + "typeArguments": [ + { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "string" + }, + { + "type": "intrinsic", + "name": "null" + } + ] + } + ] + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 66, + "character": 19 + } + ] + }, + { + "id": 2116, + "name": "load", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2117, + "name": "load", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2118, + "name": "id", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 2119, + "name": "require", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reference", + "name": "AmdRequire", + "id": 99 + } + }, + { + "id": 2120, + "name": "load", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2121, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2122, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2123, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 83, + "character": 59 + } + ] + } + } + }, + { + "id": 2124, + "name": "config", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "reference", + "name": "AmdConfig", + "id": 26 + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 83, + "character": 20 + } + ] + }, + { + "id": 2109, + "name": "normalize", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2110, + "name": "normalize", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2111, + "name": "id", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + }, + { + "id": 2112, + "name": "toAbsMid", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 2113, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2114, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2115, + "name": "moduleId", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 76, + "character": 47 + } + ] + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 76, + "character": 25 + } + ] + }, + { + "id": 2087, + "name": "strip", + "kind": 64, + "kindString": "Function", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 2088, + "name": "strip", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 2089, + "name": "text", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 14, + "character": 14 + } + ] + } + ], + "groups": [ + { + "title": "Variables", + "kind": 32, + "children": [ + 2090, + 2102, + 2086, + 2098 + ] + }, + { + "title": "Functions", + "kind": 64, + "children": [ + 2106, + 2116, + 2109, + 2087 + ] + } + ], + "sources": [ + { + "fileName": "text.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 1616, + "name": "\"util\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/util.ts", + "children": [ + { + "id": 1617, + "name": "createTimer", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1618, + "name": "createTimer", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Wraps a setTimeout call in a handle, allowing the timeout to be cleared by calling destroy.", + "returns": "Handle which can be destroyed to clear the timeout\n" + }, + "parameters": [ + { + "id": 1619, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Callback to be called when the timeout elapses" + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1620, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1621, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1622, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 11, + "character": 37 + } + ] + } + } + }, + { + "id": 1623, + "name": "delay", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "comment": { + "text": "Number of milliseconds to wait before calling the callback" + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 11, + "character": 27 + } + ] + }, + { + "id": 1624, + "name": "debounce", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1625, + "name": "debounce", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Wraps a callback, returning a function which fires after no further calls are received over a set interval.", + "returns": "Debounced function\n" + }, + "typeParameter": [ + { + "id": 1630, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1626, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1627, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1628, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1629, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 29, + "character": 34 + } + ] + } + } + } + ], + "parameters": [ + { + "id": 1631, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Callback to wrap" + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reflection", + "declaration": { + "id": 1626, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1627, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1628, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1629, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 29, + "character": 34 + } + ] + } + } + } + }, + { + "id": 1632, + "name": "delay", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Number of milliseconds to wait after any invocations before calling the original callback" + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reflection", + "declaration": { + "id": 1626, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1627, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1628, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1629, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 29, + "character": 34 + } + ] + } + } + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 29, + "character": 24 + } + ] + }, + { + "id": 1651, + "name": "guaranteeMinimumTimeout", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1652, + "name": "guaranteeMinimumTimeout", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1653, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1654, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1655, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1656, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 99, + "character": 49 + } + ] + } + } + }, + { + "id": 1657, + "name": "delay", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isOptional": true, + "__visited__": true + }, + "type": { + "type": "union", + "types": [ + { + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "intrinsic", + "name": "number" + } + ] + } + } + ], + "type": { + "type": "reference", + "name": "Handle", + "id": 16 + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 99, + "character": 39 + } + ] + }, + { + "id": 1633, + "name": "throttle", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1634, + "name": "throttle", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Wraps a callback, returning a function which fires at most once per set interval.", + "returns": "Throttled function\n" + }, + "typeParameter": [ + { + "id": 1639, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1635, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1636, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1637, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1638, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 54, + "character": 34 + } + ] + } + } + } + ], + "parameters": [ + { + "id": 1640, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Callback to wrap" + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reflection", + "declaration": { + "id": 1635, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1636, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1637, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1638, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 54, + "character": 34 + } + ] + } + } + } + }, + { + "id": 1641, + "name": "delay", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Number of milliseconds to wait before allowing the original callback to be called again" + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reflection", + "declaration": { + "id": 1635, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1636, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1637, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1638, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 54, + "character": 34 + } + ] + } + } + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 54, + "character": 24 + } + ] + }, + { + "id": 1642, + "name": "throttleAfter", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 1643, + "name": "throttleAfter", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Like throttle, but calls the callback at the end of each interval rather than the beginning.\nUseful for e.g. resize or scroll events, when debounce would appear unresponsive.", + "returns": "Throttled function\n" + }, + "typeParameter": [ + { + "id": 1648, + "name": "T", + "kind": 131072, + "kindString": "Type parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "reflection", + "declaration": { + "id": 1644, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1645, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1646, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1647, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 79, + "character": 39 + } + ] + } + } + } + ], + "parameters": [ + { + "id": 1649, + "name": "callback", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Callback to wrap" + }, + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reflection", + "declaration": { + "id": 1644, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1645, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1646, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1647, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 79, + "character": 39 + } + ] + } + } + } + }, + { + "id": 1650, + "name": "delay", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "comment": { + "text": "Number of milliseconds to wait before calling the original callback and allowing it to be called again" + }, + "type": { + "type": "intrinsic", + "name": "number" + } + } + ], + "type": { + "type": "typeParameter", + "name": "T", + "constraint": { + "type": "reflection", + "declaration": { + "id": 1644, + "name": "__type", + "kind": 65536, + "kindString": "Type literal", + "flags": { + "__visited__": true + }, + "signatures": [ + { + "id": 1645, + "name": "__call", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "parameters": [ + { + "id": 1646, + "name": "this", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "__visited__": true + }, + "type": { + "type": "intrinsic", + "name": "any" + } + }, + { + "id": 1647, + "name": "args", + "kind": 32768, + "kindString": "Parameter", + "flags": { + "isRest": true, + "__visited__": true + }, + "type": { + "type": "array", + "elementType": { + "type": "intrinsic", + "name": "any" + } + } + } + ], + "type": { + "type": "intrinsic", + "name": "void" + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 79, + "character": 39 + } + ] + } + } + } + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 79, + "character": 29 + } + ] + } + ], + "groups": [ + { + "title": "Functions", + "kind": 64, + "children": [ + 1617, + 1624, + 1651, + 1633, + 1642 + ] + } + ], + "sources": [ + { + "fileName": "util.ts", + "line": 1, + "character": 0 + } + ] + }, + { + "id": 2393, + "name": "\"uuid\"", + "kind": 1, + "kindString": "External module", + "flags": { + "isExported": true, + "__visited__": true + }, + "originalName": "src/uuid.ts", + "children": [ + { + "id": 2394, + "name": "uuid", + "kind": 64, + "kindString": "Function", + "flags": { + "isExported": true, + "__visited__": true + }, + "signatures": [ + { + "id": 2395, + "name": "uuid", + "kind": 4096, + "kindString": "Call signature", + "flags": { + "__visited__": true + }, + "comment": { + "shortText": "Returns a v4 compliant UUID.", + "returns": "\n" + }, + "type": { + "type": "intrinsic", + "name": "string" + } + } + ], + "sources": [ + { + "fileName": "uuid.ts", + "line": 6, + "character": 28 + } + ] + } + ], + "groups": [ + { + "title": "Functions", + "kind": 64, + "children": [ + 2394 + ] + } + ], + "sources": [ + { + "fileName": "uuid.ts", + "line": 1, + "character": 0 + } + ] + } + ], + "groups": [ + { + "title": "External modules", + "kind": 1, + "children": [ + 842, + 964, + 977, + 1130, + 1067, + 1218, + 2323, + 1540, + 2364, + 2019, + 1506, + 455, + 1356, + 1424, + 2125, + 2243, + 626, + 635, + 1066, + 1023, + 1024, + 1, + 150, + 1201, + 1178, + 2396, + 2318, + 1240, + 1355, + 1985, + 1658, + 1599, + 1698, + 1736, + 1750, + 1837, + 1766, + 1758, + 2068, + 2085, + 1616, + 2393 + ] + } + ] +} \ No newline at end of file diff --git a/src/lib/core/docs/has.md b/src/lib/core/docs/has.md new file mode 100644 index 0000000..50f6f60 --- /dev/null +++ b/src/lib/core/docs/has.md @@ -0,0 +1,40 @@ +# has + +## Detecting Features + +The default export of `dojo-core/has` is a function which accepts a single parameter: the name of the feature to test for. +If the feature is available, a truthy value is returned, otherwise a falsy value is returned: + +```ts +import has from 'dojo-core/has'; + +if (has('dom-addeventlistener')) { + element.addEventListener('click', function () { /* ... */ }); +} +``` + +## Adding Feature Detections + +It's important to be able to add new feature tests that aren't provided out-of-the-box by `dojo-core/has`. +This can be done easily by using the `add` function exported by the `has` module. It accepts two parameters: +the name of the feature, and either an immediate value indicating its availability or a function that resolves to a +value. + +When a function is passed, the feature will be lazily evaluated - i.e. the function is not executed until the feature is +actually requested. The return value is then cached for future calls for the same feature. + +```ts +import { add as hasAdd } from 'dojo-core/has'; +hasAdd('dom-queryselector', 'querySelector' in document && 'querySelectorAll' in document); + +// Lazily executed; useful if a polyfill is loaded after page load +hasAdd('typedarray', function () { + return 'ArrayBuffer' in window; +}); +``` + +## Accessing the Feature Cache + +`dojo-core/has` maintains object hashes containing keys that correspond to all features that have been both +registered _and_ requested. The value associated with each feature name key corresponds to that feature's availability +in the current environment. The object hash containing evaluated features is accessible via the `cache` export. diff --git a/src/lib/core/docs/lang.md b/src/lib/core/docs/lang.md new file mode 100644 index 0000000..585ee36 --- /dev/null +++ b/src/lib/core/docs/lang.md @@ -0,0 +1,210 @@ +# lang + +## Module Exports + +### `assign` + +Copies values of own properties from the source object(s) to the target object. + +```ts +import { assign } from '@dojo/core/lang'; + +var target = { + foo: 'bar' +}; + +var source = { + bar: 'foo' +}; + +assign(target, source); + +target.foo === 'bar'; // true +target.bar === 'foo'; // true + +``` + +### `create` + +Creates a new object from the given prototype, and copies all enumerable own properties of one or more source objects to the newly created target object. + +```ts +import { create } from '@dojo/core/lang'; + +var oldObj = { + foo: 'bar', + obj: { + bar: 'foo' + } +}; + +var newObj = create(oldObj, { + bar: 'foo' +}); + +newObj.bar === 'foo'; // true +newObj.foo === 'bar'; // true +newObj.obj.bar === 'foo'; // true + +oldObj.foo = 'foo'; +oldObj.obj.bar = 'bar'; + +newObj.foo === 'bar'; // true +newObj.obj.bar === 'bar'; // true +``` + +### `deepAssign` + +Copies the values of all enumerable own properties of one or more source objects to the target object, recursively copying all nested objects and arrays as well. + +```ts +import { deepAssign } from '@dojo/core/lang'; + +var oldObj = { + foo: 'bar', + obj: { + bar: 'foo' + } +}; + +var newObj = deepAssign(oldObj, { + bar: 'foo' +}); + +newObj.bar === 'foo'; // true +newObj.foo === 'bar'; // true +newObj.obj.bar === 'foo'; // true + +oldObj.foo = 'foo'; +oldObj.obj.bar = 'bar'; + +newObj.foo === 'bar'; // true +newObj.obj.bar === 'bar'; // true +``` + +### `mixin` + +Copies values of own and inherited properties from the source object(s) to the target object. + +```ts +import { mixin } from '@dojo/core/lang'; + +const obj = { + foo: 'bar', + fooObj: { + bar: 'foo' + } +}; + +const result = mixin({}, obj); + +result.foo === 'bar'; // true +result.fooObj.bar === 'foo'; // true + +obj.fooObj.bar = 'bar'; + +result.fooObj.bar === 'bar'; // true + +``` + +### `deepMixin` + +Copies the values of all enumerable (own or inherited) properties of one or more source objects to the target object, recursively copying all nested objects and arrays as well. + +```ts +import { deepMixin } from '@dojo/core/lang'; + +const obj = { + foo: 'bar', + fooObj: { + bar: 'foo' + } +}; + +const result = deepMixin({}, obj); + +result.foo === 'bar'; // true +result.fooObj.bar === 'foo'; // true + +obj.fooObj.bar = 'bar'; + +result.fooObj.bar === 'bar'; // false +result.fooObj.bar === 'foo'; // true + +``` + +### `duplicate` + +Creates a new object using the provided source's prototype as the prototype for the new object, and then deep copies the provided source's values into the new target. + +```ts +import { duplicate } from '@dojo/core/lang'; + +var oldObj = { + foo: 'bar' +}; + +var newObj = duplicate(oldObj); + +oldObj.foo = 'foo'; + +oldObj.foo === 'foo'; +newObj.foo === 'bar'; + +``` + +### `partial` + +Returns a function which invokes the given function with the given arguments prepended to its argument list. Like `Function.prototype.bind`, but does not alter execution context. + +```ts +import { partial } from '@dojo/core/lang'; + +var add = function (a, b) { + return a + b; +} + +var addFive = partial(add, 5); + +var result = addFive(4); + +result === 9; + +``` + +### `isIdentical` + +Determines whether two values are the same (including NaN). + +```ts +import { isIdentical } from '@dojo/core/lang'; + +isIdentical(1, 1); // true +isIdentical(NaN, NaN); // true + +``` + +### `lateBind` + +Creates a function that calls the current method on an object with given arguments. + +```ts +import { lateBind } from '@dojo/core/lang'; + +var person = { + speak: function (name) { + return 'hi, ' + name; + } +}; + +var personSpeak = lateBind(person, 'speak', 'name'); + +personSpeak() === 'hi, name'; // true + +person.speak = function (name) { + return 'bye, ' + name; +}; + +personSpeak() === 'bye, name'; + +``` diff --git a/src/lib/core/docs/load.md b/src/lib/core/docs/load.md new file mode 100644 index 0000000..0e74a5f --- /dev/null +++ b/src/lib/core/docs/load.md @@ -0,0 +1,117 @@ +# load + +## Module Exports + +### 'isPlugin' + +Tests a value to determine whether is a plugin (an object with a `load` method). + +```ts +import { isPlugin } from '@dojo/core/load'; + +// true +isPlugin({ + load() {} + normalize() {} +}); + +isPlugin(1); // false +isPlugin([]); // false +isPlugin([]); // false +// false +isPlugin({ + observer() {} +}); + +``` + +### 'load' + +Dynamically loads a module or other resource. + +```ts +import load, { useDefault } from '@dojo/core/load'; + +// Load a single module +load('mymodule').then(([ myModule ]: [ any ]) => { + // ... +}); + +// Load multiple modules +load('namespace/first', 'namespace/second').then(([ first, second ]: [ any, any ]) => { + // ... +}); + +// Load modules with relative ids as relative to the current module +load(require, './first', './second').then(([ first, second ]: [ any, any ]) => { + // ... +}); + +// Automatically map modules to their default export +load('namespace/first').then(useDefault).then(([ first ]: [ any ]) => { + // ... +}); + +// Load a custom resource via a plugin +load(require, 'plugin!./template.html').then(([ html ]: [ string ]) => { + // ... +}); + +``` + +#### Using Plugins + +AMD-style plugins can be used with `load` by passing in module ids with the format `{pluginId}!{resourceId}`. First, the plugin will be loaded, and then the resource id (the string that follows the `!` in the mid passed to `core/load`) will be normalized and passed to the plugin's `load` method. If the plugin module does not actually have a `load` method, then the resource id is ignored, and the module is returned as-is. Plugins can also expose an optional `normalize` method that is passed the resource id and a resolver method (which will be either `require.toUrl`, `require.resolve`, or an identity function, depending on the environment). Note that if no `normalize` method is provided, then the provided resource id will be resolved using `require.toUrl` or `require.resolve`, depending on the environment. Again, if the plugin module has a default export, the `normalize` method MUST exist on that object. + +Note: the plugins that can be used with `load` loosely follow the [amdjs plugin API](https://github.com/amdjs/amdjs-api/blob/master/LoaderPlugins.md), with the following exceptions: + +1. The plugin's `load` method does not receive a contextual `require` or a configuration object. +2. Rather than execute a callback when the resource has loaded, the plugin's `load` method instead must return a promise that resolves to that resource. + +```ts +// Plugin that does not use the default export. +import { Load } from '@dojo/core/load'; + +export function normalize(resourceId: string, resolver: (id: string) => string): string { + return resolver(resourceId); +} + +export function load(resourceId: string, load: Load) { + // This plugin does nothing more than load the resource id with `core/load`. + return load(resourceId); +} + +``` + +```ts +// The same plugin, but using the default export +import { Load } from '@dojo/core/load'; + +const plugin = { + normalize(resourceId: string, resolver: (id: string) => string): string { + return resolver(resourceId); + }, + + load(resourceId: string, load: Load) { + // This plugin does nothing more than load the resource id with `core/load`. + return load(resourceId); + } +}; +export default plugin; + +``` + +```ts +import load from '@dojo/core/load'; + +// 1. The module with the id `plugin` is loaded. +// 2. If `plugin` is not actually a plugin, then `plugin` itself is returned. +// 3. If the plugin has a normalize method, then "some/resource/id" is passed to it, +// and the return value is used as the resource id. +// 4. The resource id is passed to the plugin's `load` method. +// 5. The loaded resource is used to resolve the `load` promise. +load('plugin!some/resource/id').then(([ resource ]: [ any ]) => { + // ... +}); + +``` diff --git a/src/lib/core/docs/on.md b/src/lib/core/docs/on.md new file mode 100644 index 0000000..38735e2 --- /dev/null +++ b/src/lib/core/docs/on.md @@ -0,0 +1,65 @@ +# On + +`dojo-core/on` provides event handling support with methods to attach and emit events. + +## `emit` + +Dispatch event to target. + +```ts +import { emit } from '@dojo/core/on'; + +var button = document.getElementById('button'); +var DOMEventObject = { + type: 'click', + bubbles: true, + cancelable: true +}; + +emit(button, DOMEventObject); + +``` +## `on` + +Adds event listener to target. + +```ts +import { on } from '@dojo/core/on'; + +var button = document.getElementById('button'); + +on(button, 'click', function (event) { + console.log(event.target.id); +}); + +``` +## `once` + +Attach an event that can only be called once to a target. + +```ts +import { once } from '@dojo/core/on'; + +var button = document.getElementById('button'); +once(button, 'click', function (event) { + console.log(event.target.id); + console.log('this event has been removed') +}); + +``` +## `pausable` + +Attach an event that can be paused to a target. + +```ts +import { pausable } from '@dojo/core/on'; + +var button = document.getElementById('button'); +var buttonClickHandle = pausable(button, 'click', function (event) { + console.log(event.target.id); +}); + +buttonClickHandle.pause(); // when paused the event will not fire +buttonClickHandle.resume(); // after resuming the event will begin to fire again if triggered + +``` diff --git a/src/lib/core/docs/request.md b/src/lib/core/docs/request.md new file mode 100644 index 0000000..0235bb0 --- /dev/null +++ b/src/lib/core/docs/request.md @@ -0,0 +1,75 @@ +# request + +This modules provides 4 methods (get, post, delete, and put) to simplify sending http requests. Each of these methods returns a promise that resolves with the response. + +* request + * get + * post + * delete + * put + +## Making Requests + +Making requests is similar to using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). + +A GET request, + +```typescript +const json = await request('http://www.example.com').then(response => response.json()); +``` + +A POST request, + +```typescript +const response = await request.post('http://www.example.com', { body: JSON.stringify(myValues)}).then(response => response.json()); +``` + +## Observables + +Several observables are available to provide deeper insight into the state of a request. + +### Monitoring Upload Progress + +Upload progress can be monitored with the `upload` observable on the `Request` object. Since upload events automatically cause a preflight request, they can be disabled by setting `includeUploadProgress: false`. + +```typescript +const req = request.post('http://www.example.com/', { + body: someLargeString +}); + +req.upload.subscribe(totalUploadedBytes => { + // do something with uploaded bytes +}) +``` + +Note that while the Node.js provider will emit a single upload event when it is done uploading, it cannot emit more granular upload events with `string` or `Buffer` body types. To receive more frequent upload events, you can use the `bodyStream` option to provide a `Readable` with the body content. Upload events will be emitted as the data is read from the stream. + +```typescript +request.post('http://www.example.com/', { + bodyStream: fs.createReadStream('some-large-file') +}); +``` + +### Monitoring Download Progress + +You can monitor download progress by subscribing to the `download` observable on the `Response` object. + +```typescript +request("http://www.example/some-large-file").then(response => { + response.download.subscribe(totalBytesDownloaded => { + // do something with totalBytesDownloaded + }); +}); +``` + +### Receiving Raw Data + +You can receive the raw data from a response with the `data` observable. Depending on the provider, the value might be a `string`, or a `Buffer`. + +```typescript +request("http://www.example/some-large-file").then(response => { + response.data.subscribe(chunk => { + // do something with chunk + }); +}); +``` diff --git a/src/lib/core/docs/stringExtras.md b/src/lib/core/docs/stringExtras.md new file mode 100644 index 0000000..4b365de --- /dev/null +++ b/src/lib/core/docs/stringExtras.md @@ -0,0 +1,30 @@ +# stringExtras + +## `escapeRegExp` + +Escapes a string to safely be included in regular expressions. + +```ts +import { escapeRegExp } from '@dojo/core/string'; + +const str = 'cat file.js | grep -c'; + +const result = escapeRegExp(str); + +result === 'cat file\\.js \\| grep -c'; // true + +``` + +## `escapeXml` + +Escapes XML (or HTML) content in a string. + +```ts +import { escapeXml } from '@dojo/core/string'; + +const badCode = ""; + +const sanitized = escapeXml(badCode); + +sanitized === '<script>alert('hi')</script>'; // true +``` diff --git a/src/lib/core/intern.json b/src/lib/core/intern.json new file mode 100644 index 0000000..a6d312f --- /dev/null +++ b/src/lib/core/intern.json @@ -0,0 +1,91 @@ +{ + "capabilities+": { + "project": "Dojo 2", + "name": "@dojo/core", + "fixSessionCapabilities": false, + "browserstack.debug": false + }, + + "environments": [ + { "browserName": "node" } + ], + + "suites": [ + "./_build/tests/unit/all.js" + ], + + "functionalSuites": [ + "./_build/tests/functional/all.js" + ], + + "plugins": [ + "./_build/tests/plugins/echo-service.js" + ], + + "browser": { + "loader": "./node_modules/grunt-dojo2/lib/intern/internLoader.js", + "suites+": [ + "./_build/tests/unit/all-browser.js" + ] + }, + + "node": { + "suites+": [ + "./_build/tests/unit/all-node.js" + ] + }, + + "coverage": [ + "./_build/src/**/*.js" + ], + + "configs": { + "browserstack": { + "tunnel": "browserstack", + + "environments+": [ + { "browserName": "internet explorer", "version": "11", "os": "WINDOWS", "os_version": [ "8.1", "10" ] }, + { "browserName": "edge" }, + { "browserName": "firefox", "platform": "WINDOWS" }, + { "browserName": "chrome", "platform": "WINDOWS" }, + { "browserName": "safari", "version": "10.1", "platform": "MAC" } + ], + + "maxConcurrency": 5 + }, + + "node-loader": { + "node": { + "loader": "./node_modules/grunt-dojo2/lib/intern/internLoader.js", + "suites+": [ + "./_build/tests/unit/all-node-loader.js" + ] + } + }, + + "local": { + "tunnel": "selenium", + "tunnelOptions": { + "hostname": "localhost", + "port": 4444 + }, + + "environments+": [ + { "browserName": "chrome" } + ] + }, + + "saucelabs": { + "tunnel": "saucelabs", + "tunnelOptions": {}, + + "defaultTimeout": 10000, + "environments+": [ + { "browserName": "internet explorer", "version": [ "11.0" ], "platform": "Windows 7" }, + { "browserName": "firefox", "version": "43", "platform": "Windows 10" }, + { "browserName": "chrome", "platform": "Windows 10" } + ], + "maxConcurrency": 4 + } + } +} diff --git a/src/lib/core/package.json b/src/lib/core/package.json new file mode 100644 index 0000000..32652d1 --- /dev/null +++ b/src/lib/core/package.json @@ -0,0 +1,78 @@ +{ + "name": "@dojo/core", + "version": "2.0.1-pre", + "description": "Basic utilites for common TypeScript development", + "engines": { + "npm": ">=3.0.0" + }, + "homepage": "https://dojo.io", + "bugs": { + "url": "https://github.com/dojo/core/issues" + }, + "license": "BSD-3-Clause", + "private": true, + "main": "main.js", + "repository": { + "type": "git", + "url": "https://github.com/dojo/core.git" + }, + "scripts": { + "prepublish": "grunt peerDepInstall", + "precommit": "lint-staged", + "prettier": "prettier --write 'src/**/*.ts' 'tests/**/*.ts'", + "test": "grunt test" + }, + "dependencies": { + "tslib": "~1.8.1" + }, + "peerDependencies": { + "@dojo/has": "^2.0.0", + "@dojo/shim": "^2.0.0" + }, + "devDependencies": { + "@dojo/loader": "^2.0.0", + "@theintern/leadfoot": "~2.0.2", + "@types/benchmark": "~1.0.0", + "@types/chai": "~4.0.0", + "@types/express": "~4.0.39", + "@types/glob": "~5.0.0", + "@types/grunt": "~0.4.0", + "@types/multer": "~1.3.3", + "@types/node": "~9.6.5", + "@types/sinon": "~1.16.0", + "benchmark": "^1.0.0", + "express": "~4.15.3", + "grunt": "^1.0.1", + "grunt-contrib-clean": ">=1.0.0", + "grunt-contrib-copy": ">=1.0.0", + "grunt-dojo2": "latest", + "grunt-postcss": "^0.8.0", + "grunt-text-replace": ">=0.4.0", + "grunt-ts": ">=5.0.0", + "grunt-tslint": "5.0.1", + "grunt-typings": "^0.1.5", + "husky": "0.14.3", + "intern": "~4.1.0", + "lint-staged": "6.0.0", + "multer": "~1.3.0", + "prettier": "1.9.2", + "remap-istanbul": ">=0.6.3", + "sinon": "~1.17.6", + "tslint": "5.8.0", + "typescript": "~2.6.1" + }, + "lint-staged": { + "*.{ts,tsx}": [ + "prettier --write", + "git add" + ] + }, + "prettier": { + "singleQuote": true, + "tabWidth": 4, + "useTabs": true, + "parser": "typescript", + "printWidth": 120, + "arrowParens": "always" + } +} diff --git a/src/lib/core/resources/BrowserStackLogo.png b/src/lib/core/resources/BrowserStackLogo.png new file mode 100644 index 0000000..4b7ea4f Binary files /dev/null and b/src/lib/core/resources/BrowserStackLogo.png differ diff --git a/src/lib/core/src/DateObject.ts b/src/lib/core/src/DateObject.ts new file mode 100644 index 0000000..55ebbff --- /dev/null +++ b/src/lib/core/src/DateObject.ts @@ -0,0 +1,350 @@ +import { Hash } from './interfaces'; + +export interface KwArgs { + dayOfMonth?: number; + hours?: number; + milliseconds?: number; + minutes?: number; + month: number; + seconds?: number; + year: number; +} + +export interface OperationKwArgs { + days?: number; + hours?: number; + milliseconds?: number; + minutes?: number; + months?: number; + seconds?: number; + years?: number; +} + +/** + * The properties of a complete date + */ +export interface DateProperties { + dayOfMonth: number; + readonly dayOfWeek: number; + readonly daysInMonth: number; + hours: number; + readonly isLeapYear: boolean; + milliseconds: number; + minutes: number; + month: number; + seconds: number; + year: number; +} + +const days = [NaN, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +const isLeapYear = (function() { + const date = new Date(); + function isLeapYear(year: number): boolean { + date.setFullYear(year, 1, 29); + return date.getDate() === 29; + } + return isLeapYear; +})(); + +const operationOrder = ['years', 'months', 'days', 'hours', 'minutes', 'seconds', 'milliseconds']; +const operationHash: Hash = Object.create(null, { + days: { value: 'Date' }, + hours: { value: 'UTCHours' }, + milliseconds: { value: 'UTCMilliseconds' }, + minutes: { value: 'UTCMinutes' }, + months: { value: 'Month' }, + seconds: { value: 'UTCSeconds' }, + years: { value: 'FullYear' } +}); + +export class DateObject implements DateProperties { + static parse(str: string): DateObject { + return new DateObject(Date.parse(str)); + } + + static now(): DateObject { + return new DateObject(Date.now()); + } + + private readonly _date: Date; + readonly utc: DateProperties; + + constructor(value: number); + constructor(value: string); + constructor(value: Date); + constructor(value: KwArgs); + constructor(); + constructor(value?: any) { + let _date: Date; + if (!arguments.length) { + _date = new Date(); + } else if (value instanceof Date) { + _date = new Date(+value); + } else if (typeof value === 'number' || typeof value === 'string') { + _date = new Date(value); + } else { + _date = new Date( + value.year, + value.month - 1, + value.dayOfMonth || 1, + value.hours || 0, + value.minutes || 0, + value.seconds || 0, + value.milliseconds || 0 + ); + } + + this._date = _date; + const self = this; + this.utc = { + get isLeapYear(this: DateObject): boolean { + return isLeapYear(this.year); + }, + get daysInMonth(this: DateObject): number { + const month = this.month; + + if (month === 2 && this.isLeapYear) { + return 29; + } + return days[month]; + }, + + get year(): number { + return self._date.getUTCFullYear(); + }, + set year(year: number) { + self._date.setUTCFullYear(year); + }, + + get month(): number { + return self._date.getUTCMonth() + 1; + }, + set month(month: number) { + self._date.setUTCMonth(month - 1); + }, + + get dayOfMonth(): number { + return self._date.getUTCDate(); + }, + set dayOfMonth(day: number) { + self._date.setUTCDate(day); + }, + + get hours(): number { + return self._date.getUTCHours(); + }, + set hours(hours: number) { + self._date.setUTCHours(hours); + }, + + get minutes(): number { + return self._date.getUTCMinutes(); + }, + set minutes(minutes: number) { + self._date.setUTCMinutes(minutes); + }, + + get seconds(): number { + return self._date.getUTCSeconds(); + }, + set seconds(seconds: number) { + self._date.setUTCSeconds(seconds); + }, + + get milliseconds(): number { + return self._date.getUTCMilliseconds(); + }, + set milliseconds(milliseconds: number) { + self._date.setUTCMilliseconds(milliseconds); + }, + + get dayOfWeek(): number { + return self._date.getUTCDay(); + }, + + toString: function(): string { + return self._date.toUTCString(); + } + } as any; + } + + get isLeapYear(): boolean { + return isLeapYear(this.year); + } + + get daysInMonth(): number { + const month = this.month; + + if (month === 2 && this.isLeapYear) { + return 29; + } + return days[month]; + } + + get year(): number { + return this._date.getFullYear(); + } + set year(year: number) { + const dayOfMonth = this.dayOfMonth; + + this._date.setFullYear(year); + + if (this.dayOfMonth < dayOfMonth) { + this.dayOfMonth = 0; + } + } + + get month(): number { + return this._date.getMonth() + 1; + } + set month(month: number) { + const dayOfMonth = this.dayOfMonth; + + this._date.setMonth(month - 1); + + if (this.dayOfMonth < dayOfMonth) { + this.dayOfMonth = 0; + } + } + + get dayOfMonth(): number { + return this._date.getDate(); + } + set dayOfMonth(day: number) { + this._date.setDate(day); + } + + get hours(): number { + return this._date.getHours(); + } + set hours(hours: number) { + this._date.setHours(hours); + } + + get minutes(): number { + return this._date.getMinutes(); + } + set minutes(minutes: number) { + this._date.setMinutes(minutes); + } + + get seconds(): number { + return this._date.getSeconds(); + } + set seconds(seconds: number) { + this._date.setSeconds(seconds); + } + + get milliseconds(): number { + return this._date.getMilliseconds(); + } + set milliseconds(milliseconds: number) { + this._date.setMilliseconds(milliseconds); + } + + get time(): number { + return this._date.getTime(); + } + set time(time: number) { + this._date.setTime(time); + } + + get dayOfWeek(): number { + return this._date.getDay(); + } + get timezoneOffset(): number { + return this._date.getTimezoneOffset(); + } + + add(value: number): DateObject; + add(value: OperationKwArgs): DateObject; + add(value: any): DateObject { + const result = new DateObject(this.time); + + if (typeof value === 'number') { + result.time += value; + } else { + // Properties have to be added in a particular order to properly handle + // date overshoots in month and year calculations + operationOrder.forEach((property: string): void => { + if (!(property in value)) { + return; + } + + const dateMethod = operationHash[property]; + (result._date)[`set${dateMethod}`]((this._date)[`get${dateMethod}`]() + value[property]); + + if ((property === 'years' || property === 'months') && result.dayOfMonth < this.dayOfMonth) { + // Set the day of the month to 0 to move the date to the first day of the previous + // month to fix overshoots when adding a month and the date is the 31st or adding + // a year and the date is the 29th + result.dayOfMonth = 0; + } + }); + } + + return result; + } + + compare(value: DateObject): number { + const result = this.time - value.time; + if (result > 0) { + return 1; + } + if (result < 0) { + return -1; + } + return 0; + } + + compareDate(value: KwArgs): number { + const left = new DateObject(this); + const right = new DateObject(value); + + left._date.setHours(0, 0, 0, 0); + right._date.setHours(0, 0, 0, 0); + + return left.compare(right); + } + + compareTime(value: KwArgs): number { + const left = new DateObject(this); + const right = new DateObject(value); + + left._date.setFullYear(0, 0, 0); + right._date.setFullYear(0, 0, 0); + + return left.compare(right); + } + + toString(): string { + return this._date.toString(); + } + toDateString(): string { + return this._date.toDateString(); + } + toTimeString(): string { + return this._date.toTimeString(); + } + toLocaleString(): string { + return this._date.toLocaleString(); + } + toLocaleDateString(): string { + return this._date.toLocaleDateString(); + } + toLocaleTimeString(): string { + return this._date.toLocaleTimeString(); + } + toISOString(): string { + return this._date.toISOString(); + } + toJSON(key?: any): string { + return this._date.toJSON(key); + } + valueOf(): number { + return this._date.valueOf(); + } +} + +export default DateObject; diff --git a/src/lib/core/src/Destroyable.ts b/src/lib/core/src/Destroyable.ts new file mode 100644 index 0000000..88d6bc9 --- /dev/null +++ b/src/lib/core/src/Destroyable.ts @@ -0,0 +1,67 @@ +import { Handle } from './interfaces'; +import { createCompositeHandle } from './lang'; +import Promise from '@dojo/shim/Promise'; + +/** + * No operation function to replace own once instance is destoryed + */ +function noop(): Promise { + return Promise.resolve(false); +} + +/** + * No op function used to replace own, once instance has been destoryed + */ +function destroyed(): never { + throw new Error('Call made to destroyed method'); +} + +export class Destroyable { + /** + * register handles for the instance + */ + private handles: Handle[]; + + /** + * @constructor + */ + constructor() { + this.handles = []; + } + + /** + * Register handles for the instance that will be destroyed when `this.destroy` is called + * + * @param {Handle} handle The handle to add for the instance + * @returns {Handle} a handle for the handle, removes the handle for the instance and calls destroy + */ + own(handles: Handle | Handle[]): Handle { + const handle = Array.isArray(handles) ? createCompositeHandle(...handles) : handles; + const { handles: _handles } = this; + _handles.push(handle); + return { + destroy() { + _handles.splice(_handles.indexOf(handle)); + handle.destroy(); + } + }; + } + + /** + * Destrpys all handers registered for the instance + * + * @returns {Promise { + return new Promise((resolve) => { + this.handles.forEach((handle) => { + handle && handle.destroy && handle.destroy(); + }); + this.destroy = noop; + this.own = destroyed; + resolve(true); + }); + } +} + +export default Destroyable; diff --git a/src/lib/core/src/Evented.ts b/src/lib/core/src/Evented.ts new file mode 100644 index 0000000..32a25f5 --- /dev/null +++ b/src/lib/core/src/Evented.ts @@ -0,0 +1,132 @@ +import Map from '@dojo/shim/Map'; +import { Handle, EventType, EventObject } from './interfaces'; +import { Destroyable } from './Destroyable'; + +/** + * Map of computed regular expressions, keyed by string + */ +const regexMap = new Map(); + +/** + * Determines is the event type glob has been matched + * + * @returns boolean that indicates if the glob is matched + */ +export function isGlobMatch(globString: string | symbol, targetString: string | symbol): boolean { + if (typeof targetString === 'string' && typeof globString === 'string' && globString.indexOf('*') !== -1) { + let regex: RegExp; + if (regexMap.has(globString)) { + regex = regexMap.get(globString)!; + } else { + regex = new RegExp(`^${globString.replace(/\*/g, '.*')}$`); + regexMap.set(globString, regex); + } + return regex.test(targetString); + } else { + return globString === targetString; + } +} + +export type EventedCallback = EventObject> = { + /** + * A callback that takes an `event` argument + * + * @param event The event object + */ + + (event: E): boolean | void; +}; + +export interface CustomEventTypes = EventObject> { + [index: string]: T; +} + +/** + * A type which is either a targeted event listener or an array of listeners + * @template T The type of target for the events + * @template E The event type for the events + */ +export type EventedCallbackOrArray = EventObject> = + | EventedCallback + | EventedCallback[]; + +/** + * Event Class + */ +export class Evented< + M extends CustomEventTypes = {}, + T = EventType, + O extends EventObject = EventObject +> extends Destroyable { + // The following member is purely so TypeScript remembers the type of `M` when extending so + // that the utilities in `on.ts` will work https://github.com/Microsoft/TypeScript/issues/20348 + // tslint:disable-next-line + protected __typeMap__?: M; + /** + * map of listeners keyed by event type + */ + protected listenersMap: Map[]> = new Map(); + + /** + * Emits the event object for the specified type + * + * @param event the event to emit + */ + emit(event: M[K]): void; + emit(event: O): void; + emit(event: any): void { + this.listenersMap.forEach((methods, type) => { + if (isGlobMatch(type as any, event.type)) { + [...methods].forEach((method) => { + method.call(this, event); + }); + } + }); + } + + /** + * Catch all handler for various call signatures. The signatures are defined in + * `BaseEventedEvents`. You can add your own event type -> handler types by extending + * `BaseEventedEvents`. See example for details. + * + * @param args + * + * @example + * + * interface WidgetBaseEvents extends BaseEventedEvents { + * (type: 'properties:changed', handler: PropertiesChangedHandler): Handle; + * } + * class WidgetBase extends Evented { + * on: WidgetBaseEvents; + * } + * + * @return {any} + */ + on(type: K, listener: EventedCallbackOrArray): Handle; + on(type: T, listener: EventedCallbackOrArray): Handle; + on(type: any, listener: EventedCallbackOrArray): Handle { + if (Array.isArray(listener)) { + const handles = listener.map((listener) => this._addListener(type, listener)); + return { + destroy() { + handles.forEach((handle) => handle.destroy()); + } + }; + } + return this._addListener(type, listener); + } + + private _addListener(type: T | keyof M, listener: EventedCallback) { + const listeners = this.listenersMap.get(type) || []; + listeners.push(listener); + this.listenersMap.set(type, listeners); + return { + destroy: () => { + const listeners = this.listenersMap.get(type) || []; + listeners.splice(listeners.indexOf(listener), 1); + } + }; + } +} + +export default Evented; diff --git a/src/lib/core/src/IdentityRegistry.ts b/src/lib/core/src/IdentityRegistry.ts new file mode 100644 index 0000000..a88ebb6 --- /dev/null +++ b/src/lib/core/src/IdentityRegistry.ts @@ -0,0 +1,180 @@ +import Map from '@dojo/shim/Map'; +import WeakMap from '@dojo/shim/WeakMap'; +import { Iterable, IterableIterator } from '@dojo/shim/iterator'; +import { Handle } from './interfaces'; +import '@dojo/shim/Symbol'; +import List from './List'; + +const noop = () => {}; + +interface Entry { + readonly handle: Handle; + readonly value: V; +} + +interface State { + readonly entryMap: Map>; + readonly idMap: WeakMap; +} + +const privateStateMap = new WeakMap, State>(); + +function getState(instance: IdentityRegistry): State { + return privateStateMap.get(instance)!; +} + +/** + * Registry identities can be strings or symbols. Note that the empty string is allowed. + */ +export type Identity = string | symbol; + +/** + * A registry of values, mapped by identities. + */ +export class IdentityRegistry implements Iterable<[Identity, V]> { + constructor() { + privateStateMap.set(this, { + entryMap: new Map>(), + idMap: new WeakMap() + }); + } + + /** + * Look up a value by its identifier. + * + * Throws if no value has been registered for the given identifier. + * + * @param id The identifier + * @return The value + */ + get(id: Identity): V { + const entry = getState(this).entryMap.get(id); + if (!entry) { + throw new Error(`Could not find a value for identity '${id.toString()}'`); + } + + return entry.value; + } + + /** + * Determine whether the value has been registered. + * @param value The value + * @return `true` if the value has been registered, `false` otherwise + */ + contains(value: V): boolean { + return getState(this).idMap.has(value); + } + + /** + * Remove from the registry the value for a given identifier. + * @param id The identifier + * @return `true` if the value was removed, `false` otherwise + */ + delete(id: Identity): boolean { + const entry = getState(this).entryMap.get(id); + if (!entry) { + return false; + } + + entry.handle.destroy(); + return true; + } + + /** + * Determine whether a value has been registered for the given identifier. + * @param id The identifier + * @return `true` if a value has been registered, `false` otherwise + */ + has(id: Identity): boolean { + return getState(this).entryMap.has(id); + } + + /** + * Look up the identifier for which the given value has been registered. + * + * Throws if the value hasn't been registered. + * + * @param value The value + * @return The identifier otherwise + */ + identify(value: V): Identity | undefined { + if (!this.contains(value)) { + throw new Error('Could not identify non-registered value'); + } + + return getState(this).idMap.get(value); + } + + /** + * Register a new value with a new identity. + * + * Throws if a different value has already been registered for the given identity, + * or if the value has already been registered with a different identity. + * + * @param id The identifier + * @param value The value + * @return A handle for deregistering the value. Note that when called repeatedly with + * the same identifier and value combination, the same handle is returned + */ + register(id: Identity, value: V): Handle { + const entryMap = getState(this).entryMap; + const existingEntry = entryMap.get(id); + if (existingEntry && existingEntry.value !== value) { + const str = id.toString(); + throw new Error(`A value has already been registered for the given identity (${str})`); + } + + const existingId = this.contains(value) ? this.identify(value) : null; + if (existingId && existingId !== id) { + const str = existingId.toString(); + throw new Error(`The value has already been registered with a different identity (${str})`); + } + + // Adding the same value with the same id is a noop, return the original handle. + if (existingEntry && existingId) { + return existingEntry.handle; + } + + const handle = { + destroy: () => { + handle.destroy = noop; + getState(this).entryMap.delete(id); + } + }; + + entryMap.set(id, { handle, value }); + getState(this).idMap.set(value, id); + + return handle; + } + + entries(): IterableIterator<[Identity, V]> { + const values = new List<[Identity, V]>(); + + getState(this).entryMap.forEach((value: Entry, key: Identity) => { + values.add([key, value.value]); + }); + + return values.values(); + } + + values(): IterableIterator { + const values = new List(); + + getState(this).entryMap.forEach((value: Entry, key: Identity) => { + values.add(value.value); + }); + + return values.values(); + } + + ids(): IterableIterator { + return getState(this).entryMap.keys(); + } + + [Symbol.iterator](): IterableIterator<[Identity, V]> { + return this.entries(); + } +} + +export default IdentityRegistry; diff --git a/src/lib/core/src/List.ts b/src/lib/core/src/List.ts new file mode 100644 index 0000000..7830468 --- /dev/null +++ b/src/lib/core/src/List.ts @@ -0,0 +1,106 @@ +import { isArrayLike, isIterable, Iterable, IterableIterator, ShimIterator } from '@dojo/shim/iterator'; +import WeakMap from '@dojo/shim/WeakMap'; + +const listItems: WeakMap, any[]> = new WeakMap, any[]>(); + +function getListItems(list: List): T[] { + return (listItems.get(list) || []) as T[]; +} + +export class List { + [Symbol.iterator]() { + return this.values(); + } + + get size(): number { + return getListItems(this).length; + } + + constructor(source?: Iterable | ArrayLike) { + listItems.set(this, []); + + if (source) { + if (isArrayLike(source)) { + for (let i = 0; i < source.length; i++) { + this.add(source[i]); + } + } else if (isIterable(source)) { + for (const item of source) { + this.add(item); + } + } + } + } + + add(value: T): this { + getListItems(this).push(value); + return this; + } + + clear(): void { + listItems.set(this, []); + } + + delete(idx: number): boolean { + if (idx < this.size) { + getListItems(this).splice(idx, 1); + return true; + } + + return false; + } + + entries(): IterableIterator<[number, T]> { + return new ShimIterator<[number, T]>(getListItems(this).map<[number, T]>((value, index) => [index, value])); + } + + forEach(fn: (value: T, idx: number, list: this) => void, thisArg?: any): void { + getListItems(this).forEach(fn.bind(thisArg ? thisArg : this)); + } + + has(idx: number): boolean { + return this.size > idx; + } + + includes(value: T): boolean { + return getListItems(this).indexOf(value) >= 0; + } + + indexOf(value: T): number { + return getListItems(this).indexOf(value); + } + + join(separator: string = ','): string { + return getListItems(this).join(separator); + } + + keys(): IterableIterator { + return new ShimIterator(getListItems(this).map((_, index) => index)); + } + + lastIndexOf(value: T): number { + return getListItems(this).lastIndexOf(value); + } + + push(value: T): void { + this.add(value); + } + + pop(): T | undefined { + return getListItems(this).pop(); + } + + splice(start: number, deleteCount?: number, ...newItems: T[]): T[] { + return getListItems(this).splice( + start, + deleteCount === undefined ? this.size - start : deleteCount, + ...newItems + ); + } + + values(): IterableIterator { + return new ShimIterator(getListItems(this).map((value) => value)); + } +} + +export default List; diff --git a/src/lib/core/src/MatchRegistry.ts b/src/lib/core/src/MatchRegistry.ts new file mode 100644 index 0000000..5fce5f9 --- /dev/null +++ b/src/lib/core/src/MatchRegistry.ts @@ -0,0 +1,89 @@ +import { Handle } from './interfaces'; + +/** + * An entry in a MatchRegistry. Each Entry contains a test to determine whether the Entry is applicable, and a value for + * the entry. + */ +interface Entry { + readonly test: Test | null; + readonly value: T | null; +} + +/** + * A registry of values tagged with matchers. + */ +export class MatchRegistry { + protected _defaultValue: T | undefined; + private readonly _entries: Entry[] | null; + + /** + * Construct a new MatchRegistry, optionally containing a given default value. + */ + constructor(defaultValue?: T) { + this._defaultValue = defaultValue; + this._entries = []; + } + + /** + * Return the first entry in this registry that matches the given arguments. If no entry matches and the registry + * was created with a default value, that value will be returned. Otherwise, an exception is thrown. + * + * @param ...args Arguments that will be used to select a matching value. + * @returns the matching value, or a default value if one exists. + */ + match(...args: any[]): T { + const entries = this._entries ? this._entries.slice(0) : []; + let entry: Entry; + + for (let i = 0; (entry = entries[i]); ++i) { + if (entry.value && entry.test && entry.test.apply(null, args)) { + return entry.value; + } + } + + if (this._defaultValue !== undefined) { + return this._defaultValue; + } + + throw new Error('No match found'); + } + + /** + * Register a test + value pair with this registry. + * + * @param test The test that will be used to determine if the registered value matches a set of arguments. + * @param value A value being registered. + * @param first If true, the newly registered test and value will be the first entry in the registry. + */ + register(test: Test | null, value: T | null, first?: boolean): Handle { + let entries = this._entries; + let entry: Entry | null = { + test: test, + value: value + }; + + (entries)[first ? 'unshift' : 'push'](entry); + + return { + destroy: function(this: Handle) { + this.destroy = function(): void {}; + let i = 0; + if (entries && entry) { + while ((i = entries.indexOf(entry, i)) > -1) { + entries.splice(i, 1); + } + } + test = value = entries = entry = null; + } + }; + } +} + +/** + * The interface that a test function must implement. + */ +export interface Test { + (...args: any[]): boolean | null; +} + +export default MatchRegistry; diff --git a/src/lib/core/src/MultiMap.ts b/src/lib/core/src/MultiMap.ts new file mode 100644 index 0000000..d64b7a3 --- /dev/null +++ b/src/lib/core/src/MultiMap.ts @@ -0,0 +1,237 @@ +import { from as arrayFrom } from '@dojo/shim/array'; +import { isArrayLike, isIterable, Iterable, IterableIterator, ShimIterator } from '@dojo/shim/iterator'; +import Map from '@dojo/shim/Map'; +import '@dojo/shim/Symbol'; + +/** + * A map implmentation that supports multiple keys for specific value. + * + * @param T Accepts the type of the value + */ +export class MultiMap implements Map { + private _map: Map; + private _key: symbol; + + /** + * @constructor + * + * @param iterator an array or iterator of tuples to initialize the map with. + */ + constructor(iterable?: ArrayLike<[any[], T]> | Iterable<[any[], T]>) { + this._map = new Map(); + this._key = Symbol(); + if (iterable) { + if (isArrayLike(iterable)) { + for (let i = 0; i < iterable.length; i++) { + const value = iterable[i]; + this.set(value[0], value[1]); + } + } else if (isIterable(iterable)) { + for (const value of iterable) { + this.set(value[0], value[1]); + } + } + } + } + + /** + * Sets the value for the array of keys provided + * + * @param keys The array of keys to store the value against + * @param value the value of the map entry + * + * @return the multi map instance + */ + set(keys: any[], value: T): this { + let map = this._map; + let childMap; + + for (let i = 0; i < keys.length; i++) { + if (map.get(keys[i])) { + map = map.get(keys[i]); + continue; + } + childMap = new Map(); + map.set(keys[i], childMap); + map = childMap; + } + + map.set(this._key, value); + return this; + } + + /** + * Returns the value entry for the array of keys + * + * @param keys The array of keys to look up the value for + * + * @return The value if found otherwise `undefined` + */ + get(keys: any[]): T | undefined { + let map = this._map; + + for (let i = 0; i < keys.length; i++) { + map = map.get(keys[i]); + + if (!map) { + return undefined; + } + } + + return map.get(this._key); + } + + /** + * Returns a boolean indicating if the key exists in the map + * + * @return boolean true if the key exists otherwise false + */ + has(keys: any[]): boolean { + let map = this._map; + + for (let i = 0; i < keys.length; i++) { + map = map.get(keys[i]); + if (!map) { + return false; + } + } + return true; + } + + /** + * Returns the size of the map, based on the number of unique keys + */ + get size(): number { + return arrayFrom(this.keys()).length; + } + + /** + * Deletes the entry for the key provided. + * + * @param keys the key of the entry to remove + * @return boolean trus if the entry was deleted, false if the entry was not found + */ + delete(keys: any[]): boolean { + let map = this._map; + const path = [this._map]; + + for (let i = 0; i < keys.length; i++) { + map = map.get(keys[i]); + path.push(map); + if (!map) { + return false; + } + } + + map.delete(this._key); + + for (let i = keys.length - 1; i >= 0; i--) { + map = path[i].get(keys[i]); + if (map.size) { + break; + } + path[i].delete(keys[i]); + } + + return true; + } + + /** + * Return an iterator that yields each value in the map + * + * @return An iterator containing the instance's values. + */ + values(): IterableIterator { + const values: T[] = []; + + const getValues = (map: Map) => { + map.forEach((value, key) => { + if (key === this._key) { + values.push(value); + } else { + getValues(value); + } + }); + }; + + getValues(this._map); + return new ShimIterator(values); + } + + /** + * Return an iterator that yields each key array in the map + * + * @return An iterator containing the instance's keys. + */ + keys(): IterableIterator { + const finalKeys: any[][] = []; + + const getKeys = (map: Map, keys: any[] = []) => { + map.forEach((value, key) => { + if (key === this._key) { + finalKeys.push(keys); + } else { + const nextKeys = [...keys, key]; + getKeys(value, nextKeys); + } + }); + }; + + getKeys(this._map); + return new ShimIterator(finalKeys); + } + + /** + * Returns an iterator that yields each key/value pair as an array. + * + * @return An iterator for each key/value pair in the instance. + */ + entries(): IterableIterator<[any[], T]> { + const finalEntries: [any[], T][] = []; + + const getKeys = (map: Map, keys: any[] = []) => { + map.forEach((value, key) => { + if (key === this._key) { + finalEntries.push([keys, value]); + } else { + const nextKeys = [...keys, key]; + getKeys(value, nextKeys); + } + }); + }; + + getKeys(this._map); + return new ShimIterator<[any[], T]>(finalEntries); + } + + /** + * Executes a given function for each map entry. The function + * is invoked with three arguments: the element value, the + * element key, and the associated Map instance. + * + * @param callback The function to execute for each map entry, + * @param context The value to use for `this` for each execution of the calback + */ + forEach(callback: (value: T, key: any[], mapInstance: MultiMap) => any, context?: {}): void { + const entries = this.entries(); + + for (const value of entries) { + callback.call(context, value[1], value[0], this); + } + } + + /** + * Deletes all keys and their associated values. + */ + clear(): void { + this._map.clear(); + } + + [Symbol.iterator](): IterableIterator<[any[], T]> { + return this.entries(); + } + + [Symbol.toStringTag] = 'MultiMap'; +} + +export default MultiMap; diff --git a/src/lib/core/src/Observable.ts b/src/lib/core/src/Observable.ts new file mode 100644 index 0000000..844a6de --- /dev/null +++ b/src/lib/core/src/Observable.ts @@ -0,0 +1,171 @@ +import ObservableShim, { ObservableObject, Subscribable, SubscriptionObserver } from '@dojo/shim/Observable'; +import Promise from '@dojo/shim/Promise'; +import { Iterable } from '@dojo/shim/iterator'; + +function isSubscribable(object: any): object is Subscribable { + return object && object.subscribe !== undefined; +} + +export default class Observable extends ObservableShim { + static of(...items: T[]): Observable { + return >super.of(...items); + } + + static from(item: Iterable | ArrayLike | ObservableObject): Observable { + return >super.from(item); + } + + static defer(deferFunction: () => Subscribable): Observable { + return new Observable((observer) => { + const trueObservable = deferFunction(); + + return trueObservable.subscribe({ + next(value: T) { + return observer.next(value); + }, + error(errorValue?: any) { + return observer.error(errorValue); + }, + complete(completeValue?: any) { + observer.complete(completeValue); + } + }); + }); + } + + toPromise(): Promise { + return new Promise((resolve, reject) => { + this.subscribe({ + next(value: T) { + resolve(value); + }, + error(error: any) { + reject(error); + } + }); + }); + } + + map(mapFunction: (x: T) => U): Observable { + const self = this; + + if (typeof mapFunction !== 'function') { + throw new TypeError('Map parameter must be a function'); + } + + return new Observable((observer: SubscriptionObserver) => { + self.subscribe({ + next(value: T) { + try { + const result: U = mapFunction(value); + return observer.next(result); + } catch (e) { + return observer.error(e); + } + }, + error(errorValue?: any) { + return observer.error(errorValue); + }, + complete(completeValue?: any) { + return observer.complete(completeValue); + } + }); + }); + } + + filter(filterFunction: (x: T) => boolean): Observable { + const self = this; + + if (typeof filterFunction !== 'function') { + throw new TypeError('Filter argument must be a function'); + } + + return new Observable((observer: SubscriptionObserver) => { + self.subscribe({ + next(value: T) { + try { + if (filterFunction(value)) { + return observer.next(value); + } + } catch (e) { + return observer.error(e); + } + }, + error(errorValue?: any) { + return observer.error(errorValue); + }, + complete(completeValue?: any) { + return observer.complete(completeValue); + } + }); + }); + } + + toArray(): Observable { + const self = this; + + return new Observable((observer) => { + const values: T[] = []; + + self.subscribe({ + next(value: T) { + values.push(value); + }, + error(errorValue?: any) { + return observer.error(errorValue); + }, + complete(completeValue?: any) { + observer.next(values); + observer.complete(completeValue); + } + }); + }); + } + + mergeAll(concurrent: number): Observable { + const self = this; + + return new Observable>((observer) => { + let active: any[] = []; + let queue: any[] = []; + + function checkForComplete() { + if (active.length === 0 && queue.length === 0) { + observer.complete(); + } else if (queue.length > 0 && active.length < concurrent) { + const item = queue.shift(); + + if (isSubscribable(item)) { + const itemIndex = active.length; + active.push(item); + + item.subscribe({ + next(value: any) { + observer.next(value); + }, + complete() { + active.splice(itemIndex, 1); + checkForComplete(); + } + }); + } else { + observer.next(item); + checkForComplete(); + } + } + } + + self.subscribe({ + next(value: T) { + queue.push(value); + }, + complete() { + checkForComplete(); + } + }); + }); + } +} + +// for convienence, re-export some interfaces from shim +export { Observable, Subscribable, SubscriptionObserver as Observer }; diff --git a/src/lib/core/src/QueuingEvented.ts b/src/lib/core/src/QueuingEvented.ts new file mode 100644 index 0000000..6defd3d --- /dev/null +++ b/src/lib/core/src/QueuingEvented.ts @@ -0,0 +1,71 @@ +import { Handle, EventObject, EventType } from './interfaces'; +import Map from '@dojo/shim/Map'; +import Evented, { CustomEventTypes, isGlobMatch, EventedCallbackOrArray } from './Evented'; + +/** + * An implementation of the Evented class that queues up events when no listeners are + * listening. When a listener is subscribed, the queue will be published to the listener. + * When the queue is full, the oldest events will be discarded to make room for the newest ones. + * + * @property maxEvents The number of events to queue before old events are discarded. If zero (default), an unlimited number of events is queued. + */ +class QueuingEvented< + M extends CustomEventTypes = {}, + T = EventType, + O extends EventObject = EventObject +> extends Evented { + private _queue: Map = new Map(); + + public maxEvents = 0; + + emit(event: M[K]): void; + emit(event: O): void; + emit(event: any): void { + super.emit(event); + + let hasMatch = false; + + this.listenersMap.forEach((method, type) => { + // Since `type` is generic, the compiler doesn't know what type it is and `isGlobMatch` requires `string | symbol` + if (isGlobMatch(type as any, event.type)) { + hasMatch = true; + } + }); + + if (!hasMatch) { + let queue = this._queue.get(event.type); + + if (!queue) { + queue = []; + this._queue.set(event.type, queue); + } + + queue.push(event); + + if (this.maxEvents > 0) { + while (queue.length > this.maxEvents) { + queue.shift(); + } + } + } + } + + on(type: K, listener: EventedCallbackOrArray): Handle; + on(type: T, listener: EventedCallbackOrArray): Handle; + on(type: any, listener: EventedCallbackOrArray): Handle { + let handle = super.on(type, listener); + + this.listenersMap.forEach((method, listenerType) => { + this._queue.forEach((events, queuedType) => { + if (isGlobMatch(listenerType as any, queuedType)) { + events.forEach((event) => this.emit(event)); + this._queue.delete(queuedType); + } + }); + }); + + return handle; + } +} + +export default QueuingEvented; diff --git a/src/lib/core/src/Scheduler.ts b/src/lib/core/src/Scheduler.ts new file mode 100644 index 0000000..b33ee29 --- /dev/null +++ b/src/lib/core/src/Scheduler.ts @@ -0,0 +1,115 @@ +import { Handle } from './interfaces'; +import { QueueItem, queueTask } from './queue'; + +function getQueueHandle(item: QueueItem): Handle { + return { + destroy: function(this: Handle) { + this.destroy = function() {}; + item.isActive = false; + item.callback = null; + } + }; +} + +export interface KwArgs { + deferWhileProcessing?: boolean; + queueFunction?: (callback: (...args: any[]) => any) => Handle; +} + +export class Scheduler { + protected readonly _boundDispatch: () => void; + protected _deferred: QueueItem[] | null = null; + protected _isProcessing: boolean; + protected readonly _queue: QueueItem[]; + protected _task: Handle | null = null; + + /** + * Determines whether any callbacks registered during should be added to the current batch (`false`) + * or deferred until the next batch (`true`, default). + */ + deferWhileProcessing: boolean | undefined; + + /** + * Allows users to specify the function that should be used to schedule callbacks. + * If no function is provided, then `queueTask` will be used. + */ + queueFunction: (callback: (...args: any[]) => any) => Handle; + + protected _defer(callback: (...args: any[]) => void): Handle { + const item: QueueItem = { + isActive: true, + callback: callback + }; + + if (!this._deferred) { + this._deferred = []; + } + + this._deferred.push(item); + + return getQueueHandle(item); + } + + protected _dispatch(): void { + this._isProcessing = true; + if (this._task) { + this._task.destroy(); + this._task = null; + } + + const queue = this._queue; + let item: QueueItem | undefined; + + while ((item = queue.shift())) { + if (item.isActive && item.callback) { + item.callback(); + } + } + + this._isProcessing = false; + + let deferred: QueueItem[] | null = this._deferred; + if (deferred && deferred.length) { + this._deferred = null; + + let item: QueueItem | undefined; + while ((item = deferred.shift())) { + this._schedule(item); + } + } + } + + protected _schedule(item: QueueItem): void { + if (!this._task) { + this._task = this.queueFunction(this._boundDispatch); + } + + this._queue.push(item); + } + + constructor(kwArgs?: KwArgs) { + this.deferWhileProcessing = kwArgs && 'deferWhileProcessing' in kwArgs ? kwArgs.deferWhileProcessing : true; + this.queueFunction = kwArgs && kwArgs.queueFunction ? kwArgs.queueFunction : queueTask; + + this._boundDispatch = this._dispatch.bind(this); + this._isProcessing = false; + this._queue = []; + } + + schedule(callback: (...args: any[]) => void): Handle { + if (this._isProcessing && this.deferWhileProcessing) { + return this._defer(callback); + } + + const item: QueueItem = { + isActive: true, + callback: callback + }; + + this._schedule(item); + + return getQueueHandle(item); + } +} + +export default Scheduler; diff --git a/src/lib/core/src/UrlSearchParams.ts b/src/lib/core/src/UrlSearchParams.ts new file mode 100644 index 0000000..8688d37 --- /dev/null +++ b/src/lib/core/src/UrlSearchParams.ts @@ -0,0 +1,193 @@ +import { Hash } from './interfaces'; +import { duplicate } from './lang'; + +/** + * Object with string keys and string or string array values that describes a query string. + */ +export type ParamList = Hash; + +/** + * Parses a query string, returning a ParamList object. + */ +function parseQueryString(input: string): ParamList { + const query: Hash = {}; + const splits = input.split('&'); + + for (let i = 0; i < splits.length; i++) { + const entry = splits[i]; + const indexOfFirstEquals = entry.indexOf('='); + let key: string; + let value = ''; + + if (indexOfFirstEquals >= 0) { + key = entry.slice(0, indexOfFirstEquals); + value = entry.slice(indexOfFirstEquals + 1); + } else { + key = entry; + } + + key = key ? decodeURIComponent(key) : ''; + value = value ? decodeURIComponent(value) : ''; + + if (key in query) { + query[key].push(value); + } else { + query[key] = [value]; + } + } + return query; +} + +/** + * Represents a set of URL query search parameters. + */ +export class UrlSearchParams { + /** + * Constructs a new UrlSearchParams from a query string, an object of parameters and values, or another + * UrlSearchParams. + */ + constructor(input?: string | ParamList | UrlSearchParams) { + let list: ParamList = {}; + + if (input instanceof UrlSearchParams) { + // Copy the incoming UrlSearchParam's internal list + list = duplicate(input._list); + } else if (typeof input === 'object') { + // Copy the incoming object, assuming its property values are either arrays or strings + list = {}; + for (const key in input) { + const value = (input)[key]; + + if (Array.isArray(value)) { + list[key] = value.length ? value.slice() : ['']; + } else if (value == null) { + list[key] = ['']; + } else { + list[key] = [value]; + } + } + } else if (typeof input === 'string') { + // Parse the incoming string as a query string + list = parseQueryString(input); + } + + this._list = list as Hash; + } + + /** + * Maps property keys to arrays of values. The value for any property that has been set will be an array containing + * at least one item. Properties that have been deleted will have a value of 'undefined'. + */ + protected readonly _list: Hash; + + /** + * Appends a new value to the set of values for a key. + * @param key The key to add a value for + * @param value The value to add + */ + append(key: string, value: string): void { + if (!this.has(key)) { + this.set(key, value); + } else { + const values = this._list[key]; + if (values) { + values.push(value); + } + } + } + + /** + * Deletes all values for a key. + * @param key The key whose values are to be removed + */ + delete(key: string): void { + // Set to undefined rather than deleting the key, for better consistency across browsers. + // If a deleted key is re-added, most browsers put it at the end of iteration order, but IE maintains + // its original position. This approach maintains the original position everywhere. + this._list[key] = undefined; + } + + /** + * Returns the first value associated with a key. + * @param key The key to return the first value for + * @return The first string value for the key + */ + get(key: string): string | undefined { + if (!this.has(key)) { + return undefined; + } + const value = this._list[key]; + return value ? value[0] : undefined; + } + + /** + * Returns all the values associated with a key. + * @param key The key to return all values for + * @return An array of strings containing all values for the key + */ + getAll(key: string): string[] | undefined { + if (!this.has(key)) { + return undefined; + } + return this._list[key]; + } + + /** + * Returns true if a key has been set to any value, false otherwise. + * @param key The key to test for existence + * @return A boolean indicating if the key has been set + */ + has(key: string): boolean { + return Array.isArray(this._list[key]); + } + + /** + * Returns an array of all keys which have been set. + * @return An array of strings containing all keys set in the UrlSearchParams instance + */ + keys(): string[] { + const keys: string[] = []; + + for (const key in this._list) { + if (this.has(key)) { + keys.push(key); + } + } + + return keys; + } + + /** + * Sets the value associated with a key. + * @param key The key to set the value of + */ + set(key: string, value: string): void { + this._list[key] = [value]; + } + + /** + * Returns this object's data as an encoded query string. + * @return A string in application/x-www-form-urlencoded format containing all of the set keys/values + */ + toString(): string { + const query: string[] = []; + + for (const key in this._list) { + if (!this.has(key)) { + continue; + } + + const values = this._list[key]; + if (values) { + const encodedKey = encodeURIComponent(key); + for (let i = 0; i < values.length; i++) { + query.push(encodedKey + (values[i] ? '=' + encodeURIComponent(values[i]) : '')); + } + } + } + + return query.join('&'); + } +} + +export default UrlSearchParams; diff --git a/src/lib/core/src/aspect.ts b/src/lib/core/src/aspect.ts new file mode 100644 index 0000000..2917c3b --- /dev/null +++ b/src/lib/core/src/aspect.ts @@ -0,0 +1,531 @@ +import { Handle } from './interfaces'; +import WeakMap from '@dojo/shim/WeakMap'; +import { createHandle } from './lang'; + +/** + * An object that provides the necessary APIs to be MapLike + */ +export interface MapLike { + get(key: K): V; + set(key: K, value?: V): this; +} + +/** + * An internal type guard that determines if an value is MapLike or not + * + * @param value The value to guard against + */ +function isMapLike(value: any): value is MapLike { + return value && typeof value.get === 'function' && typeof value.set === 'function'; +} + +export interface Indexable { + [method: string]: any; +} + +/** + * The types of objects or maps where advice can be applied + */ +export type Targetable = MapLike | Indexable; + +type AdviceType = 'before' | 'after' | 'around'; + +/** + * A meta data structure when applying advice + */ +interface Advised { + readonly id?: number; + advice?: Function; + previous?: Advised; + next?: Advised; + readonly receiveArguments?: boolean; +} + +/** + * A function that dispatches advice which is decorated with additional + * meta data about the advice to apply + */ +interface Dispatcher { + [type: string]: Advised | undefined; + (): any; + target: any; + before?: Advised; + around?: Advised; + after?: Advised; +} + +export interface JoinPointDispatchAdvice { + before?: JoinPointBeforeAdvice[]; + after?: JoinPointAfterAdvice[]; + readonly joinPoint: Function; +} + +export interface JoinPointAfterAdvice { + /** + * Advice which is applied *after*, receiving the result and arguments from the join point. + * + * @param result The result from the function being advised + * @param args The arguments that were supplied to the advised function + * @returns The value returned from the advice is then the result of calling the method + */ + (result: T, ...args: any[]): T; +} + +export interface JoinPointAroundAdvice { + /** + * Advice which is applied *around*. The advising function receives the original function and + * needs to return a new function which will then invoke the original function. + * + * @param origFn The original function + * @returns A new function which will invoke the original function. + */ + (origFn: GenericFunction): (...args: any[]) => T; +} + +export interface JoinPointBeforeAdvice { + /** + * Advice which is applied *before*, receiving the original arguments, if the advising + * function returns a value, it is passed further along taking the place of the original + * arguments. + * + * @param args The arguments the method was called with + */ + (...args: any[]): any[] | void; +} + +export interface GenericFunction { + (...args: any[]): T; +} + +/** + * A weak map of dispatchers used to apply the advice + */ +const dispatchAdviceMap = new WeakMap>(); + +/** + * A UID for tracking advice ordering + */ +let nextId = 0; + +/** + * Internal function that advises a join point + * + * @param dispatcher The current advice dispatcher + * @param type The type of before or after advice to apply + * @param advice The advice to apply + * @param receiveArguments If true, the advice will receive the arguments passed to the join point + * @return The handle that will remove the advice + */ +function adviseObject( + dispatcher: Dispatcher | undefined, + type: AdviceType, + advice: Function | undefined, + receiveArguments?: boolean +): Handle { + let previous = dispatcher && dispatcher[type]; + let advised: Advised | undefined = { + id: nextId++, + advice: advice, + receiveArguments: receiveArguments + }; + + if (previous) { + if (type === 'after') { + // add the listener to the end of the list + // note that we had to change this loop a little bit to workaround a bizarre IE10 JIT bug + while (previous.next && (previous = previous.next)) {} + previous.next = advised; + advised.previous = previous; + } else { + // add to the beginning + if (dispatcher) { + dispatcher.before = advised; + } + advised.next = previous; + previous.previous = advised; + } + } else { + dispatcher && (dispatcher[type] = advised); + } + + advice = previous = undefined; + + return createHandle(function() { + let { previous = undefined, next = undefined } = advised || {}; + + if (dispatcher && !previous && !next) { + dispatcher[type] = undefined; + } else { + if (previous) { + previous.next = next; + } else { + dispatcher && (dispatcher[type] = next); + } + + if (next) { + next.previous = previous; + } + } + if (advised) { + delete advised.advice; + } + dispatcher = advised = undefined; + }); +} + +/** + * Advise a join point (function) with supplied advice + * + * @param joinPoint The function to be advised + * @param type The type of advice to be applied + * @param advice The advice to apply + */ +function adviseJoinPoint, T>( + this: any, + joinPoint: F, + type: AdviceType, + advice: JoinPointBeforeAdvice | JoinPointAfterAdvice | JoinPointAroundAdvice +): F { + let dispatcher: F; + if (type === 'around') { + dispatcher = getJoinPointDispatcher(advice.apply(this, [joinPoint])); + } else { + dispatcher = getJoinPointDispatcher(joinPoint); + // cannot have undefined in map due to code logic, using ! + const adviceMap = dispatchAdviceMap.get(dispatcher)!; + if (type === 'before') { + (adviceMap.before || (adviceMap.before = [])).unshift(advice); + } else { + (adviceMap.after || (adviceMap.after = [])).push(advice); + } + } + return dispatcher; +} + +/** + * An internal function that resolves or creates the dispatcher for a given join point + * + * @param target The target object or map + * @param methodName The name of the method that the dispatcher should be resolved for + * @return The dispatcher + */ +function getDispatcherObject(target: Targetable, methodName: string | symbol): Dispatcher { + const existing = isMapLike(target) ? target.get(methodName) : target && target[methodName]; + let dispatcher: Dispatcher; + + if (!existing || existing.target !== target) { + /* There is no existing dispatcher, therefore we will create one */ + dispatcher = function(this: Dispatcher): any { + let executionId = nextId; + let args = arguments; + let results: any; + let before = dispatcher.before; + + while (before) { + if (before.advice) { + args = before.advice.apply(this, args) || args; + } + before = before.next; + } + + if (dispatcher.around && dispatcher.around.advice) { + results = dispatcher.around.advice(this, args); + } + + let after = dispatcher.after; + while (after && after.id !== undefined && after.id < executionId) { + if (after.advice) { + if (after.receiveArguments) { + let newResults = after.advice.apply(this, args); + results = newResults === undefined ? results : newResults; + } else { + results = after.advice.call(this, results, args); + } + } + after = after.next; + } + + return results; + }; + + if (isMapLike(target)) { + target.set(methodName, dispatcher); + } else { + target && (target[methodName] = dispatcher); + } + + if (existing) { + dispatcher.around = { + advice: function(target: any, args: any[]): any { + return existing.apply(target, args); + } + }; + } + + dispatcher.target = target; + } else { + dispatcher = existing; + } + + return dispatcher; +} + +/** + * Returns the dispatcher function for a given joinPoint (method/function) + * + * @param joinPoint The function that is to be advised + */ +function getJoinPointDispatcher, T>(joinPoint: F): F { + function dispatcher(this: Function, ...args: any[]): T { + // cannot have undefined in map due to code logic, using ! + const { before, after, joinPoint } = dispatchAdviceMap.get(dispatcher)!; + if (before) { + args = before.reduce((previousArgs, advice) => { + const currentArgs = advice.apply(this, previousArgs); + return currentArgs || previousArgs; + }, args); + } + let result = joinPoint.apply(this, args); + if (after) { + result = after.reduce((previousResult, advice) => { + return advice.apply(this, [previousResult].concat(args)); + }, result); + } + return result; + } + + /* We want to "clone" the advice that has been applied already, if this + * joinPoint is already advised */ + if (dispatchAdviceMap.has(joinPoint)) { + // cannot have undefined in map due to code logic, using ! + const adviceMap = dispatchAdviceMap.get(joinPoint)!; + let { before, after } = adviceMap; + if (before) { + before = before.slice(0); + } + if (after) { + after = after.slice(0); + } + dispatchAdviceMap.set(dispatcher, { + joinPoint: adviceMap.joinPoint, + before, + after + }); + } else { + /* Otherwise, this is a new joinPoint, so we will create the advice map afresh */ + dispatchAdviceMap.set(dispatcher, { joinPoint }); + } + + return dispatcher as F; +} + +/** + * Apply advice *after* the supplied joinPoint (function) + * + * @param joinPoint A function that should have advice applied to + * @param advice The after advice + */ +function afterJoinPoint, T>(joinPoint: F, advice: JoinPointAfterAdvice): F { + return adviseJoinPoint(joinPoint, 'after', advice); +} + +/** + * Attaches "after" advice to be executed after the original method. + * The advising function will receive the original method's return value and arguments object. + * The value it returns will be returned from the method when it is called (even if the return value is undefined). + * + * @param target Object whose method will be aspected + * @param methodName Name of method to aspect + * @param advice Advising function which will receive the original method's return value and arguments object + * @return A handle which will remove the aspect when destroy is called + */ +function afterObject( + target: Targetable, + methodName: string | symbol, + advice: (originalReturn: any, originalArgs: IArguments) => any +): Handle { + return adviseObject(getDispatcherObject(target, methodName), 'after', advice); +} + +/** + * Attaches "after" advice to be executed after the original method. + * The advising function will receive the original method's return value and arguments object. + * The value it returns will be returned from the method when it is called (even if the return value is undefined). + * + * @param target Object whose method will be aspected + * @param methodName Name of method to aspect + * @param advice Advising function which will receive the original method's return value and arguments object + * @return A handle which will remove the aspect when destroy is called + */ +export function after( + target: Targetable, + methodName: string | symbol, + advice: (originalReturn: any, originalArgs: IArguments) => any +): Handle; +/** + * Apply advice *after* the supplied joinPoint (function) + * + * @param joinPoint A function that should have advice applied to + * @param advice The after advice + */ +export function after, T>(joinPoint: F, advice: JoinPointAfterAdvice): F; +export function after, T>( + joinPointOrTarget: F | Targetable, + methodNameOrAdvice: string | symbol | JoinPointAfterAdvice, + objectAdvice?: (originalReturn: any, originalArgs: IArguments) => any +): Handle | F { + if (typeof joinPointOrTarget === 'function') { + return afterJoinPoint(joinPointOrTarget, >methodNameOrAdvice); + } else { + return afterObject(joinPointOrTarget, methodNameOrAdvice, objectAdvice!); + } +} + +/** + * Apply advice *around* the supplied joinPoint (function) + * + * @param joinPoint A function that should have advice applied to + * @param advice The around advice + */ +export function aroundJoinPoint, T>(joinPoint: F, advice: JoinPointAroundAdvice): F { + return adviseJoinPoint(joinPoint, 'around', advice); +} + +/** + * Attaches "around" advice around the original method. + * + * @param target Object whose method will be aspected + * @param methodName Name of method to aspect + * @param advice Advising function which will receive the original function + * @return A handle which will remove the aspect when destroy is called + */ +export function aroundObject( + target: Targetable, + methodName: string | symbol, + advice: ((previous: Function) => Function) +): Handle { + let dispatcher: Dispatcher | undefined = getDispatcherObject(target, methodName); + let previous = dispatcher.around; + let advised: Function | undefined; + if (advice) { + advised = advice(function(this: Dispatcher): any { + if (previous && previous.advice) { + return previous.advice(this, arguments); + } + }); + } + + dispatcher.around = { + advice: function(target: any, args: any[]): any { + return advised ? advised.apply(target, args) : previous && previous.advice && previous.advice(target, args); + } + }; + + return createHandle(function() { + advised = dispatcher = undefined; + }); +} + +/** + * Attaches "around" advice around the original method. + * + * @param target Object whose method will be aspected + * @param methodName Name of method to aspect + * @param advice Advising function which will receive the original function + * @return A handle which will remove the aspect when destroy is called + */ +export function around( + target: Targetable, + methodName: string | symbol, + advice: ((previous: Function) => Function) +): Handle; +/** + * Apply advice *around* the supplied joinPoint (function) + * + * @param joinPoint A function that should have advice applied to + * @param advice The around advice + */ +export function around, T>(joinPoint: F, advice: JoinPointAroundAdvice): F; +export function around, T>( + joinPointOrTarget: F | Targetable, + methodNameOrAdvice: string | symbol | JoinPointAroundAdvice, + objectAdvice?: ((previous: Function) => Function) +): Handle | F { + if (typeof joinPointOrTarget === 'function') { + return aroundJoinPoint(joinPointOrTarget, >methodNameOrAdvice); + } else { + return aroundObject(joinPointOrTarget, methodNameOrAdvice, objectAdvice!); + } +} + +/** + * Apply advice *before* the supplied joinPoint (function) + * + * @param joinPoint A function that should have advice applied to + * @param advice The before advice + */ +export function beforeJoinPoint>(joinPoint: F, advice: JoinPointBeforeAdvice): F { + return adviseJoinPoint(joinPoint, 'before', advice); +} + +/** + * Attaches "before" advice to be executed before the original method. + * + * @param target Object whose method will be aspected + * @param methodName Name of method to aspect + * @param advice Advising function which will receive the same arguments as the original, and may return new arguments + * @return A handle which will remove the aspect when destroy is called + */ +export function beforeObject( + target: Targetable, + methodName: string | symbol, + advice: (...originalArgs: any[]) => any[] | void +): Handle { + return adviseObject(getDispatcherObject(target, methodName), 'before', advice); +} + +/** + * Attaches "before" advice to be executed before the original method. + * + * @param target Object whose method will be aspected + * @param methodName Name of method to aspect + * @param advice Advising function which will receive the same arguments as the original, and may return new arguments + * @return A handle which will remove the aspect when destroy is called + */ +export function before( + target: Targetable, + methodName: string | symbol, + advice: (...originalArgs: any[]) => any[] | void +): Handle; +/** + * Apply advice *before* the supplied joinPoint (function) + * + * @param joinPoint A function that should have advice applied to + * @param advice The before advice + */ +export function before>(joinPoint: F, advice: JoinPointBeforeAdvice): F; +export function before, T>( + joinPointOrTarget: F | Targetable, + methodNameOrAdvice: string | symbol | JoinPointBeforeAdvice, + objectAdvice?: ((...originalArgs: any[]) => any[] | void) +): Handle | F { + if (typeof joinPointOrTarget === 'function') { + return beforeJoinPoint(joinPointOrTarget, methodNameOrAdvice); + } else { + return beforeObject(joinPointOrTarget, methodNameOrAdvice, objectAdvice!); + } +} + +/** + * Attaches advice to be executed after the original method. + * The advising function will receive the same arguments as the original method. + * The value it returns will be returned from the method when it is called *unless* its return value is undefined. + * + * @param target Object whose method will be aspected + * @param methodName Name of method to aspect + * @param advice Advising function which will receive the same arguments as the original method + * @return A handle which will remove the aspect when destroy is called + */ +export function on(target: Targetable, methodName: string | symbol, advice: (...originalArgs: any[]) => any): Handle { + return adviseObject(getDispatcherObject(target, methodName), 'after', advice, true); +} diff --git a/src/lib/core/src/async/ExtensiblePromise.ts b/src/lib/core/src/async/ExtensiblePromise.ts new file mode 100644 index 0000000..cb5664a --- /dev/null +++ b/src/lib/core/src/async/ExtensiblePromise.ts @@ -0,0 +1,249 @@ +import { Thenable } from '@dojo/shim/interfaces'; +import { isArrayLike, isIterable, Iterable } from '@dojo/shim/iterator'; +import Promise, { Executor } from '@dojo/shim/Promise'; +import '@dojo/shim/Symbol'; + +/** + * Take a list of values, and if any are ExtensiblePromise objects, insert the wrapped Promise in its place, + * otherwise use the original object. We use this to help use the native Promise methods like `all` and `race`. + * + * @param iterable The list of objects to iterate over + * @returns {any[]} The list of objects, as an array, with ExtensiblePromises being replaced by Promises. + */ +export function unwrapPromises(iterable: Iterable | any[]): any[] { + const unwrapped: any[] = []; + + if (isArrayLike(iterable)) { + for (let i = 0; i < iterable.length; i++) { + const item = iterable[i]; + unwrapped.push(item instanceof ExtensiblePromise ? item._promise : item); + } + } else { + for (const item of iterable) { + unwrapped.push(item instanceof ExtensiblePromise ? item._promise : item); + } + } + + return unwrapped; +} + +export type DictionaryOfPromises = { [_: string]: T | Promise | Thenable }; +export type ListOfPromises = Iterable>; + +/** + * An extensible base to allow Promises to be extended in ES5. This class basically wraps a native Promise object, + * giving an API like a native promise. + */ +export class ExtensiblePromise { + /** + * Return a rejected promise wrapped in an ExtensiblePromise + * + * @param reason The reason for the rejection + * @returns An extensible promise + */ + static reject(reason?: any): ExtensiblePromise; + + /** + * Return a rejected promise wrapped in an ExtensiblePromise + * + * @param reason The reason for the rejection + * @returns An extensible promise + */ + static reject(reason?: any): ExtensiblePromise { + return new this((resolve, reject) => reject(reason)); + } + + /** + * Return a resolved promise wrapped in an ExtensiblePromise + * + * @param value The value to resolve the promise with + * + * @returns An extensible promise + */ + static resolve

>(): P; + + /** + * Return a resolved promise wrapped in an ExtensiblePromise + * + * @param value The value to resolve the promise with + * + * @returns An extensible promise + */ + static resolve>(value: T | PromiseLike): P; + static resolve(value?: any | PromiseLike): ExtensiblePromise { + return new this((resolve, reject) => resolve(value)); + } + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all(iterable: DictionaryOfPromises): ExtensiblePromise<{ [key: string]: T }>; + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all(iterable: (T | Thenable)[]): ExtensiblePromise; + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all(iterable: T | Thenable): ExtensiblePromise; + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all(iterable: ListOfPromises): ExtensiblePromise; + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all( + iterable: DictionaryOfPromises | ListOfPromises + ): ExtensiblePromise { + if (!isArrayLike(iterable) && !isIterable(iterable)) { + const promiseKeys = Object.keys(iterable); + + return new this((resolve, reject) => { + Promise.all(promiseKeys.map((key) => iterable[key])).then((promiseResults: T[]) => { + const returnValue: { [key: string]: T } = {}; + + promiseResults.forEach((value: T, index: number) => { + returnValue[promiseKeys[index]] = value; + }); + + resolve(returnValue); + }, reject); + }); + } + + return new this((resolve, reject) => { + Promise.all(unwrapPromises(>iterable)).then(resolve, reject); + }); + } + + /** + * Return a ExtensiblePromise that resolves when one of the passed in objects have resolved + * + * @param iterable An iterable of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns {ExtensiblePromise} + */ + static race(iterable: Iterable> | (T | PromiseLike)[]): ExtensiblePromise { + return new this((resolve, reject) => { + Promise.race(unwrapPromises(iterable)).then(resolve, reject); + }); + } + + /** + * @type {Promise} + * The wrapped promise + */ + readonly _promise: Promise; + + /** + * Creates a new extended Promise. + * + * @constructor + * + * @param executor + * The executor function is called immediately when the Promise is instantiated. It is responsible for + * starting the asynchronous operation when it is invoked. + * + * The executor must call either the passed `resolve` function when the asynchronous operation has completed + * successfully, or the `reject` function when the operation fails. + */ + constructor(executor: Executor) { + this._promise = new Promise(executor); + } + + /** + * Adds a callback to be invoked when the wrapped Promise is rejected. + * + * @param {Function} onRejected A function to call to handle the error. The parameter to the function will be the caught error. + * + * @returns {ExtensiblePromise} + */ + catch( + onRejected?: ((reason: any) => TResult | PromiseLike) | undefined | null + ): ExtensiblePromise { + return this.then(undefined, onRejected); + } + + /** + * Adds a callback to be invoked when the wrapped Promise resolves or is rejected. + * + * @param {Function} onFulfilled A function to call to handle the resolution. The paramter to the function will be the resolved value, if any. + * @param {Function} onRejected A function to call to handle the error. The parameter to the function will be the caught error. + * + * @returns {ExtensiblePromise} + */ + then( + onFulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, + onRejected?: ((reason: any) => TResult2 | PromiseLike | void) | undefined | null + ): ExtensiblePromise { + const executor: Executor = (resolve, reject) => { + function handler(rejected: boolean, valueOrError: T | TResult1 | Error) { + const callback: ((value: any) => any) | null | undefined = rejected ? onRejected : onFulfilled; + + if (typeof callback === 'function') { + try { + resolve(callback(valueOrError)); + } catch (error) { + reject(error); + } + } else if (rejected) { + reject(valueOrError); + } else { + resolve(valueOrError as TResult1); + } + } + + this._promise.then(handler.bind(null, false), handler.bind(null, true)); + }; + + return new (this.constructor as typeof ExtensiblePromise)(executor); + } + + readonly [Symbol.toStringTag]: 'Promise'; +} + +export default ExtensiblePromise; diff --git a/src/lib/core/src/async/Task.ts b/src/lib/core/src/async/Task.ts new file mode 100644 index 0000000..e555533 --- /dev/null +++ b/src/lib/core/src/async/Task.ts @@ -0,0 +1,384 @@ +import { Thenable } from '@dojo/shim/interfaces'; +import { isArrayLike, isIterable, Iterable } from '@dojo/shim/iterator'; +import { Executor } from '@dojo/shim/Promise'; +import ExtensiblePromise, { DictionaryOfPromises, ListOfPromises, unwrapPromises } from './ExtensiblePromise'; + +/** + * Describe the internal state of a task. + */ +export const enum State { + Fulfilled = 0, + Pending = 1, + Rejected = 2, + Canceled = 3 +} + +/** + * A type guard that determines if `value` is a `Task` + * @param value The value to guard + */ +export function isTask(value: any): value is Task { + return Boolean(value && typeof value.cancel === 'function' && Array.isArray(value.children) && isThenable(value)); +} + +/** + * Returns true if a given value has a `then` method. + * @param {any} value The value to check if is Thenable + * @returns {is Thenable} A type guard if the value is thenable + */ +export function isThenable(value: any): value is Thenable { + return value && typeof value.then === 'function'; +} + +/** + * Task is an extension of Promise that supports cancellation and the Task#finally method. + */ +export class Task extends ExtensiblePromise { + /** + * Return a Task that resolves when one of the passed in objects have resolved + * + * @param iterable An iterable of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns {Task} + */ + static race(iterable: Iterable> | (T | Thenable)[]): Task { + return new this((resolve, reject) => { + Promise.race(unwrapPromises(iterable)).then(resolve, reject); + }); + } + + /** + * Return a rejected promise wrapped in a Task + * + * @param reason The reason for the rejection + * @returns A task + */ + static reject(reason?: Error): Task { + return new this((resolve, reject) => reject(reason)); + } + + /** + * Return a resolved task. + * + * @param value The value to resolve with + * + * @return A task + */ + public static resolve(): Task; + + /** + * Return a resolved task. + * + * @param value The value to resolve with + * + * @return A task + */ + public static resolve(value: T | Thenable): Task; + + /** + * Return a resolved task. + * + * @param value The value to resolve with + * + * @return A task + */ + public static resolve(value?: any): Task { + return new this((resolve, reject) => resolve(value)); + } + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all(iterable: DictionaryOfPromises): Task<{ [key: string]: T }>; + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all(iterable: (T | Thenable)[]): Task; + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all(iterable: T | Thenable): Task; + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all(iterable: ListOfPromises): Task; + + /** + * Return a ExtensiblePromise that resolves when all of the passed in objects have resolved. When used with a key/value + * pair, the returned promise's argument is a key/value pair of the original keys with their resolved values. + * + * @example + * ExtensiblePromise.all({ one: 1, two: 2 }).then(results => console.log(results)); + * // { one: 1, two: 2 } + * + * @param iterable An iterable of values to resolve, or a key/value pair of values to resolve. These can be Promises, ExtensiblePromises, or other objects + * @returns An extensible promise + */ + static all(iterable: DictionaryOfPromises | ListOfPromises): Task { + return new Task( + (resolve, reject) => { + super.all(iterable).then(resolve, reject); + }, + () => { + if (isArrayLike(iterable)) { + for (let i = 0; i < iterable.length; i++) { + const promiseLike = iterable[i]; + + if (isTask(promiseLike)) { + promiseLike.cancel(); + } + } + } else if (isIterable(iterable)) { + for (const promiseLike of iterable) { + if (isTask(promiseLike)) { + promiseLike.cancel(); + } + } + } else { + Object.keys(iterable).forEach((key: any) => { + const promiseLike = iterable[key]; + + if (isTask(promiseLike)) { + promiseLike.cancel(); + } + }); + } + } + ); + } + + /** + * A cancelation handler that will be called if this task is canceled. + */ + private canceler: () => void; + + /** + * Children of this Task (i.e., Tasks that were created from this Task with `then` or `catch`). + */ + private readonly children: Task[]; + + /** + * The finally callback for this Task (if it was created by a call to `finally`). + */ + private _finally: undefined | (() => void); + + /** + * The state of the task + */ + protected _state: State; + + get state() { + return this._state; + } + + /** + * @constructor + * + * Create a new task. Executor is run immediately. The canceler will be called when the task is canceled. + * + * @param executor Method that initiates some task + * @param canceler Method to call when the task is canceled + * + */ + constructor(executor: Executor, canceler?: () => void) { + // we have to initialize these to avoid a compiler error of using them before they are initialized + let superResolve: (value?: T | Thenable | undefined) => void = () => {}; + let superReject: (reason?: any) => void = () => {}; + + super((resolve, reject) => { + superResolve = resolve; + superReject = reject; + }); + + this._state = State.Pending; + + this.children = []; + this.canceler = () => { + if (canceler) { + canceler(); + } + this._cancel(); + }; + + // Don't let the Task resolve if it's been canceled + try { + executor( + (value) => { + if (this._state === State.Canceled) { + return; + } + this._state = State.Fulfilled; + superResolve(value); + }, + (reason) => { + if (this._state === State.Canceled) { + return; + } + this._state = State.Rejected; + superReject(reason); + } + ); + } catch (reason) { + this._state = State.Rejected; + superReject(reason); + } + } + + /** + * Propagates cancellation down through a Task tree. The Task's state is immediately set to canceled. If a Thenable + * finally task was passed in, it is resolved before calling this Task's finally callback; otherwise, this Task's + * finally callback is immediately executed. `_cancel` is called for each child Task, passing in the value returned + * by this Task's finally callback or a Promise chain that will eventually resolve to that value. + */ + private _cancel(finallyTask?: void | Thenable): void { + this._state = State.Canceled; + + const runFinally = () => { + try { + return this._finally && this._finally(); + } catch (error) { + // Any errors in a `finally` callback are completely ignored during cancelation + } + }; + + if (this._finally) { + if (isThenable(finallyTask)) { + finallyTask = (>finallyTask).then(runFinally, runFinally); + } else { + finallyTask = runFinally(); + } + } + + this.children.forEach(function(child) { + child._cancel(finallyTask); + }); + } + + /** + * Immediately cancels this task if it has not already resolved. This Task and any descendants are synchronously set + * to the Canceled state and any `finally` added downstream from the canceled Task are invoked. + */ + cancel(): void { + if (this._state === State.Pending) { + this.canceler(); + } + } + + catch( + onRejected?: ((reason: any) => TResult | PromiseLike) | undefined + ): Task { + return this.then(undefined, onRejected) as Task; + } + + /** + * Allows for cleanup actions to be performed after resolution of a Promise. + */ + finally(callback: () => void): Task { + // if this task is already canceled, call the task + if (this._state === State.Canceled) { + callback(); + return this; + } + + const task = this.then( + (value) => Task.resolve(callback()).then(() => value), + (reason) => + Task.resolve(callback()).then(() => { + throw reason; + }) + ); + + // Keep a reference to the callback; it will be called if the Task is canceled + task._finally = callback; + return task; + } + + /** + * Adds a callback to be invoked when the Task resolves or is rejected. + * + * @param onFulfilled A function to call to handle the resolution. The paramter to the function will be the resolved value, if any. + * @param onRejected A function to call to handle the error. The parameter to the function will be the caught error. + * + * @returns A task + */ + then( + onFulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, + onRejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null + ): Task { + // FIXME + // tslint:disable-next-line:no-var-keyword + var task = super.then( + // Don't call the onFulfilled or onRejected handlers if this Task is canceled + function(value) { + if (task._state === State.Canceled) { + return; + } + if (onFulfilled) { + return onFulfilled(value); + } + return value; + }, + function(error) { + if (task._state === State.Canceled) { + return; + } + if (onRejected) { + return onRejected(error); + } + throw error; + } + ) as Task; + + task.canceler = () => { + // If task's parent (this) hasn't been resolved, cancel it; downward propagation will start at the first + // unresolved parent + if (this._state === State.Pending) { + this.cancel(); + } else { + // If task's parent has been resolved, propagate cancelation to the task's descendants + task._cancel(); + } + }; + + // Keep track of child Tasks for propogating cancelation back down the chain + this.children.push(task); + + return task; + } +} + +export default Task; diff --git a/src/lib/core/src/async/iteration.ts b/src/lib/core/src/async/iteration.ts new file mode 100644 index 0000000..7756ab7 --- /dev/null +++ b/src/lib/core/src/async/iteration.ts @@ -0,0 +1,295 @@ +import * as array from '@dojo/shim/array'; +import { isArrayLike, Iterable } from '@dojo/shim/iterator'; +import Promise from '@dojo/shim/Promise'; +import { Thenable } from '@dojo/shim/interfaces'; + +function isThenable(value: any): value is Thenable { + return value && typeof value.then === 'function'; +} + +type ValuesAndResults = { values: T[] | undefined; results: U[] | undefined }; + +/** + * Processes all items and then applies the callback to each item and eventually returns an object containing the + * processed values and callback results + * @param items a list of synchronous/asynchronous values to process + * @param callback a callback that maps values to synchronous/asynchronous results + * @return a list of objects holding the synchronous values and synchronous results. + */ +function processValuesAndCallback( + items: Iterable> | (T | Thenable)[], + callback: Mapper +): Promise> { + return Promise.all(items).then(function(results) { + const pass: (U | Promise)[] = Array.prototype.map.call(results, callback); + return Promise.all(pass).then(function(pass) { + return { values: results, results: pass }; + }); + }); +} + +/** + * Finds the index of the next value in a sparse array-like object + * @param list the sparse array-like object + * @param offset the starting offset + * @return the offset of the next index with a value; or -1 if not found + */ +function findNextValueIndex(list: ArrayLike, offset: number = -1): number { + offset++; + for (let length = list.length; offset < length; offset++) { + if (offset in list) { + return offset; + } + } + return -1; +} + +function findLastValueIndex(list: ArrayLike, offset?: number): number { + offset = (offset === undefined ? list.length : offset) - 1; + for (; offset >= 0; offset--) { + if (offset in list) { + return offset; + } + } + return -1; +} + +function generalReduce( + findNextIndex: (list: ArrayLike, offset?: number) => number, + items: Iterable> | (T | Promise)[], + callback: Reducer, + initialValue?: U +): Promise { + const hasInitialValue = arguments.length > 3; + return Promise.all(items).then(function(results) { + return new Promise(function(resolve, reject) { + // As iterators do not have indices like `ArrayLike` objects, the results array + // is used to determine the next value. + const list = isArrayLike(items) ? items : results; + let i: number; + function next(currentValue: U | undefined): void { + i = findNextIndex(list, i); + if (i >= 0) { + if (results) { + if (currentValue) { + const result = callback(currentValue, results[i], i, results); + + if (isThenable(result)) { + result.then(next, reject); + } else { + next(result); + } + } + } + } else { + resolve(currentValue); + } + } + + let value: U | undefined; + if (hasInitialValue) { + value = initialValue; + } else { + i = findNextIndex(list); + + if (i < 0) { + throw new Error('reduce array with no initial value'); + } + if (results) { + value = results[i]; + } + } + next(value); + }); + }); +} + +function testAndHaltOnCondition( + condition: boolean, + items: Iterable> | (T | Promise)[], + callback: Filterer +): Promise { + return Promise.all(items).then(function(results) { + return new Promise(function(resolve) { + let result: boolean | Thenable; + let pendingCount = 0; + if (results) { + for (let i = 0; i < results.length; i++) { + result = callback(results[i], i, results); + if (result === condition) { + return resolve(result); + } else if (isThenable(result)) { + pendingCount++; + result.then(function(result) { + if (result === condition) { + resolve(result); + } + pendingCount--; + if (pendingCount === 0) { + resolve(!condition); + } + }); + } + } + } + if (pendingCount === 0) { + resolve(!condition); + } + }); + }); +} + +/** + * Test whether all elements in the array pass the provided callback + * @param items a collection of synchronous/asynchronous values + * @param callback a synchronous/asynchronous test + * @return eventually returns true if all values pass; otherwise false + */ +export function every( + items: Iterable> | (T | Promise)[], + callback: Filterer +): Promise { + return testAndHaltOnCondition(false, items, callback); +} + +/** + * Returns an array of elements which pass the provided callback + * @param items a collection of synchronous/asynchronous values + * @param callback a synchronous/asynchronous test + * @return eventually returns a new array with only values that have passed + */ +export function filter(items: Iterable> | (T | Promise)[], callback: Filterer): Promise { + return processValuesAndCallback(items, callback).then(function(result) { + let arr: T[] = []; + if (result && result.results && result.values) { + for (let i = 0; i < result.results.length; i++) { + result.results[i] && arr.push(result.values[i]); + } + } + return arr; + }); +} + +/** + * Find the first value matching a filter function + * @param items a collection of synchronous/asynchronous values + * @param callback a synchronous/asynchronous test + * @return a promise eventually containing the item or undefined if a match is not found + */ +export function find( + items: Iterable> | (T | Promise)[], + callback: Filterer +): Promise { + const list = isArrayLike(items) ? items : array.from(items); + return findIndex(list, callback).then(function(i) { + return i !== undefined && i >= 0 ? list[i] : undefined; + }); +} + +/** + * Find the first index with a value matching the filter function + * @param items a collection of synchronous/asynchronous values + * @param callback a synchronous/asynchronous test + * @return a promise eventually containing the index of the matching item or -1 if a match is not found + */ +export function findIndex( + items: Iterable> | (T | Thenable)[], + callback: Filterer +): Promise { + // TODO we can improve this by returning immediately + return processValuesAndCallback(items, callback).then(function(result: ValuesAndResults) { + if (result && result.results) { + for (let i = 0; i < result.results.length; i++) { + if (result.results[i]) { + return i; + } + } + } + return -1; + }); +} + +/** + * transform a list of items using a mapper function + * @param items a collection of synchronous/asynchronous values + * @param callback a synchronous/asynchronous transform function + * @return a promise eventually containing a collection of each transformed value + */ +export function map( + items: Iterable> | (T | Promise)[], + callback: Mapper +): Promise { + return processValuesAndCallback(items, callback).then(function(result) { + return result ? result.results : null; + }); +} + +/** + * reduce a list of items down to a single value + * @param items a collection of synchronous/asynchronous values + * @param callback a synchronous/asynchronous reducer function + * @param [initialValue] the first value to pass to the callback + * @return a promise eventually containing a value that is the result of the reduction + */ +export function reduce( + this: any, + items: Iterable> | (T | Promise)[], + callback: Reducer, + initialValue?: U +): Promise { + const args: any[] = array.from(arguments); + args.unshift(findNextValueIndex); + return generalReduce.apply(this, args); +} + +export function reduceRight( + this: any, + items: Iterable> | (T | Promise)[], + callback: Reducer, + initialValue?: U +): Promise { + const args: any[] = array.from(arguments); + args.unshift(findLastValueIndex); + return generalReduce.apply(this, args); +} + +export function series( + items: Iterable> | (T | Promise)[], + operation: Mapper +): Promise { + return generalReduce( + findNextValueIndex, + items, + function(previousValue, currentValue: T, index: number, array: T[]) { + const result = operation(currentValue, index, array); + + if (isThenable(result)) { + return result.then(function(value) { + previousValue.push(value); + return previousValue; + }); + } + + previousValue.push(result); + return previousValue; + }, + [] as U[] + ); +} + +export function some( + items: Iterable> | Array>, + callback: Filterer +): Promise { + return testAndHaltOnCondition(true, items, callback); +} + +export interface Filterer extends Mapper {} + +export interface Mapper { + (value: T, index: number, array: T[]): U | Thenable; +} + +export interface Reducer { + (previousValue: U, currentValue: T, index: number, array: T[]): U | Thenable; +} diff --git a/src/lib/core/src/async/timing.ts b/src/lib/core/src/async/timing.ts new file mode 100644 index 0000000..46be710 --- /dev/null +++ b/src/lib/core/src/async/timing.ts @@ -0,0 +1,63 @@ +import Promise from './ExtensiblePromise'; +import { Thenable } from '@dojo/shim/interfaces'; + +export type IdentityValue = T | (() => T | Thenable); +export interface Identity { + (value?: IdentityValue): Promise; +} + +/** + * Used for delaying a Promise chain for a specific number of milliseconds. + * + * @param milliseconds the number of milliseconds to delay + * @return {function (value: T | (() => T | Thenable)): Promise} a function producing a promise that eventually returns the value or executes the value function passed to it; usable with Thenable.then() + */ +export function delay(milliseconds: number): Identity { + return function(value?: IdentityValue): Promise { + return new Promise(function(resolve) { + setTimeout(function() { + resolve(typeof value === 'function' ? value() : value); + }, milliseconds); + }); + }; +} + +/** + * Reject a promise chain if a result hasn't been found before the timeout + * + * @param milliseconds after this number of milliseconds a rejection will be returned + * @param reason The reason for the rejection + * @return {function(T): Promise} a function that produces a promise that is rejected or resolved based on your timeout + */ +export function timeout(milliseconds: number, reason: Error): Identity { + const start = Date.now(); + return function(value?: IdentityValue): Promise { + if (Date.now() - milliseconds > start) { + return Promise.reject(reason); + } + if (typeof value === 'function') { + return Promise.resolve(value()); + } + return Promise.resolve(value); + }; +} + +/** + * A Promise that will reject itself automatically after a time. + * Useful for combining with other promises in Promise.race. + */ +export class DelayedRejection extends Promise { + /** + * @param milliseconds the number of milliseconds to wait before triggering a rejection + * @param reason the reason for the rejection + */ + constructor(milliseconds: number, reason?: Error) { + super(() => {}); + + return new Promise(function(resolve, reject) { + setTimeout(() => { + reject(reason); + }, milliseconds); + }); + } +} diff --git a/src/lib/core/src/base64.ts b/src/lib/core/src/base64.ts new file mode 100644 index 0000000..c2667b2 --- /dev/null +++ b/src/lib/core/src/base64.ts @@ -0,0 +1,42 @@ +import global from '@dojo/shim/global'; +import has, { add as hasAdd } from '@dojo/has/has'; + +hasAdd('btoa', 'btoa' in global, true); +hasAdd('atob', 'atob' in global, true); + +/** + * Take a string encoded in base64 and decode it + * @param encodedString The base64 encoded string + */ +export const decode: (encodedString: string) => string = has('atob') + ? function(encodedString: string) { + /* this allows for utf8 characters to be decoded properly */ + return decodeURIComponent( + Array.prototype.map + .call( + atob(encodedString), + (char: string) => '%' + ('00' + char.charCodeAt(0).toString(16)).slice(-2) + ) + .join('') + ); + } + : function(encodedString: string): string { + return new Buffer(encodedString.toString(), 'base64').toString('utf8'); + }; + +/** + * Take a string and encode it to base64 + * @param rawString The string to encode + */ +export const encode: (rawString: string) => string = has('btoa') + ? function(decodedString: string) { + /* this allows for utf8 characters to be encoded properly */ + return btoa( + encodeURIComponent(decodedString).replace(/%([0-9A-F]{2})/g, (match, code: string) => + String.fromCharCode(Number('0x' + code)) + ) + ); + } + : function(rawString: string): string { + return new Buffer(rawString.toString(), 'utf8').toString('base64'); + }; diff --git a/src/lib/core/src/compare.ts b/src/lib/core/src/compare.ts new file mode 100644 index 0000000..b26da81 --- /dev/null +++ b/src/lib/core/src/compare.ts @@ -0,0 +1,754 @@ +import { assign } from '@dojo/shim/object'; +import { keys } from '@dojo/shim/object'; +import Set from '@dojo/shim/Set'; + +/* Assigning to local variables to improve minification and readability */ + +const objectCreate = Object.create; +const hasOwnProperty = Object.prototype.hasOwnProperty; +const defineProperty = Object.defineProperty; +const isArray = Array.isArray; +const isFrozen = Object.isFrozen; +const isSealed = Object.isSealed; + +export type IgnorePropertyFunction = (name: string, a: any, b: any) => boolean; + +export interface DiffOptions { + /** + * Allow functions to be values. Values will be considered equal if the `typeof` both values are `function`. + * When adding or updating the property, the value of the property of `a` will be used in the record, which + * will be a reference to the function. + */ + allowFunctionValues?: boolean; + + /** + * An array of strings or regular expressions which flag certain properties to be ignored. Alternatively + * a function, which returns `true` to have the property ignored or `false` to diff the property. + */ + ignoreProperties?: (string | RegExp)[] | IgnorePropertyFunction; + + /** + * An array of strings or regular expressions which flag certain values to be ignored. For flagged properties, + * if the property is present in both `a` and `b` the value will be ignored. If adding the property, + * whatever the value of the property of `a` will be used, which could be a reference. + */ + ignorePropertyValues?: (string | RegExp)[] | IgnorePropertyFunction; +} + +/** + * Interface for a generic constructor function + */ +export interface Constructor { + new (...args: any[]): object; + prototype: object; +} + +/** + * A partial property descriptor that provides the property descriptor flags supported by the + * complex property construction of `patch()` + * + * All properties are value properties, with the value being supplied by the `ConstructRecord` + */ +export interface ConstructDescriptor { + /** + * Is the property configurable? + */ + configurable?: boolean; + + /** + * Is the property enumerable? + */ + enumerable?: boolean; + + /** + * Is the property configurable? + */ + writable?: boolean; +} + +/** + * A record that describes a constructor function and arguments necessary to create an instance of + * an object + */ +export interface AnonymousConstructRecord { + /** + * Any arguments to pass to the constructor function + */ + args?: any[]; + + /** + * The constructor function to use to create the instance + */ + Ctor: Constructor; + + /** + * The partial descriptor that is used to set the value of the instance + */ + descriptor?: ConstructDescriptor; + + /** + * Any patches to properties that need to occur on the instance + */ + propertyRecords?: (ConstructRecord | PatchRecord)[]; +} + +export interface ConstructRecord extends AnonymousConstructRecord { + /** + * The name of the property on the Object + */ + name: string; +} + +/** + * A record that describes the mutations necessary to a property of an object to make that property look + * like another + */ +export type PatchRecord = + | { + /** + * The name of the property on the Object + */ + name: string; + + /** + * The type of the patch + */ + type: 'delete'; + } + | { + /** + * A property descriptor that describes the property in `name` + */ + descriptor: PropertyDescriptor; + + /** + * The name of the property on the Object + */ + name: string; + + /** + * The type of the patch + */ + type: 'add' | 'update'; + + /** + * Additional patch records which describe the value of the property + */ + valueRecords?: (ConstructRecord | PatchRecord | SpliceRecord)[]; + }; + +/** + * The different types of patch records supported + */ +export type PatchTypes = 'add' | 'update' | 'delete'; + +/** + * A record that describes a splice operation to perform on an array to make the array look like another array + */ +export interface SpliceRecord { + /** + * Any items that are being added to the array + */ + add?: any[]; + + /** + * The number of items in the array to delete + */ + deleteCount: number; + + /** + * The type, set to `splice` + */ + type: 'splice'; + + /** + * The index of where to start the splice + */ + start: number; +} + +/** + * A record that describes how to instantiate a new object via a constructor function + * @param Ctor The constructor function + * @param args Any arguments to be passed to the constructor function + */ +/* tslint:disable:variable-name */ +export function createConstructRecord( + Ctor: Constructor, + args?: any[], + descriptor?: ConstructDescriptor +): AnonymousConstructRecord { + const record: AnonymousConstructRecord = assign(objectCreate(null), { Ctor }); + if (args) { + record.args = args; + } + if (descriptor) { + record.descriptor = descriptor; + } + return record; +} +/* tslint:enable:variable-name */ + +/** + * An internal function that returns a new patch record + * + * @param type The type of patch record + * @param name The property name the record refers to + * @param descriptor The property descriptor to be installed on the object + * @param valueRecords Any subsequenet patch recrds to be applied to the value of the descriptor + */ +function createPatchRecord( + type: PatchTypes, + name: string, + descriptor?: PropertyDescriptor, + valueRecords?: (ConstructRecord | PatchRecord | SpliceRecord)[] +): PatchRecord { + const patchRecord = assign(objectCreate(null), { + type, + name + }); + + if (descriptor) { + patchRecord.descriptor = descriptor; + } + if (valueRecords) { + patchRecord.valueRecords = valueRecords; + } + + return patchRecord as PatchRecord; +} + +/** + * An internal function that returns a new splice record + * + * @param start Where in the array to start the splice + * @param deleteCount The number of elements to delete from the array + * @param add Elements to be added to the target + */ +function createSpliceRecord(start: number, deleteCount: number, add?: any[]): SpliceRecord { + const spliceRecord: SpliceRecord = assign(objectCreate(null), { + type: 'splice', + start, + deleteCount + }); + + if (add && add.length) { + spliceRecord.add = add; + } + + return spliceRecord; +} + +/** + * A function that produces a value property descriptor, which assumes that properties are enumerable, writable and configurable + * unless specified + * + * @param value The value for the descriptor + * @param writable Defaults to `true` if not specified + * @param enumerable Defaults to `true` if not specified + * @param configurable Defaults to `true` if not specified + */ +function createValuePropertyDescriptor( + value: any, + writable: boolean = true, + enumerable: boolean = true, + configurable: boolean = true +): PropertyDescriptor { + return assign(objectCreate(null), { + value, + writable, + enumerable, + configurable + }); +} + +/** + * A function that returns a constructor record or `undefined` when diffing a value + */ +export type CustomDiffFunction = ( + value: T, + nameOrIndex: string | number, + parent: object +) => AnonymousConstructRecord | void; + +/** + * A class which is used when making a custom comparison of a non-plain object or array + */ +export class CustomDiff { + private _differ: CustomDiffFunction; + + constructor(diff: CustomDiffFunction) { + this._differ = diff; + } + + /** + * Get the difference of the `value` + * @param value The value to diff + * @param nameOrIndex A `string` if comparing a property or a `number` if comparing an array element + * @param parent The outer parent that this value is part of + */ + diff(value: T, nameOrIndex: string | number, parent: object): ConstructRecord | void { + const record = this._differ(value, nameOrIndex, parent); + if (record && typeof nameOrIndex === 'string') { + return assign(record, { name: nameOrIndex }); + } + } +} + +/** + * Internal function that detects the differences between an array and another value and returns a set of splice records that + * describe the differences + * + * @param a The first array to compare to + * @param b The second value to compare to + * @param options An options bag that allows configuration of the behaviour of `diffArray()` + */ +function diffArray(a: any[], b: any, options: DiffOptions): SpliceRecord[] { + /* This function takes an overly simplistic approach to calculating splice records. There are many situations where + * in complicated array mutations, the splice records can be more optimised. + * + * TODO: Raise an issue for this when it is finally merged and put into core + */ + + const { allowFunctionValues = false } = options; + + const arrayA = a; + const lengthA = arrayA.length; + const arrayB = isArray(b) ? b : []; + const lengthB = arrayB.length; + const patchRecords: SpliceRecord[] = []; + + if (!lengthA && lengthB) { + /* empty array */ + patchRecords.push(createSpliceRecord(0, lengthB)); + return patchRecords; + } + + let add: any[] = []; + let start = 0; + let deleteCount = 0; + let last = -1; + + function flushSpliceRecord() { + if (deleteCount || add.length) { + patchRecords.push( + createSpliceRecord(start, start + deleteCount > lengthB ? lengthB - start : deleteCount, add) + ); + } + } + + function addDifference(index: number, adding: boolean, value?: any) { + if (index > last + 1) { + /* flush the splice */ + flushSpliceRecord(); + start = index; + deleteCount = 0; + if (add.length) { + add = []; + } + } + + if (adding) { + add.push(value); + } + deleteCount++; + last = index; + } + + arrayA.forEach((valueA, index) => { + const valueB = arrayB[index]; + + if ( + index in arrayB && + (valueA === valueB || (allowFunctionValues && typeof valueA === 'function' && typeof valueB === 'function')) + ) { + return; /* not different */ + } + + const isValueAArray = isArray(valueA); + const isValueAPlainObject = isPlainObject(valueA); + + if (isValueAArray || isValueAPlainObject) { + const value = isValueAArray + ? isArray(valueB) ? valueB : [] + : isPlainObject(valueB) ? valueB : Object.create(null); + const valueRecords = diff(valueA, value, options); + if (valueRecords.length) { + /* only add if there are changes */ + addDifference(index, true, diff(valueA, value, options)); + } + } else if (isPrimitive(valueA)) { + addDifference(index, true, valueA); + } else if (allowFunctionValues && typeof valueA === 'function') { + addDifference(index, true, valueA); + } else { + throw new TypeError( + `Value of array element "${index}" from first argument is not a primative, plain Object, or Array.` + ); + } + }); + + if (lengthB > lengthA) { + for (let index = lengthA; index < lengthB; index++) { + addDifference(index, false); + } + } + + /* flush any deletes */ + flushSpliceRecord(); + + return patchRecords; +} + +/** + * Internal function that detects the differences between plain objects and returns a set of patch records that + * describe the differences + * + * @param a The first plain object to compare to + * @param b The second plain bject to compare to + * @param options An options bag that allows configuration of the behaviour of `diffPlainObject()` + */ +function diffPlainObject(a: any, b: any, options: DiffOptions): (ConstructRecord | PatchRecord)[] { + const { allowFunctionValues = false, ignorePropertyValues = [] } = options; + const patchRecords: (ConstructRecord | PatchRecord)[] = []; + const { comparableA, comparableB } = getComparableObjects(a, b, options); + + /* look for keys in a that are different from b */ + keys(comparableA).reduce((patchRecords, name) => { + const valueA = a[name]; + const valueB = b[name]; + const bHasOwnProperty = hasOwnProperty.call(comparableB, name); + + if ( + bHasOwnProperty && + (valueA === valueB || (allowFunctionValues && typeof valueA === 'function' && typeof valueB === 'function')) + ) { + /* not different */ + /* when `allowFunctionValues` is true, functions are simply considered to be equal by `typeof` */ + return patchRecords; + } + + const type = bHasOwnProperty ? 'update' : 'add'; + + const isValueAArray = isArray(valueA); + const isValueAPlainObject = isPlainObject(valueA); + + if (isValueAArray || isValueAPlainObject) { + /* non-primitive values we can diff */ + /* this is a bit complicated, but essentially if valueA and valueB are both arrays or plain objects, then + * we can diff those two values, if not, then we need to use an empty array or an empty object and diff + * the valueA with that */ + const value = + (isValueAArray && isArray(valueB)) || (isValueAPlainObject && isPlainObject(valueB)) + ? valueB + : isValueAArray ? [] : objectCreate(null); + const valueRecords = diff(valueA, value, options); + if (valueRecords.length) { + /* only add if there are changes */ + patchRecords.push( + createPatchRecord(type, name, createValuePropertyDescriptor(value), diff(valueA, value, options)) + ); + } + } else if (isCustomDiff(valueA) && !isCustomDiff(valueB)) { + /* complex diff left hand */ + const result = valueA.diff(valueB, name, b); + if (result) { + patchRecords.push(result); + } + } else if (isCustomDiff(valueB)) { + /* complex diff right hand */ + const result = valueB.diff(valueA, name, a); + if (result) { + patchRecords.push(result); + } + } else if ( + isPrimitive(valueA) || + (allowFunctionValues && typeof valueA === 'function') || + isIgnoredPropertyValue(name, a, b, ignorePropertyValues) + ) { + /* primitive values, functions values if allowed, or ignored property values can just be copied */ + patchRecords.push(createPatchRecord(type, name, createValuePropertyDescriptor(valueA))); + } else { + throw new TypeError( + `Value of property named "${name}" from first argument is not a primative, plain Object, or Array.` + ); + } + return patchRecords; + }, patchRecords); + + /* look for keys in b that are not in a */ + keys(comparableB).reduce((patchRecords, name) => { + if (!hasOwnProperty.call(comparableA, name)) { + patchRecords.push(createPatchRecord('delete', name)); + } + return patchRecords; + }, patchRecords); + + return patchRecords; +} + +/** + * Takes two plain objects to be compared, as well as options customizing the behavior of the comparison, and returns + * two new objects that contain only those properties that should be compared. If a property is ignored + * it will not be included in either returned object. If a property's value should be ignored it will be excluded + * if it is present in both objects. + * @param a The first object to compare + * @param b The second object to compare + * @param options An options bag indicating which properties should be ignored or have their values ignored, if any. + */ +export function getComparableObjects(a: any, b: any, options: DiffOptions) { + const { ignoreProperties = [], ignorePropertyValues = [] } = options; + const ignore = new Set(); + const keep = new Set(); + + const isIgnoredProperty = Array.isArray(ignoreProperties) + ? (name: string) => { + return ignoreProperties.some( + (value) => (typeof value === 'string' ? name === value : value.test(name)) + ); + } + : (name: string) => ignoreProperties(name, a, b); + + const comparableA = keys(a).reduce( + (obj, name) => { + if ( + isIgnoredProperty(name) || + (hasOwnProperty.call(b, name) && isIgnoredPropertyValue(name, a, b, ignorePropertyValues)) + ) { + ignore.add(name); + return obj; + } + + keep.add(name); + obj[name] = a[name]; + return obj; + }, + {} as { [key: string]: any } + ); + + const comparableB = keys(b).reduce( + (obj, name) => { + if (ignore.has(name) || (!keep.has(name) && isIgnoredProperty(name))) { + return obj; + } + + obj[name] = b[name]; + return obj; + }, + {} as { [key: string]: any } + ); + + return { comparableA, comparableB, ignore }; +} + +/** + * A guard that determines if the value is a `ConstructRecord` + * @param value The value to check + */ +function isConstructRecord(value: any): value is ConstructRecord { + return Boolean(value && typeof value === 'object' && value !== null && value.Ctor && value.name); +} + +function isIgnoredPropertyValue( + name: string, + a: any, + b: any, + ignoredPropertyValues: (string | RegExp)[] | IgnorePropertyFunction +) { + return Array.isArray(ignoredPropertyValues) + ? ignoredPropertyValues.some((value) => { + return typeof value === 'string' ? name === value : value.test(name); + }) + : ignoredPropertyValues(name, a, b); +} + +/** + * A guard that determines if the value is a `PatchRecord` + * + * @param value The value to check + */ +function isPatchRecord(value: any): value is PatchRecord { + return Boolean(value && value.type && value.name); +} + +/** + * A guard that determines if the value is an array of `PatchRecord`s + * + * @param value The value to check + */ +function isPatchRecordArray(value: any): value is PatchRecord[] { + return Boolean(isArray(value) && value.length && isPatchRecord(value[0])); +} + +/** + * A guard that determines if the value is a plain object. A plain object is an object that has + * either no constructor (e.g. `Object.create(null)`) or has Object as its constructor. + * + * @param value The value to check + */ +function isPlainObject(value: any): value is Object { + return Boolean( + value && typeof value === 'object' && (value.constructor === Object || value.constructor === undefined) + ); +} + +/** + * A guard that determines if the value is a primitive (including `null`), as these values are + * fine to just copy. + * + * @param value The value to check + */ +function isPrimitive(value: any): value is string | number | boolean | undefined | null { + const typeofValue = typeof value; + return ( + value === null || + typeofValue === 'undefined' || + typeofValue === 'string' || + typeofValue === 'number' || + typeofValue === 'boolean' + ); +} + +/** + * A guard that determines if the value is a `CustomDiff` + * @param value The value to check + */ +function isCustomDiff(value: any): value is CustomDiff { + return typeof value === 'object' && value instanceof CustomDiff; +} + +/** + * A guard that determines if the value is a `SpliceRecord` + * + * @param value The value to check + */ +function isSpliceRecord(value: any): value is SpliceRecord { + return value && value.type === 'splice' && 'start' in value && 'deleteCount' in value; +} + +/** + * A guard that determines if the value is an array of `SpliceRecord`s + * + * @param value The value to check + */ +function isSpliceRecordArray(value: any): value is SpliceRecord[] { + return Boolean(isArray(value) && value.length && isSpliceRecord(value[0])); +} + +/** + * An internal function that patches a target with a `SpliceRecord` + */ +function patchSplice(target: any[], { add, deleteCount, start }: SpliceRecord): any { + if (add && add.length) { + const deletedItems = deleteCount ? target.slice(start, start + deleteCount) : []; + add = add.map((value, index) => resolveTargetValue(value, deletedItems[index])); + target.splice(start, deleteCount, ...add); + } else { + target.splice(start, deleteCount); + } + return target; +} + +/** + * An internal function that patches a target with a `PatchRecord` + */ +function patchPatch(target: any, record: PatchRecord): any { + const { name } = record; + if (record.type === 'delete') { + delete target[name]; + return target; + } + const { descriptor, valueRecords } = record; + if (valueRecords && valueRecords.length) { + descriptor.value = patch(descriptor.value, valueRecords); + } + defineProperty(target, name, descriptor); + return target; +} + +const defaultConstructDescriptor = { + configurable: true, + enumerable: true, + writable: true +}; + +function patchConstruct(target: any, record: ConstructRecord): any { + const { args, descriptor = defaultConstructDescriptor, Ctor, name, propertyRecords } = record; + const value = new Ctor(...(args || [])); + if (propertyRecords) { + propertyRecords.forEach( + (record) => (isConstructRecord(record) ? patchConstruct(value, record) : patchPatch(value, record)) + ); + } + defineProperty(target, name, assign({ value }, descriptor)); + return target; +} + +/** + * An internal function that takes a value from array being patched and the target value from the same + * index and determines the value that should actually be patched into the target array + */ +function resolveTargetValue(patchValue: any, targetValue: any): any { + const patchIsSpliceRecordArray = isSpliceRecordArray(patchValue); + return patchIsSpliceRecordArray || isPatchRecordArray(patchValue) + ? patch( + patchIsSpliceRecordArray + ? isArray(targetValue) ? targetValue : [] + : isPlainObject(targetValue) ? targetValue : objectCreate(null), + patchValue + ) + : patchValue; +} + +/** + * Compares two plain objects or arrays and return a set of records which describe the differences between the two + * + * The records describe what would need to be applied to the second argument to make it look like the first argument + * + * @param a The plain object or array to compare with + * @param b The plain object or array to compare to + * @param options An options bag that allows configuration of the behaviour of `diff()` + */ +export function diff(a: any, b: any, options: DiffOptions = {}): (ConstructRecord | PatchRecord | SpliceRecord)[] { + if (typeof a !== 'object' || typeof b !== 'object') { + throw new TypeError('Arguments are not of type object.'); + } + + if (isArray(a)) { + return diffArray(a, b, options); + } + + if (isArray(b)) { + b = objectCreate(null); + } + + if (!isPlainObject(a) || !isPlainObject(b)) { + throw new TypeError('Arguments are not plain Objects or Arrays.'); + } + + return diffPlainObject(a, b, options); +} + +/** + * Apply a set of patch records to a target. + * + * @param target The plain object or array that the patch records should be applied to + * @param records A set of patch records to be applied to the target + */ +export function patch(target: any, records: (ConstructRecord | PatchRecord | SpliceRecord)[]): any { + if (!isArray(target) && !isPlainObject(target)) { + throw new TypeError('A target for a patch must be either an array or a plain object.'); + } + if (isFrozen(target) || isSealed(target)) { + throw new TypeError('Cannot patch sealed or frozen objects.'); + } + + records.forEach((record) => { + target = isSpliceRecord(record) + ? patchSplice(isArray(target) ? target : [], record) /* patch arrays */ + : isConstructRecord(record) + ? patchConstruct(target, record) /* patch complex object */ + : patchPatch(isPlainObject(target) ? target : {}, record); /* patch plain object */ + }); + return target; +} diff --git a/src/lib/core/src/global.ts b/src/lib/core/src/global.ts new file mode 100644 index 0000000..7433175 --- /dev/null +++ b/src/lib/core/src/global.ts @@ -0,0 +1,10 @@ +import globalObject from '@dojo/shim/global'; +import { deprecated } from './instrument'; + +deprecated({ + message: 'has been replaced with @dojo/shim/global', + name: '@dojo/core/global', + url: 'https://github.com/dojo/core/issues/302' +}); + +export default globalObject; diff --git a/src/lib/core/src/has.ts b/src/lib/core/src/has.ts new file mode 100644 index 0000000..08cf81a --- /dev/null +++ b/src/lib/core/src/has.ts @@ -0,0 +1,70 @@ +import global from '@dojo/shim/global'; +import has, { add } from '@dojo/shim/support/has'; + +export * from '@dojo/shim/support/has'; +export default has; + +add('object-assign', typeof global.Object.assign === 'function', true); + +add('arraybuffer', typeof global.ArrayBuffer !== 'undefined', true); +add('formdata', typeof global.FormData !== 'undefined', true); +add('filereader', typeof global.FileReader !== 'undefined', true); +add('xhr', typeof global.XMLHttpRequest !== 'undefined', true); +add('xhr2', has('xhr') && 'responseType' in global.XMLHttpRequest.prototype, true); +add( + 'blob', + function() { + if (!has('xhr2')) { + return false; + } + + const request = new global.XMLHttpRequest(); + request.open('GET', global.location.protocol + '//www.google.com', true); + request.responseType = 'blob'; + request.abort(); + return request.responseType === 'blob'; + }, + true +); + +add('node-buffer', 'Buffer' in global && typeof global.Buffer === 'function', true); + +add('fetch', 'fetch' in global && typeof global.fetch === 'function', true); + +add( + 'web-worker-xhr-upload', + typeof global.Promise !== 'undefined' && + new Promise((resolve) => { + try { + if (global.Worker !== undefined && global.URL && global.URL.createObjectURL) { + const blob = new Blob( + [ + `(function () { +self.addEventListener('message', function () { + var xhr = new XMLHttpRequest(); + try { + xhr.upload; + postMessage('true'); + } catch (e) { + postMessage('false'); + } +}); + })()` + ], + { type: 'application/javascript' } + ); + const worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('message', ({ data: result }) => { + resolve(result === 'true'); + }); + worker.postMessage({}); + } else { + resolve(false); + } + } catch (e) { + // IE11 on Winodws 8.1 encounters a security error. + resolve(false); + } + }), + true +); diff --git a/src/lib/core/src/instrument.ts b/src/lib/core/src/instrument.ts new file mode 100644 index 0000000..26ed1cb --- /dev/null +++ b/src/lib/core/src/instrument.ts @@ -0,0 +1,100 @@ +import has from './has'; + +/** + * The default message to warn when no other is provided + */ +const DEFAULT_DEPRECATED_MESSAGE = 'This function will be removed in future versions.'; + +/** + * When set, globalWarn will be used instead of `console.warn` + */ +let globalWarn: ((message?: any, ...optionalParams: any[]) => void) | undefined; + +export interface DeprecatedOptions { + /** + * The message to use when warning + */ + message?: string; + + /** + * The name of the method or function to use + */ + name?: string; + + /** + * An alternative function to log the warning to + */ + warn?: (...args: any[]) => void; + + /** + * Reference an URL for more information when warning + */ + url?: string; +} + +/** + * A function that will console warn that a function has been deprecated + * + * @param options Provide options which change the display of the message + */ +export function deprecated({ message, name, warn, url }: DeprecatedOptions = {}): void { + /* istanbul ignore else: testing with debug off is difficult */ + if (has('debug')) { + message = message || DEFAULT_DEPRECATED_MESSAGE; + let warning = `DEPRECATED: ${name ? name + ': ' : ''}${message}`; + if (url) { + warning += `\n\n See ${url} for more details.\n\n`; + } + if (warn) { + warn(warning); + } else if (globalWarn) { + globalWarn(warning); + } else { + console.warn(warning); + } + } +} + +/** + * A function that generates before advice that can be used to warn when an API has been deprecated + * + * @param options Provide options which change the display of the message + */ +export function deprecatedAdvice(options?: DeprecatedOptions): (...args: any[]) => any[] { + return function(...args: any[]): any[] { + deprecated(options); + return args; + }; +} + +/** + * A method decorator that will console warn when a method if invoked that is deprecated + * + * @param options Provide options which change the display of the message + */ +export function deprecatedDecorator(options?: DeprecatedOptions): MethodDecorator { + return function(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) { + if (has('debug')) { + const { value: originalFn } = descriptor; + options = options || {}; + propertyKey = String(propertyKey); + /* IE 10/11 don't have the name property on functions */ + options.name = target.constructor.name ? `${target.constructor.name}#${propertyKey}` : propertyKey; + descriptor.value = function(...args: any[]) { + deprecated(options); + return originalFn.apply(target, args); + }; + } + return descriptor; + }; +} + +/** + * A function that will set the warn function that will be used instead of `console.warn` when + * logging warning messages + * + * @param warn The function (or `undefined`) to use instead of `console.warn` + */ +export function setWarn(warn?: ((message?: any, ...optionalParams: any[]) => void)): void { + globalWarn = warn; +} diff --git a/src/lib/core/src/interfaces.ts b/src/lib/core/src/interfaces.ts new file mode 100644 index 0000000..180c668 --- /dev/null +++ b/src/lib/core/src/interfaces.ts @@ -0,0 +1,287 @@ +export type EventType = string | symbol; + +/** + * The base event object, which provides a `type` property + */ +export interface EventObject { + /** + * The type of the event + */ + readonly type: T; +} + +export interface EventErrorObject extends EventObject { + /** + * The error that is the subject of this event + */ + readonly error: Error; +} + +/** + * An interface for an object which provides a cancelable event API. By calling the + * `.preventDefault()` method on the object, the event should be cancelled and not + * proceed any further + */ +export interface EventCancelableObject extends EventObject { + /** + * Can the event be canceled? + */ + readonly cancelable: boolean; + + /** + * Was the event canceled? + */ + readonly defaultPrevented: boolean; + + /** + * Cancel the event + */ + preventDefault(): void; +} + +/** + * Used through the toolkit as a consistent API to manage how callers can "cleanup" + * when doing a function. + */ +export interface Handle { + /** + * Perform the destruction/cleanup logic associated with this handle + */ + destroy(): void; +} + +/** + * A general interface that can be used to renference a general index map of values of a particular type + */ +export interface Hash { + [id: string]: T; +} + +/** + * A base map of styles where each key is the name of the style attribute and the value is a string + * which represents the style + */ +export interface StylesMap { + [style: string]: string; +} + +/** + * The interfaces to the `@dojo/loader` AMD loader + */ + +export interface AmdConfig { + /** + * The base URL that the loader will use to resolve modules + */ + baseUrl?: string; + + /** + * A map of module identifiers and their replacement meta data + */ + map?: AmdModuleMap; + + /** + * An array of packages that the loader should use when resolving a module ID + */ + packages?: AmdPackage[]; + + /** + * A map of paths to use when resolving modules names + */ + paths?: { [path: string]: string }; + + /** + * A map of packages that the loader should use when resolving a module ID + */ + pkgs?: { [path: string]: AmdPackage }; +} + +export interface AmdDefine { + /** + * Define a module + * + * @param moduleId the MID to use for the module + * @param dependencies an array of MIDs this module depends upon + * @param factory the factory function that will return the module + */ + (moduleId: string, dependencies: string[], factory: AmdFactory): void; + + /** + * Define a module + * + * @param dependencies an array of MIDs this module depends upon + * @param factory the factory function that will return the module + */ + (dependencies: string[], factory: AmdFactory): void; + + /** + * Define a module + * + * @param factory the factory function that will return the module + */ + (factory: AmdFactory): void; + + /** + * Define a module + * + * @param value the value for the module + */ + (value: any): void; + + /** + * Meta data about this particular AMD loader + */ + amd: { [prop: string]: string | number | boolean }; +} + +export interface AmdFactory { + /** + * The module factory + * + * @param modules The arguments that represent the resolved versions of the module dependencies + */ + (...modules: any[]): any; +} + +export interface AmdHas { + /** + * Determine if a feature is present + * + * @param name the feature name to check + */ + (name: string): any; + + /** + * Register a feature test + * + * @param name The name of the feature to register + * @param value The test for the feature + * @param now If `true` the test will be executed immediatly, if not, it will be lazily executed + * @param force If `true` the test value will be overwritten if already registered + */ + add( + name: string, + value: (global: Window, document?: HTMLDocument, element?: HTMLDivElement) => any, + now?: boolean, + force?: boolean + ): void; + add(name: string, value: any, now?: boolean, force?: boolean): void; +} + +export interface AmdModuleMap extends AmdModuleMapItem { + [sourceMid: string]: AmdModuleMapReplacement; +} + +export interface AmdModuleMapItem { + [mid: string]: any; +} + +export interface AmdModuleMapReplacement extends AmdModuleMapItem { + [findMid: string]: string; +} + +export interface NodeRequire { + (moduleId: string): any; + resolve(moduleId: string): string; +} + +export interface AmdPackage { + /** + * The path to the root of the package + */ + location?: string; + + /** + * The main module of the package (defaults to `main.js`) + */ + main?: string; + + /** + * The package name + */ + name?: string; +} + +export interface AmdRequire { + /** + * Resolve a list of module dependencies and pass them to the callback + * + * @param dependencies The array of MIDs to resolve + * @param callback The function to invoke with the resolved dependencies + */ + (dependencies: string[], callback: AmdRequireCallback): void; + + /** + * Resolve and return a single module (compatability with CommonJS `require`) + * + * @param moduleId The module ID to resolve and return + */ + (moduleId: string): ModuleType; + + /** + * If running in the node environment, a reference to the original NodeJS `require` + */ + nodeRequire?: NodeRequire; + + /** + * Take a relative MID and return an absolute MID + * + * @param moduleId The relative module ID to resolve + */ + toAbsMid(moduleId: string): string; + + /** + * Take a path and resolve the full URL for the path + * + * @param path The path to resolve and return as a URL + */ + toUrl(path: string): string; +} + +export interface AmdRequireCallback { + /** + * The `require` callback + * + * @param modules The arguments that represent the resolved versions of dependencies + */ + (...modules: any[]): void; +} + +export interface AmdRootRequire extends AmdRequire { + /** + * The minimalist `has` API integrated with the `@dojo/loader` + */ + has: AmdHas; + + /** + * Register an event listener + * + * @param type The event type to listen for + * @param listener The listener to call when the event is emitted + */ + on(type: AmdRequireOnSignalType, listener: any): { remove: () => void }; + + /** + * Configure the loader + * + * @param config The configuration to apply to the loader + */ + config(config: AmdConfig): void; + + /** + * Return internal values of loader for debug purposes + * + * @param name The name of the internal label + */ + inspect?(name: string): any; + + /** + * Undefine a module, based on absolute MID that should be removed from the loader cache + */ + undef(moduleId: string): void; +} + +/** + * The signal type for the `require.on` API + */ +export type AmdRequireOnSignalType = 'error'; diff --git a/src/lib/core/src/lang.ts b/src/lib/core/src/lang.ts new file mode 100644 index 0000000..b1995a3 --- /dev/null +++ b/src/lib/core/src/lang.ts @@ -0,0 +1,390 @@ +import { Handle } from './interfaces'; +import { assign } from '@dojo/shim/object'; + +export { assign } from '@dojo/shim/object'; + +const slice = Array.prototype.slice; +const hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Type guard that ensures that the value can be coerced to Object + * to weed out host objects that do not derive from Object. + * This function is used to check if we want to deep copy an object or not. + * Note: In ES6 it is possible to modify an object's Symbol.toStringTag property, which will + * change the value returned by `toString`. This is a rare edge case that is difficult to handle, + * so it is not handled here. + * @param value The value to check + * @return If the value is coercible into an Object + */ +function shouldDeepCopyObject(value: any): value is Object { + return Object.prototype.toString.call(value) === '[object Object]'; +} + +function copyArray(array: T[], inherited: boolean): T[] { + return array.map(function(item: T): T { + if (Array.isArray(item)) { + return copyArray(item, inherited); + } + + return !shouldDeepCopyObject(item) + ? item + : _mixin({ + deep: true, + inherited: inherited, + sources: >[item], + target: {} + }); + }); +} + +interface MixinArgs { + deep: boolean; + inherited: boolean; + sources: (U | null | undefined)[]; + target: T; + copied?: any[]; +} + +function _mixin(kwArgs: MixinArgs): T & U { + const deep = kwArgs.deep; + const inherited = kwArgs.inherited; + const target: any = kwArgs.target; + const copied = kwArgs.copied || []; + const copiedClone = [...copied]; + + for (let i = 0; i < kwArgs.sources.length; i++) { + const source = kwArgs.sources[i]; + + if (source === null || source === undefined) { + continue; + } + for (let key in source) { + if (inherited || hasOwnProperty.call(source, key)) { + let value: any = source[key]; + + if (copiedClone.indexOf(value) !== -1) { + continue; + } + + if (deep) { + if (Array.isArray(value)) { + value = copyArray(value, inherited); + } else if (shouldDeepCopyObject(value)) { + const targetValue: any = target[key] || {}; + copied.push(source); + value = _mixin({ + deep: true, + inherited: inherited, + sources: [value], + target: targetValue, + copied + }); + } + } + target[key] = value; + } + } + } + + return target; +} + +/** + * Creates a new object from the given prototype, and copies all enumerable own properties of one or more + * source objects to the newly created target object. + * + * @param prototype The prototype to create a new object from + * @param mixins Any number of objects whose enumerable own properties will be copied to the created object + * @return The new object + */ +export function create< + T extends {}, + U extends {}, + V extends {}, + W extends {}, + X extends {}, + Y extends {}, + Z extends {} +>(prototype: T, mixin1: U, mixin2: V, mixin3: W, mixin4: X, mixin5: Y, mixin6: Z): T & U & V & W & X & Y & Z; +export function create( + prototype: T, + mixin1: U, + mixin2: V, + mixin3: W, + mixin4: X, + mixin5: Y +): T & U & V & W & X & Y; +export function create( + prototype: T, + mixin1: U, + mixin2: V, + mixin3: W, + mixin4: X +): T & U & V & W & X; +export function create( + prototype: T, + mixin1: U, + mixin2: V, + mixin3: W +): T & U & V & W; +export function create(prototype: T, mixin1: U, mixin2: V): T & U & V; +export function create(prototype: T, mixin: U): T & U; +export function create(prototype: T): T; +export function create(prototype: any, ...mixins: any[]): any { + if (!mixins.length) { + throw new RangeError('lang.create requires at least one mixin object.'); + } + + const args = mixins.slice(); + args.unshift(Object.create(prototype)); + + return assign.apply(null, args); +} + +/** + * Copies the values of all enumerable own properties of one or more source objects to the target object, + * recursively copying all nested objects and arrays as well. + * + * @param target The target object to receive values from source objects + * @param sources Any number of objects whose enumerable own properties will be copied to the target object + * @return The modified target object + */ +export function deepAssign< + T extends {}, + U extends {}, + V extends {}, + W extends {}, + X extends {}, + Y extends {}, + Z extends {} +>(target: T, source1: U, source2: V, source3: W, source4: X, source5: Y, source6: Z): T & U & V & W & X & Y & Z; +export function deepAssign( + target: T, + source1: U, + source2: V, + source3: W, + source4: X, + source5: Y +): T & U & V & W & X & Y; +export function deepAssign( + target: T, + source1: U, + source2: V, + source3: W, + source4: X +): T & U & V & W & X; +export function deepAssign( + target: T, + source1: U, + source2: V, + source3: W +): T & U & V & W; +export function deepAssign(target: T, source1: U, source2: V): T & U & V; +export function deepAssign(target: T, source: U): T & U; +export function deepAssign(target: any, ...sources: any[]): any { + return _mixin({ + deep: true, + inherited: false, + sources: sources, + target: target + }); +} + +/** + * Copies the values of all enumerable (own or inherited) properties of one or more source objects to the + * target object, recursively copying all nested objects and arrays as well. + * + * @param target The target object to receive values from source objects + * @param sources Any number of objects whose enumerable properties will be copied to the target object + * @return The modified target object + */ +export function deepMixin< + T extends {}, + U extends {}, + V extends {}, + W extends {}, + X extends {}, + Y extends {}, + Z extends {} +>(target: T, source1: U, source2: V, source3: W, source4: X, source5: Y, source6: Z): T & U & V & W & X & Y & Z; +export function deepMixin( + target: T, + source1: U, + source2: V, + source3: W, + source4: X, + source5: Y +): T & U & V & W & X & Y; +export function deepMixin( + target: T, + source1: U, + source2: V, + source3: W, + source4: X +): T & U & V & W & X; +export function deepMixin( + target: T, + source1: U, + source2: V, + source3: W +): T & U & V & W; +export function deepMixin(target: T, source1: U, source2: V): T & U & V; +export function deepMixin(target: T, source: U): T & U; +export function deepMixin(target: any, ...sources: any[]): any { + return _mixin({ + deep: true, + inherited: true, + sources: sources, + target: target + }); +} + +/** + * Creates a new object using the provided source's prototype as the prototype for the new object, and then + * deep copies the provided source's values into the new target. + * + * @param source The object to duplicate + * @return The new object + */ +export function duplicate(source: T): T { + const target = Object.create(Object.getPrototypeOf(source)); + + return deepMixin(target, source); +} + +/** + * Determines whether two values are the same value. + * + * @param a First value to compare + * @param b Second value to compare + * @return true if the values are the same; false otherwise + */ +export function isIdentical(a: any, b: any): boolean { + return ( + a === b || + /* both values are NaN */ + (a !== a && b !== b) + ); +} + +/** + * Returns a function that binds a method to the specified object at runtime. This is similar to + * `Function.prototype.bind`, but instead of a function it takes the name of a method on an object. + * As a result, the function returned by `lateBind` will always call the function currently assigned to + * the specified property on the object as of the moment the function it returns is called. + * + * @param instance The context object + * @param method The name of the method on the context object to bind to itself + * @param suppliedArgs An optional array of values to prepend to the `instance[method]` arguments list + * @return The bound function + */ +export function lateBind(instance: {}, method: string, ...suppliedArgs: any[]): (...args: any[]) => any { + return suppliedArgs.length + ? function() { + const args: any[] = arguments.length ? suppliedArgs.concat(slice.call(arguments)) : suppliedArgs; + + // TS7017 + return (instance)[method].apply(instance, args); + } + : function() { + // TS7017 + return (instance)[method].apply(instance, arguments); + }; +} + +/** + * Copies the values of all enumerable (own or inherited) properties of one or more source objects to the + * target object. + * + * @return The modified target object + */ +export function mixin( + target: T, + source1: U, + source2: V, + source3: W, + source4: X, + source5: Y, + source6: Z +): T & U & V & W & X & Y & Z; +export function mixin( + target: T, + source1: U, + source2: V, + source3: W, + source4: X, + source5: Y +): T & U & V & W & X & Y; +export function mixin( + target: T, + source1: U, + source2: V, + source3: W, + source4: X +): T & U & V & W & X; +export function mixin( + target: T, + source1: U, + source2: V, + source3: W +): T & U & V & W; +export function mixin(target: T, source1: U, source2: V): T & U & V; +export function mixin(target: T, source: U): T & U; +export function mixin(target: any, ...sources: any[]): any { + return _mixin({ + deep: false, + inherited: true, + sources: sources, + target: target + }); +} + +/** + * Returns a function which invokes the given function with the given arguments prepended to its argument list. + * Like `Function.prototype.bind`, but does not alter execution context. + * + * @param targetFunction The function that needs to be bound + * @param suppliedArgs An optional array of arguments to prepend to the `targetFunction` arguments list + * @return The bound function + */ +export function partial(targetFunction: (...args: any[]) => any, ...suppliedArgs: any[]): (...args: any[]) => any { + return function(this: any) { + const args: any[] = arguments.length ? suppliedArgs.concat(slice.call(arguments)) : suppliedArgs; + + return targetFunction.apply(this, args); + }; +} + +/** + * Returns an object with a destroy method that, when called, calls the passed-in destructor. + * This is intended to provide a unified interface for creating "remove" / "destroy" handlers for + * event listeners, timers, etc. + * + * @param destructor A function that will be called when the handle's `destroy` method is invoked + * @return The handle object + */ +export function createHandle(destructor: () => void): Handle { + let called = false; + return { + destroy: function(this: Handle) { + if (!called) { + called = true; + destructor(); + } + } + }; +} + +/** + * Returns a single handle that can be used to destroy multiple handles simultaneously. + * + * @param handles An array of handles with `destroy` methods + * @return The handle object + */ +export function createCompositeHandle(...handles: Handle[]): Handle { + return createHandle(function() { + for (let i = 0; i < handles.length; i++) { + handles[i].destroy(); + } + }); +} diff --git a/src/lib/core/src/load.ts b/src/lib/core/src/load.ts new file mode 100644 index 0000000..cb1662f --- /dev/null +++ b/src/lib/core/src/load.ts @@ -0,0 +1,110 @@ +import Promise from '@dojo/shim/Promise'; +import { AmdRequire, AmdDefine, NodeRequire } from './interfaces'; +import { isPlugin, useDefault } from './load/util'; + +export type Require = AmdRequire | NodeRequire; + +export interface Load { + (require: Require, ...moduleIds: string[]): Promise; + (...moduleIds: string[]): Promise; +} + +declare const require: Require; + +declare const define: AmdDefine; + +export function isAmdRequire(object: any): object is AmdRequire { + return typeof object.toUrl === 'function'; +} + +export function isNodeRequire(object: any): object is NodeRequire { + return typeof object.resolve === 'function'; +} + +const load: Load = (function(): Load { + const resolver = isAmdRequire(require) + ? require.toUrl + : isNodeRequire(require) ? require.resolve : (resourceId: string) => resourceId; + + function pluginLoad(moduleIds: string[], load: Load, loader: (modulesIds: string[]) => Promise) { + const pluginResourceIds: string[] = []; + moduleIds = moduleIds.map((id: string, i: number) => { + const parts = id.split('!'); + pluginResourceIds[i] = parts[1]; + return parts[0]; + }); + + return loader(moduleIds).then((modules: any[]) => { + pluginResourceIds.forEach((resourceId: string, i: number) => { + if (typeof resourceId === 'string') { + const module = modules[i]; + const defaultExport = module['default'] || module; + + if (isPlugin(defaultExport)) { + resourceId = + typeof defaultExport.normalize === 'function' + ? defaultExport.normalize(resourceId, resolver) + : resolver(resourceId); + + modules[i] = defaultExport.load(resourceId, load); + } + } + }); + + return Promise.all(modules); + }); + } + + if (typeof module === 'object' && typeof module.exports === 'object') { + return function load(contextualRequire: any, ...moduleIds: string[]): Promise { + if (typeof contextualRequire === 'string') { + moduleIds.unshift(contextualRequire); + contextualRequire = require; + } + + return pluginLoad(moduleIds, load, (moduleIds: string[]) => { + try { + return Promise.resolve( + moduleIds.map(function(moduleId): any { + return contextualRequire(moduleId.split('!')[0]); + }) + ); + } catch (error) { + return Promise.reject(error); + } + }); + }; + } else if (typeof define === 'function' && define.amd) { + return function load(contextualRequire: any, ...moduleIds: string[]): Promise { + if (typeof contextualRequire === 'string') { + moduleIds.unshift(contextualRequire); + contextualRequire = require; + } + + return pluginLoad(moduleIds, load, (moduleIds: string[]) => { + return new Promise(function(resolve, reject) { + let errorHandle: { remove: () => void }; + + if (typeof contextualRequire.on === 'function') { + errorHandle = contextualRequire.on('error', (error: Error) => { + errorHandle.remove(); + reject(error); + }); + } + + contextualRequire(moduleIds, function(...modules: any[]) { + errorHandle && errorHandle.remove(); + resolve(modules); + }); + }); + }); + }; + } else { + return function() { + return Promise.reject(new Error('Unknown loader')); + }; + } +})(); +export default load; + +export { isPlugin, useDefault }; diff --git a/src/lib/core/src/load/util.ts b/src/lib/core/src/load/util.ts new file mode 100644 index 0000000..9ac6d63 --- /dev/null +++ b/src/lib/core/src/load/util.ts @@ -0,0 +1,59 @@ +import { isArrayLike, isIterable } from '@dojo/shim/iterator'; +import { Load } from '../load'; + +export interface LoadPlugin { + /** + * An optional method that normmalizes a resource id. + * + * @param resourceId + * The raw resource id. + * + * @param resolver + * A method that can resolve an id to an absolute path. Depending on the environment, this will + * usually be either `require.toUrl` or `require.resolve`. + */ + normalize?: (resourceId: string, resolver: (resourceId: string) => string) => string; + + /** + * A method that loads the specified resource. + * + * @param resourceId + * The id of the resource to load. + * + * @param load + * The `load` method that was used to load and execute the plugin. + * + * @return + * A promise that resolves to the loaded resource. + */ + load(resourceId: string, load: Load): Promise; +} + +export function isPlugin(value: any): value is LoadPlugin { + return Boolean(value) && typeof value.load === 'function'; +} + +export function useDefault(modules: any[]): any[]; +export function useDefault(module: any): any; +export function useDefault(modules: any | any[]): any[] | any { + if (isArrayLike(modules)) { + let processedModules: any[] = []; + + for (let i = 0; i < modules.length; i++) { + const module = modules[i]; + processedModules.push(module.__esModule && module.default ? module.default : module); + } + + return processedModules; + } else if (isIterable(modules)) { + let processedModules: any[] = []; + + for (const module of modules) { + processedModules.push(module.__esModule && module.default ? module.default : module); + } + + return processedModules; + } else { + return modules.__esModule && modules.default ? modules.default : modules; + } +} diff --git a/src/lib/core/src/load/webpack.ts b/src/lib/core/src/load/webpack.ts new file mode 100644 index 0000000..de164eb --- /dev/null +++ b/src/lib/core/src/load/webpack.ts @@ -0,0 +1,146 @@ +import Promise from '@dojo/shim/Promise'; +import { isPlugin, useDefault } from './util'; + +interface ModuleIdMap { + [path: string]: { id: number; lazy: boolean }; +} + +interface BundleLoaderCallback { + (value: T): void; +} + +interface WebpackRequire { + (id: number): T | BundleLoaderCallback; +} + +/** + * A global map (set by the build) of resolved module paths to webpack-specific module data. + */ +declare const __modules__: ModuleIdMap; + +/** + * The webpack-specific require function, set globally by webpack. + */ +declare const __webpack_require__: WebpackRequire; + +/** + * @private + * Resolves an absolute path from an absolute base path and relative module ID. + * + * @param base + * The absolute base path. + * + * @param mid + * The relative module ID + * + * @return + * The resolved absolute module path. + */ +function resolveRelative(base: string, mid: string): string { + const isRelative = mid.match(/^\.+\//); + let result = base; + + if (isRelative) { + if (mid.match(/^\.\//)) { + mid = mid.replace(/\.\//, ''); + } + + const up = mid.match(/\.\.\//g); + if (up) { + const chunks = base.split('/'); + + if (up.length > chunks.length) { + throw new Error('Path cannot go beyond root directory.'); + } + + chunks.splice(chunks.length - up.length); + result = chunks.join('/'); + mid = mid.replace(/\.\.\//g, ''); + } + + mid = result + '/' + mid; + } + + return mid; +} + +/** + * @private + * Returns the parent directory for the specified module ID. + * + * @param context + * A function that returns the context module ID. + * + * @return + * The parent directory of the path returned by the context function. + */ +function getBasePath(context: () => string): string { + return context() + .split('/') + .slice(0, -1) + .join('/'); +} + +/** + * A webpack-specific function that replaces `@dojo/core/load` in its builds. In order for a module to be loaded, + * it must first be included in a webpack chunk, whether that chunk is included in the main build, or lazy-loaded. + * Note that this module is not intended for direct use, but rather is intended for use by a webpack plugin + * that sets the module ID map used to translate resolved module paths to webpack module IDs. + * + * @param contextRequire + * An optional function that returns the base path to use when resolving relative module IDs. + * + * @param ...mids + * One or more IDs for modules to load. + * + * @return + * A promise to the loaded module values. + */ +export default function load(contextRequire: () => string, ...mids: string[]): Promise; +export default function load(...mids: string[]): Promise; +export default function load(...args: any[]): Promise { + const req = __webpack_require__; + const context = + typeof args[0] === 'function' + ? args[0] + : function() { + return ''; + }; + + const modules = __modules__ || {}; + const base = getBasePath(context); + + const results = args + .filter((mid: string | Function) => typeof mid === 'string') + .map((mid: string) => resolveRelative(base, mid)) + .map((mid: string) => { + let [moduleId, pluginResourceId] = mid.split('!'); + const moduleMeta = modules[mid] || modules[moduleId]; + + if (!moduleMeta) { + return Promise.reject(new Error(`Missing module: ${mid}`)); + } + + if (moduleMeta.lazy) { + return new Promise((resolve) => req(moduleMeta.id)(resolve)); + } + + const module = req(moduleMeta.id); + const defaultExport = module['default'] || module; + + if (isPlugin(defaultExport)) { + pluginResourceId = + typeof defaultExport.normalize === 'function' + ? defaultExport.normalize(pluginResourceId, (mid: string) => resolveRelative(base, mid)) + : resolveRelative(base, pluginResourceId); + + return Promise.resolve(defaultExport.load(pluginResourceId, load)); + } + + return Promise.resolve(module); + }); + + return Promise.all(results); +} + +export { isPlugin, useDefault }; diff --git a/src/lib/core/src/main.ts b/src/lib/core/src/main.ts new file mode 100644 index 0000000..46f2bf1 --- /dev/null +++ b/src/lib/core/src/main.ts @@ -0,0 +1,47 @@ +import * as aspect from './aspect'; +import DateObject from './DateObject'; +import Evented from './Evented'; +import IdentityRegistry from './IdentityRegistry'; +import * as lang from './lang'; +import * as base64 from './base64'; +import load from './load'; +import MatchRegistry from './MatchRegistry'; +import on, { emit } from './on'; +import * as queue from './queue'; +import request from './request'; +import Scheduler from './Scheduler'; +import * as stringExtras from './stringExtras'; +import * as text from './text'; +import UrlSearchParams from './UrlSearchParams'; +import * as util from './util'; + +import * as iteration from './async/iteration'; +import Task from './async/Task'; +import * as timing from './async/timing'; + +const async = { + iteration, + Task, + timing +}; + +export { + aspect, + async, + base64, + DateObject, + emit, + Evented, + IdentityRegistry, + lang, + load, + MatchRegistry, + on, + queue, + request, + Scheduler, + stringExtras, + text, + UrlSearchParams, + util +}; diff --git a/src/lib/core/src/on.ts b/src/lib/core/src/on.ts new file mode 100644 index 0000000..ac2fef1 --- /dev/null +++ b/src/lib/core/src/on.ts @@ -0,0 +1,230 @@ +import { Handle, EventObject } from './interfaces'; +import { createHandle, createCompositeHandle } from './lang'; +import Evented, { CustomEventTypes } from './Evented'; + +export interface EventCallback> { + (event: O): void; +} + +export interface EventEmitter { + on(event: string, listener: EventCallback): EventEmitter; + removeListener(event: string, listener: EventCallback): EventEmitter; +} + +interface DOMEventObject extends EventObject { + bubbles: boolean; + cancelable: boolean; +} + +/** + * Provides a normalized mechanism for dispatching events for event emitters, Evented objects, or DOM nodes. + * @param target The target to emit the event from + * @param event The event object to emit + * @return Boolean indicating if preventDefault was called on the event object (only relevant for DOM events; + * always false for other event emitters) + */ +export function emit< + M extends CustomEventTypes, + T, + O extends EventObject = EventObject, + K extends keyof M = keyof M +>(target: Evented, event: M[K]): boolean; +export function emit = EventObject>(target: Evented, event: O): boolean; +export function emit = EventObject>( + target: EventTarget | EventEmitter, + event: O +): boolean; +export function emit(target: any, event: EventObject): boolean { + if ( + target.dispatchEvent /* includes window and document */ && + ((target.ownerDocument && target.ownerDocument.createEvent) /* matches nodes */ || + (target.document && target.document.createEvent) /* matches window */ || + target.createEvent) /* matches document */ + ) { + const nativeEvent = (target.ownerDocument || target.document || target).createEvent('HTMLEvents'); + nativeEvent.initEvent( + event.type, + Boolean((event).bubbles), + Boolean((event).cancelable) + ); + + for (let key in event) { + if (!(key in nativeEvent)) { + nativeEvent[key] = (event)[key]; + } + } + + return target.dispatchEvent(nativeEvent); + } + + if (target.emit) { + if (target.removeListener) { + // Node.js EventEmitter + target.emit(event.type, event); + return false; + } else if (target.on) { + // Dojo Evented or similar + target.emit(event); + return false; + } + } + + throw new Error('Target must be an event emitter'); +} + +/** + * Provides a normalized mechanism for listening to events from event emitters, Evented objects, or DOM nodes. + * @param target Target to listen for event on + * @param type Event event type(s) to listen for; may a string or an array of strings + * @param listener Callback to handle the event when it fires + * @param capture Whether the listener should be registered in the capture phase (DOM events only) + * @return A handle which will remove the listener when destroy is called + */ +export default function on< + M extends CustomEventTypes, + T, + K extends keyof M = keyof M, + O extends EventObject = EventObject +>(target: Evented, type: K | K[], listener: EventCallback): Handle; +export default function on = EventObject>( + target: Evented, + type: T | T[], + listener: EventCallback +): Handle; +export default function on(target: EventEmitter, type: string | string[], listener: EventCallback): Handle; +export default function on( + target: EventTarget, + type: string | string[], + listener: EventCallback, + capture?: boolean +): Handle; +export default function on(target: any, type: any, listener: any, capture?: boolean): Handle { + if (Array.isArray(type)) { + let handles: Handle[] = type.map(function(type: string): Handle { + return on(target, type, listener, capture); + }); + + return createCompositeHandle(...handles); + } + + const callback = function(this: any) { + listener.apply(this, arguments); + }; + + // DOM EventTarget + if (target.addEventListener && target.removeEventListener) { + target.addEventListener(type, callback, capture); + return createHandle(function() { + target.removeEventListener(type, callback, capture); + }); + } + + if (target.on) { + // EventEmitter + if (target.removeListener) { + target.on(type, callback); + return createHandle(function() { + target.removeListener(type, callback); + }); + } else if (target.emit) { + // Evented + return target.on(type, listener); + } + } + + throw new TypeError('Unknown event emitter object'); +} + +/** + * Provides a mechanism for listening to the next occurrence of an event from event + * emitters, Evented objects, or DOM nodes. + * @param target Target to listen for event on + * @param type Event event type(s) to listen for; may be a string or an array of strings + * @param listener Callback to handle the event when it fires + * @param capture Whether the listener should be registered in the capture phase (DOM events only) + * @return A handle which will remove the listener when destroy is called + */ +export function once< + M extends CustomEventTypes, + T, + K extends keyof M = keyof M, + O extends EventObject = EventObject +>(target: Evented, type: K | K[], listener: EventCallback): Handle; +export function once = EventObject>( + target: Evented, + type: T | T[], + listener: EventCallback +): Handle; +export function once(target: EventTarget, type: string | string[], listener: EventCallback, capture?: boolean): Handle; +export function once(target: EventEmitter, type: string | string[], listener: EventCallback): Handle; +export function once(target: any, type: any, listener: any, capture?: boolean): Handle { + // FIXME + // tslint:disable-next-line:no-var-keyword + var handle = on( + target, + type, + function(this: any) { + handle.destroy(); + return listener.apply(this, arguments); + }, + capture + ); + + return handle; +} + +export interface PausableHandle extends Handle { + pause(): void; + resume(): void; +} + +/** + * Provides a mechanism for creating pausable listeners for events from event emitters, Evented objects, or DOM nodes. + * @param target Target to listen for event on + * @param type Event event type(s) to listen for; may a string or an array of strings + * @param listener Callback to handle the event when it fires + * @param capture Whether the listener should be registered in the capture phase (DOM events only) + * @return A handle with additional pause and resume methods; the listener will never fire when paused + */ +export function pausable< + M extends CustomEventTypes, + T, + K extends keyof M = keyof M, + O extends EventObject = EventObject +>(target: Evented, type: K | K[], listener: EventCallback): PausableHandle; +export function pausable = EventObject>( + target: Evented, + type: T | T[], + listener: EventCallback +): PausableHandle; +export function pausable( + target: EventTarget, + type: string | string[], + listener: EventCallback, + capture?: boolean +): PausableHandle; +export function pausable(target: EventEmitter, type: string | string[], listener: EventCallback): PausableHandle; +export function pausable(target: any, type: any, listener: any, capture?: boolean): PausableHandle { + let paused: boolean; + + const handle = on( + target, + type, + function(this: any) { + if (!paused) { + return listener.apply(this, arguments); + } + }, + capture + ); + + handle.pause = function() { + paused = true; + }; + + handle.resume = function() { + paused = false; + }; + + return handle; +} diff --git a/src/lib/core/src/queue.ts b/src/lib/core/src/queue.ts new file mode 100644 index 0000000..e63a62a --- /dev/null +++ b/src/lib/core/src/queue.ts @@ -0,0 +1 @@ +export * from '@dojo/shim/support/queue'; diff --git a/src/lib/core/src/request.ts b/src/lib/core/src/request.ts new file mode 100644 index 0000000..fb3c4ce --- /dev/null +++ b/src/lib/core/src/request.ts @@ -0,0 +1,66 @@ +import has from '@dojo/has/has'; +import Task from './async/Task'; +import { RequestOptions, Response, Provider, UploadObservableTask } from './request/interfaces'; +import ProviderRegistry from './request/ProviderRegistry'; +import xhr from './request/providers/xhr'; + +export const providerRegistry = new ProviderRegistry(); + +const request: { + (url: string, options?: RequestOptions): Task; + delete(url: string, options?: RequestOptions): Task; + get(url: string, options?: RequestOptions): Task; + head(url: string, options?: RequestOptions): Task; + options(url: string, options?: RequestOptions): Task; + post(url: string, options?: RequestOptions): UploadObservableTask; + put(url: string, options?: RequestOptions): UploadObservableTask; + + setDefaultProvider(provider: Provider): void; +} = function request(url: string, options: RequestOptions = {}): Task { + try { + return providerRegistry.match(url, options)(url, options); + } catch (error) { + return Task.reject(error); + } +}; + +['DELETE', 'GET', 'HEAD', 'OPTIONS'].forEach((method) => { + Object.defineProperty(request, method.toLowerCase(), { + value(url: string, options: RequestOptions = {}): Task { + options = Object.create(options); + options.method = method; + return request(url, options); + } + }); +}); + +['POST', 'PUT'].forEach((method) => { + Object.defineProperty(request, method.toLowerCase(), { + value(url: string, options: RequestOptions = {}): UploadObservableTask { + options = Object.create(options); + options.method = method; + return >request(url, options); + } + }); +}); + +Object.defineProperty(request, 'setDefaultProvider', { + value(provider: Provider) { + providerRegistry.setDefaultProvider(provider); + } +}); + +providerRegistry.setDefaultProvider(xhr); + +if (has('host-node')) { + // tslint:disable-next-line + import('./request/providers/node').then((node) => { + providerRegistry.setDefaultProvider(node.default); + }); +} + +export default request; +export * from './request/interfaces'; +export { default as Headers } from './request/Headers'; +export { default as TimeoutError } from './request/TimeoutError'; +export { ResponseData } from './request/Response'; diff --git a/src/lib/core/src/request/Headers.ts b/src/lib/core/src/request/Headers.ts new file mode 100644 index 0000000..637ca45 --- /dev/null +++ b/src/lib/core/src/request/Headers.ts @@ -0,0 +1,101 @@ +import { Headers as HeadersInterface } from './interfaces'; +import { IterableIterator, ShimIterator } from '@dojo/shim/iterator'; +import Map from '@dojo/shim/Map'; + +function isHeadersLike(object: any): object is HeadersInterface { + return ( + typeof object.append === 'function' && + typeof object.entries === 'function' && + typeof object[Symbol.iterator] === 'function' + ); +} + +export class Headers implements HeadersInterface { + protected map = new Map(); + + constructor(headers?: { [key: string]: string } | HeadersInterface) { + if (headers) { + if (headers instanceof Headers) { + this.map = new Map(headers.map); + } else if (isHeadersLike(headers)) { + for (const [key, value] of headers) { + this.append(key, value); + } + } else { + for (let key in headers) { + this.set(key, headers[key]); + } + } + } + } + + append(name: string, value: string) { + const values = this.map.get(name.toLowerCase()); + + if (values) { + values.push(value); + } else { + this.set(name, value); + } + } + + delete(name: string) { + this.map.delete(name.toLowerCase()); + } + + entries(): IterableIterator<[string, string]> { + const entries: [string, string][] = []; + for (const [key, values] of this.map.entries()) { + values.forEach((value) => { + entries.push([key, value]); + }); + } + return new ShimIterator(entries); + } + + get(name: string): string | null { + const values = this.map.get(name.toLowerCase()); + + if (values) { + return values[0]; + } else { + return null; + } + } + + getAll(name: string): string[] { + const values = this.map.get(name.toLowerCase()); + + if (values) { + return values.slice(0); + } else { + return []; + } + } + + has(name: string): boolean { + return this.map.has(name.toLowerCase()); + } + + keys(): IterableIterator { + return this.map.keys(); + } + + set(name: string, value: string) { + this.map.set(name.toLowerCase(), [value]); + } + + values(): IterableIterator { + const values: string[] = []; + for (const value of this.map.values()) { + values.push(...value); + } + return new ShimIterator(values); + } + + [Symbol.iterator]() { + return this.entries(); + } +} + +export default Headers; diff --git a/src/lib/core/src/request/ProviderRegistry.ts b/src/lib/core/src/request/ProviderRegistry.ts new file mode 100644 index 0000000..458a37f --- /dev/null +++ b/src/lib/core/src/request/ProviderRegistry.ts @@ -0,0 +1,27 @@ +import { Provider, ProviderTest } from './interfaces'; +import MatchRegistry, { Test } from '../MatchRegistry'; +import { Handle } from '../interfaces'; + +export class ProviderRegistry extends MatchRegistry { + setDefaultProvider(provider: Provider) { + this._defaultValue = provider; + } + + register(test: string | RegExp | ProviderTest | null, value: Provider, first?: boolean): Handle { + let entryTest: Test | null; + + if (typeof test === 'string') { + entryTest = (url, options) => test === url; + } else if (test instanceof RegExp) { + entryTest = (url, options) => { + return test ? test.test(url) : null; + }; + } else { + entryTest = test; + } + + return super.register(entryTest, value, first); + } +} + +export default ProviderRegistry; diff --git a/src/lib/core/src/request/README.md b/src/lib/core/src/request/README.md new file mode 100644 index 0000000..5f24f2c --- /dev/null +++ b/src/lib/core/src/request/README.md @@ -0,0 +1,75 @@ +## Features + +This module allows the consumer to make HTTP requests using Node, XMLHttpRequest, or the Fetch API. The details of +these implementations are exposed through a common interface. + +With this module you can, + +* Easily make simple HTTP requests +* Convert response bodies to common formats like text, json, or html +* Access response headers of a request before the body is downloaded +* Monitor progress of a request +* Stream response data + +## How do I use this package? + +### Quick Start + +To make simple GET requests, you must register your provider (node, or XHR) then make the request. The overall +format of the API resembles the [Fetch Standard](https://fetch.spec.whatwg.org/). + +```ts +import request from 'dojo-request'; +import node from 'dojo-request/providers/node'; + +request.setDefaultProvider(node); + +request.get('http://www.example.com').then(response => { + return response.text(); +}).then(html => { + console.log(html); +}); +``` + +Responses can be returned as an `ArrayBuffer`, `Blob`, XML document, JSON object, or text string. + +You can also easily send request data, + +```ts +request.post('http://www.example.com', { + body: 'request data here' +}).then(response => { + // ... +}); +``` + +## Advanced Usage + +### Reading Response Headers + +This approach allows for processing of response headers _before_ the response body is available. + +```ts +request.get('http://www.example.com').then(response => { + const expectedSize = Number(response.headers.get('content-length') || 0); +}); +``` + +### Response Events + +`Response` objects also emit `start`, `end`, `progress`, and `data` events. You can use these events to monitor download progress +or stream a response directly to a file. + +```ts +request.get('http://www.example.com').then(response => { + response.on('progress', (event: ProgressEvent) => { + console.log(`Total downloaded: ${event.totalBytesDownloaded}`); + }); + + return response.blob(); +}).then(blob => { + // do something with the data +}); +``` + +Note that there are some caveats when using these events. XHR cannot stream data (a final `data` event is sent at the end however). diff --git a/src/lib/core/src/request/Response.ts b/src/lib/core/src/request/Response.ts new file mode 100644 index 0000000..2e952c3 --- /dev/null +++ b/src/lib/core/src/request/Response.ts @@ -0,0 +1,69 @@ +import Promise from '@dojo/shim/Promise'; +import Task from '../async/Task'; +import { Headers, Response as ResponseInterface, RequestOptions } from './interfaces'; +import Observable from '../Observable'; + +export interface ResponseData { + task: Task; + used: boolean; +} + +abstract class Response implements ResponseInterface { + abstract readonly headers: Headers; + abstract readonly ok: boolean; + abstract readonly status: number; + abstract readonly statusText: string; + abstract readonly url: string; + abstract readonly bodyUsed: boolean; + abstract readonly requestOptions: RequestOptions; + + abstract readonly download: Observable; + abstract readonly data: Observable; + + json(): Task { + return this.text().then(JSON.parse); + } + + abstract arrayBuffer(): Task; + abstract blob(): Task; + abstract formData(): Task; + abstract text(): Task; +} + +export default Response; + +export function getFileReaderPromise(reader: FileReader): Promise { + return new Promise((resolve, reject) => { + reader.onload = function() { + resolve(reader.result); + }; + reader.onerror = function() { + reject(reader.error); + }; + }); +} + +export function getTextFromBlob(blob: Blob) { + const reader = new FileReader(); + const promise = getFileReaderPromise(reader); + reader.readAsText(blob); + return promise; +} + +export function getArrayBufferFromBlob(blob: Blob) { + const reader = new FileReader(); + const promise = getFileReaderPromise(reader); + reader.readAsArrayBuffer(blob); + return promise; +} + +export function getTextFromArrayBuffer(buffer: ArrayBuffer) { + const view = new Uint8Array(buffer); + const chars: string[] = []; + + view.forEach((charCode, index) => { + chars[index] = String.fromCharCode(charCode); + }); + + return chars.join(''); +} diff --git a/src/lib/core/src/request/SubscriptionPool.ts b/src/lib/core/src/request/SubscriptionPool.ts new file mode 100644 index 0000000..4ee44ca --- /dev/null +++ b/src/lib/core/src/request/SubscriptionPool.ts @@ -0,0 +1,46 @@ +import { SubscriptionObserver } from '@dojo/shim/Observable'; + +export class SubscriptionPool { + private _observers: SubscriptionObserver[] = []; + private _queue: T[] = []; + private _queueMaxLength: number; + + constructor(maxLength = 10) { + this._queueMaxLength = maxLength; + } + + add(subscription: SubscriptionObserver) { + this._observers.push(subscription); + + while (this._queue.length > 0) { + this.next(this._queue.shift()!); + } + + return () => { + this._observers.splice(this._observers.indexOf(subscription), 1); + }; + } + + next(value: T) { + if (this._observers.length === 0) { + this._queue.push(value); + + // when the queue is full, get rid of the first ones + while (this._queue.length > this._queueMaxLength) { + this._queue.shift(); + } + } + + this._observers.forEach((observer) => { + observer.next(value); + }); + } + + complete() { + this._observers.forEach((observer) => { + observer.complete(); + }); + } +} + +export default SubscriptionPool; diff --git a/src/lib/core/src/request/TimeoutError.ts b/src/lib/core/src/request/TimeoutError.ts new file mode 100644 index 0000000..b00b5d6 --- /dev/null +++ b/src/lib/core/src/request/TimeoutError.ts @@ -0,0 +1,14 @@ +export class TimeoutError implements Error { + readonly message: string; + + get name(): string { + return 'TimeoutError'; + } + + constructor(message?: string) { + message = message || 'The request timed out'; + this.message = message; + } +} + +export default TimeoutError; diff --git a/src/lib/core/src/request/interfaces.d.ts b/src/lib/core/src/request/interfaces.d.ts new file mode 100644 index 0000000..c38fd22 --- /dev/null +++ b/src/lib/core/src/request/interfaces.d.ts @@ -0,0 +1,84 @@ +import { IterableIterator } from '@dojo/shim/iterator'; +import Task from '../async/Task'; +import UrlSearchParams, { ParamList } from '../UrlSearchParams'; +import Observable from '../Observable'; + +export interface Body { + readonly bodyUsed: boolean; + + arrayBuffer(): Task; + blob(): Task; + formData(): Task; + json(): Task; + text(): Task; +} + +export interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + entries(): IterableIterator<[string, string]>; + get(name: string): string | null; + getAll(name: string): string[]; + has(name: string): boolean; + keys(): IterableIterator; + set(name: string, value: string): void; + values(): IterableIterator; + [Symbol.iterator](): IterableIterator<[string, string]>; +} + +export interface UploadObservableTask extends Task { + upload: Observable; +} + +export type Provider = (url: string, options?: RequestOptions) => UploadObservableTask; + +export type ProviderTest = (url: string, options?: RequestOptions) => boolean | null; + +export interface RequestOptions { + /** + * Enable cache busting (default false). Cache busting will make a new URL by appending a parameter to the + * requested URL + */ + cacheBust?: boolean; + credentials?: 'omit' | 'same-origin' | 'include'; + /** + * Body to send along with the http request + */ + body?: Blob | BufferSource | FormData | UrlSearchParams | string; + /** + * Headers to send along with the http request + */ + headers?: Headers | { [key: string]: string }; + /** + * HTTP method + */ + method?: string; + /** + * Password for HTTP authentication + */ + password?: string; + /** + * Number of milliseconds before the request times out and is canceled + */ + timeout?: number; + /** + * User for HTTP authentication + */ + user?: string; + /** + * Optional query parameter(s) for the URL. The requested url will have these query parameters appended. + */ + query?: string | ParamList; +} + +export interface Response extends Body { + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly url: string; + readonly requestOptions: RequestOptions; + + readonly download: Observable; + readonly data: Observable; +} diff --git a/src/lib/core/src/request/providers/node.ts b/src/lib/core/src/request/providers/node.ts new file mode 100644 index 0000000..94b127d --- /dev/null +++ b/src/lib/core/src/request/providers/node.ts @@ -0,0 +1,677 @@ +import { Handle } from '../../interfaces'; +import Set from '@dojo/shim/Set'; +import WeakMap from '@dojo/shim/WeakMap'; +import * as http from 'http'; +import * as https from 'https'; +import * as urlUtil from 'url'; +import * as zlib from 'zlib'; +import Task from '../../async/Task'; +import { deepAssign } from '../../lang'; +import { queueTask } from '../../queue'; +import { createTimer } from '../../util'; +import Headers from '../Headers'; +import { RequestOptions, UploadObservableTask } from '../interfaces'; +import Response from '../Response'; +import TimeoutError from '../TimeoutError'; +import { Readable } from 'stream'; +import Observable from '../../Observable'; +import SubscriptionPool from '../SubscriptionPool'; + +/** + * Request options specific to a node request. For HTTPS options, see + * https://nodejs.org/api/tls.html#tls_tls_connect_options_callback for more details. + */ +export interface NodeRequestOptions extends RequestOptions { + /** + * User-agent header + */ + agent?: any; + /** + * If specified, the request body is read from the stream specified here, rather than from the `body` field. + */ + bodyStream?: Readable; + /** + * HTTPS optionally override the trusted CA certificates + */ + ca?: any; + /** + * HTTPS optional cert chains in PEM format. One cert chain should be provided per private key. + */ + cert?: string; + /** + * HTTPS optional cipher suite specification + */ + ciphers?: string; + dataEncoding?: string; + /** + * Whether or not to automatically follow redirects (default true) + */ + followRedirects?: boolean; + /** + * HTTPS optional private key in PEM format. + */ + key?: string; + /** + * Local interface to bind for network connections. + */ + localAddress?: string; + /** + * HTTPS optional shared passphrase used for a single private key and/or a PFX. + */ + passphrase?: string; + /** + * HTTPS optional PFX or PKCS12 encoded private key and certificate chain. + */ + pfx?: any; + /** + * Optional proxy address. If specified, requests will be sent through this url. + */ + proxy?: string; + /** + * HTTPS If not false the server will reject any connection which is not authorized with the list of supplied CAs + */ + rejectUnauthorized?: boolean; + /** + * HTTPS optional SSL method to use, default is "SSLv23_method" + */ + secureProtocol?: string; + /** + * Unix Domain Socket (use one of host:port or socketPath) + */ + socketPath?: string; + /** + * Whether or not to add the gzip and deflate accept headers (default true) + */ + acceptCompression?: boolean; + /** + * A set of options to set on the HTTP request + */ + socketOptions?: { + /** + * Enable/disable keep-alive functionality, and optionally set the initial delay before the first keepalive probe is sent on an idle socket. + */ + keepAlive?: number; + /** + * Disables the Nagle algorithm. By default TCP connections use the Nagle algorithm, they buffer data before sending it off. + */ + noDelay?: boolean; + /** + * Number of milliseconds before the HTTP request times out + */ + timeout?: number; + }; + /** + * Stream encoding on incoming HTTP response + */ + streamEncoding?: string; + /** + * Options to control redirect follow logic + */ + redirectOptions?: { + /** + * The limit to the number of redirects that will be followed (default 15). This is used to prevent infinite + * redirect loops. + */ + limit?: number; + count?: number; + /** + * Whether or not to keep the original HTTP method during 301 redirects (default false). + */ + keepOriginalMethod?: boolean; + }; +} + +// TODO: This should be read from the package and not hard coded! +let version = '2.0.0-pre'; + +/** + * If not overridden, redirects will only be processed this many times before aborting (per request). + * @type {number} + */ +const DEFAULT_REDIRECT_LIMIT = 15; + +/** + * Options to be passed to node's request + */ +interface Options { + agent?: any; + auth?: string; + headers?: { [name: string]: string }; + host?: string; + hostname?: string; + localAddress?: string; + method?: string; + path?: string; + port?: number; + socketPath?: string; +} + +/** + * HTTPS specific options for node + */ +interface HttpsOptions extends Options { + ca?: any; + cert?: string; + ciphers?: string; + key?: string; + passphrase?: string; + pfx?: any; + rejectUnauthorized?: boolean; + secureProtocol?: string; +} + +interface RequestData { + task: Task; + buffer: any[]; + data: Buffer; + size: number; + used: boolean; + nativeResponse: http.IncomingMessage; + requestOptions: NodeRequestOptions; + url: string; + downloadObservable: Observable; + dataObservable: Observable; +} + +const dataMap = new WeakMap(); +const discardedDuplicates = new Set([ + 'age', + 'authorization', + 'content-length', + 'content-type', + 'etag', + 'expires', + 'from', + 'host', + 'if-modified-since', + 'if-unmodified-since', + 'last-modified', + 'location', + 'max-forwards', + 'proxy-authorization', + 'referer', + 'retry-after', + 'user-agent' +]); + +function getDataTask(response: NodeResponse): Task { + const data = dataMap.get(response)!; + + if (data.used) { + return Task.reject(new TypeError('Body already read')); + } + + data.used = true; + + return >data.task.then((_) => data); +} + +/** + * Turn a node native response object into something that resembles the fetch api + */ +export class NodeResponse extends Response { + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + + downloadBody = true; + + get bodyUsed(): boolean { + return dataMap.get(this)!.used; + } + + get nativeResponse(): http.IncomingMessage { + return dataMap.get(this)!.nativeResponse; + } + + get requestOptions(): NodeRequestOptions { + return dataMap.get(this)!.requestOptions; + } + + get url(): string { + return dataMap.get(this)!.url; + } + + get download(): Observable { + return dataMap.get(this)!.downloadObservable; + } + + get data(): Observable { + return dataMap.get(this)!.dataObservable; + } + + constructor(response: http.IncomingMessage) { + super(); + + const headers = (this.headers = new Headers()); + for (let key in response.headers) { + const value = response.headers[key]; + if (value) { + if (discardedDuplicates.has(key) && !Array.isArray(value)) { + headers.append(key, value); + } + (Array.isArray(value) ? value : value.split(/\s*,\s*/)).forEach((v) => { + headers.append(key, v); + }); + } + } + + this.status = response.statusCode || 0; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = response.statusMessage || ''; + } + + arrayBuffer(): Task { + return getDataTask(this).then((data) => { + if (data) { + return data.data; + } + + return new Buffer([]); + }); + } + + blob(): Task { + // Node doesn't support Blobs + return Task.reject(new Error('Blob not supported')); + } + + formData(): Task { + return Task.reject(new Error('FormData not supported')); + } + + text(): Task { + return getDataTask(this).then((data) => { + return String(data ? data.data : ''); + }); + } +} + +function redirect( + resolve: (p?: any) => void, + reject: (_?: Error) => void, + originalUrl: string, + redirectUrl: string | null, + options: NodeRequestOptions +): boolean { + if (!options.redirectOptions) { + options.redirectOptions = {}; + } + + const { limit: redirectLimit = DEFAULT_REDIRECT_LIMIT, count: redirectCount = 0 } = options.redirectOptions; + const { followRedirects = true } = options; + + if (!followRedirects) { + return false; + } + + // we only check for undefined here because empty string redirects are now allowed + // (they'll resolve to the current url) + if (redirectUrl === undefined || redirectUrl === null) { + reject(new Error('asked to redirect but no location header was found')); + return true; + } + + if (redirectCount > redirectLimit) { + reject(new Error(`too many redirects, limit reached at ${redirectLimit}`)); + return true; + } + + options.redirectOptions.count = redirectCount + 1; + + // we wrap the url in a call to node's URL.resolve which will handle relative and partial + // redirects (like "/another-page" on the same domain). + resolve(node(urlUtil.resolve(originalUrl, redirectUrl), options)); + + return true; +} + +export function getAuth(proxyAuth: string | undefined, options: NodeRequestOptions): string | undefined { + if (proxyAuth) { + return proxyAuth; + } + + if (options.user || options.password) { + return `${options.user || ''}:${options.password || ''}`; + } + + return undefined; +} + +export default function node(url: string, options: NodeRequestOptions = {}): UploadObservableTask { + const parsedUrl = urlUtil.parse(options.proxy || url); + + const requestOptions: HttpsOptions = { + agent: options.agent, + auth: getAuth(parsedUrl.auth, options), + ca: options.ca, + cert: options.cert, + ciphers: options.ciphers, + host: parsedUrl.host, + hostname: parsedUrl.hostname, + key: options.key, + localAddress: options.localAddress, + method: options.method ? options.method.toUpperCase() : 'GET', + passphrase: options.passphrase, + path: parsedUrl.path, + pfx: options.pfx, + port: Number(parsedUrl.port), + rejectUnauthorized: options.rejectUnauthorized, + secureProtocol: options.secureProtocol, + socketPath: options.socketPath + }; + + requestOptions.headers = <{ [key: string]: string }>options.headers || {}; + + if ( + !Object.keys(requestOptions.headers) + .map((headerName) => headerName.toLowerCase()) + .some((headerName) => headerName === 'user-agent') + ) { + requestOptions.headers['user-agent'] = 'dojo/' + version + ' Node.js/' + process.version.replace(/^v/, ''); + } + + if (options.proxy) { + requestOptions.path = url; + if (parsedUrl.auth) { + requestOptions.headers['proxy-authorization'] = 'Basic ' + new Buffer(parsedUrl.auth).toString('base64'); + } + + const parsedProxyUrl = urlUtil.parse(url); + if (parsedProxyUrl.host) { + requestOptions.headers['host'] = parsedProxyUrl.host; + } + + if (parsedProxyUrl.auth) { + requestOptions.auth = parsedProxyUrl.auth; + } + } + + const { acceptCompression = true } = options; + if (acceptCompression) { + requestOptions.headers['Accept-Encoding'] = 'gzip, deflate'; + } + + const request = parsedUrl.protocol === 'https:' ? https.request(requestOptions) : http.request(requestOptions); + + const uploadObserverPool = new SubscriptionPool(); + + const requestTask = >new Task( + (resolve, reject) => { + let timeoutHandle: Handle; + let timeoutReject: Function = reject; + + if (options.socketOptions) { + if (options.socketOptions.timeout) { + request.setTimeout(options.socketOptions.timeout); + } + + if ('noDelay' in options.socketOptions) { + request.setNoDelay(options.socketOptions.noDelay); + } + + if ('keepAlive' in options.socketOptions) { + const initialDelay: number | undefined = options.socketOptions.keepAlive; + if (initialDelay !== undefined) { + request.setSocketKeepAlive(initialDelay >= 0, initialDelay); + } + } + } + + request.once('response', (message: http.IncomingMessage) => { + const response = new NodeResponse(message); + + // Redirection handling defaults to true in order to harmonise with the XHR provider, which will always + // follow redirects + if (response.status >= 300 && response.status < 400) { + const redirectOptions = options.redirectOptions || {}; + const newOptions = deepAssign({}, options); + + switch (response.status) { + case 300: + /** + * Note about 300 redirects. RFC 2616 doesn't specify what to do with them, it is up to the client to "pick + * the right one". We're picking like Chrome does, just don't pick any. + */ + break; + + case 301: + case 302: + /** + * RFC 2616 says, + * + * If the 301 status code is received in response to a request other + * than GET or HEAD, the user agent MUST NOT automatically redirect the + * request unless it can be confirmed by the user, since this might + * change the conditions under which the request was issued. + * + * Note: When automatically redirecting a POST request after + * receiving a 301 status code, some existing HTTP/1.0 user agents + * will erroneously change it into a GET request. + * + * We're going to be one of those erroneous agents, to prevent the request from failing.. + */ + if ( + requestOptions.method !== 'GET' && + requestOptions.method !== 'HEAD' && + !redirectOptions.keepOriginalMethod + ) { + newOptions.method = 'GET'; + } + + if (redirect(resolve, reject, url, response.headers.get('location'), newOptions)) { + return; + } + break; + + case 303: + /** + * The response to the request can be found under a different URI and + * SHOULD be retrieved using a GET method on that resource. + */ + if (requestOptions.method !== 'GET') { + newOptions.method = 'GET'; + } + + if (redirect(resolve, reject, url, response.headers.get('location'), newOptions)) { + return; + } + break; + + case 304: + // do nothing so this can fall through and return the response as normal. Nothing more can + // be done for 304 + break; + + case 305: + if (!response.headers.get('location')) { + reject(new Error('expected Location header to contain a proxy url')); + } else { + newOptions.proxy = response.headers.get('location') || ''; + if (redirect(resolve, reject, url, '', newOptions)) { + return; + } + } + break; + + case 307: + /** + * If the 307 status code is received in response to a request other + * than GET or HEAD, the user agent MUST NOT automatically redirect the + * request unless it can be confirmed by the user, since this might + * change the conditions under which the request was issued. + */ + if (redirect(resolve, reject, url, response.headers.get('location'), newOptions)) { + return; + } + break; + + default: + reject(new Error('unhandled redirect status ' + response.status)); + return; + } + } + + options.streamEncoding && message.setEncoding(options.streamEncoding); + + const downloadSubscriptionPool = new SubscriptionPool(); + const dataSubscriptionPool = new SubscriptionPool(); + + /* + [RFC 2616](https://tools.ietf.org/html/rfc2616#page-118) says that content-encoding can have multiple + values, so we split them here and put them in a list to process later. + */ + const contentEncodings = response.headers.getAll('content-encoding'); + + const task = new Task( + (resolve, reject) => { + timeoutReject = reject; + + // we queue this up for later to allow listeners to register themselves before we start receiving data + queueTask(() => { + /* + * Note that this is the raw data, if your input stream is zipped, and you are piecing + * together the downloaded data, you'll have to decompress it yourself + */ + message.on('data', (chunk: any) => { + dataSubscriptionPool.next(chunk); + + if (response.downloadBody) { + data.buffer.push(chunk); + } + + data.size += + typeof chunk === 'string' + ? Buffer.byteLength(chunk, options.streamEncoding) + : chunk.length; + + downloadSubscriptionPool.next(data.size); + }); + + message.once('end', () => { + timeoutHandle && timeoutHandle.destroy(); + + let dataAsBuffer = options.streamEncoding + ? new Buffer(data.buffer.join(''), 'utf8') + : Buffer.concat(data.buffer, data.size); + + const handleEncoding = function() { + /* + Content encoding is ordered by the order in which they were applied to the + content, so do undo the encoding we have to start at the end and work backwards. + */ + if (contentEncodings.length) { + const encoding = contentEncodings.pop()!.trim().toLowerCase(); + + if (encoding === '' || encoding === 'none' || encoding === 'identity') { + // do nothing, response stream is as-is + handleEncoding(); + } else if (encoding === 'gzip') { + zlib.gunzip(dataAsBuffer, function(err: Error | null, result: Buffer) { + if (err) { + reject(err); + } + + dataAsBuffer = result; + handleEncoding(); + }); + } else if (encoding === 'deflate') { + zlib.inflate(dataAsBuffer, function(err: Error | null, result: Buffer) { + if (err) { + reject(err); + } + + dataAsBuffer = result; + handleEncoding(); + }); + } else { + reject(new Error('Unsupported content encoding, ' + encoding)); + } + } else { + data.data = dataAsBuffer; + + resolve(message); + } + }; + + handleEncoding(); + }); + }); + }, + () => { + request.abort(); + } + ); + + const data: RequestData = { + task, + buffer: [], + data: Buffer.alloc(0), + size: 0, + used: false, + url: url, + requestOptions: options, + nativeResponse: message, + downloadObservable: new Observable((observer) => downloadSubscriptionPool.add(observer)), + dataObservable: new Observable((observer) => dataSubscriptionPool.add(observer)) + }; + + dataMap.set(response, data); + + resolve(response); + }); + + request.once('error', reject); + + if (options.bodyStream) { + options.bodyStream.pipe(request); + let uploadedSize = 0; + + options.bodyStream.on('data', (chunk: any) => { + uploadedSize += chunk.length; + uploadObserverPool.next(uploadedSize); + }); + + options.bodyStream.on('end', () => { + uploadObserverPool.complete(); + request.end(); + }); + } else if (options.body) { + const body = options.body.toString(); + + request.on('response', () => { + uploadObserverPool.next(body.length); + }); + + request.end(body); + } else { + request.end(); + } + + if (options.timeout && options.timeout > 0 && options.timeout !== Infinity) { + timeoutHandle = createTimer(() => { + timeoutReject && timeoutReject(new TimeoutError('The request timed out')); + }, options.timeout); + } + }, + () => { + request.abort(); + } + ).catch(function(error: Error): any { + const parsedUrl = urlUtil.parse(url); + + if (parsedUrl.auth) { + parsedUrl.auth = '(redacted)'; + } + + const sanitizedUrl = urlUtil.format(parsedUrl); + + error.message = '[' + requestOptions.method + ' ' + sanitizedUrl + '] ' + error.message; + throw error; + }); + + requestTask.upload = new Observable((observer) => uploadObserverPool.add(observer)); + + return requestTask; +} diff --git a/src/lib/core/src/request/providers/xhr.ts b/src/lib/core/src/request/providers/xhr.ts new file mode 100644 index 0000000..030a0d6 --- /dev/null +++ b/src/lib/core/src/request/providers/xhr.ts @@ -0,0 +1,333 @@ +import { Handle } from '../../interfaces'; +import global from '@dojo/shim/global'; +import WeakMap from '@dojo/shim/WeakMap'; +import Task, { State } from '../../async/Task'; +import has from '../../has'; +import Observable from '../../Observable'; +import { createTimer } from '../../util'; +import Headers from '../Headers'; +import { RequestOptions, UploadObservableTask } from '../interfaces'; +import Response, { getArrayBufferFromBlob, getTextFromBlob } from '../Response'; +import SubscriptionPool from '../SubscriptionPool'; +import TimeoutError from '../TimeoutError'; +import { generateRequestUrl } from '../util'; + +/** + * Request options specific to an XHR request + */ +export interface XhrRequestOptions extends RequestOptions { + /** + * Controls whether or not the request is synchronous (blocks the main thread) or asynchronous (default). + */ + blockMainThread?: boolean; + /** + * Controls whether or not the X-Requested-With header is added to the request (default true). Set to false to not + * include the header. + */ + includeRequestedWithHeader?: boolean; + /** + * Controls whether or not to subscribe to events on `XMLHttpRequest.upload`, if available. This causes all requests + * to be preflighted (https://xhr.spec.whatwg.org/#request) + */ + includeUploadProgress?: boolean; +} + +interface RequestData { + task: Task; + used: boolean; + requestOptions: XhrRequestOptions; + nativeResponse: XMLHttpRequest; + url: string; + downloadObservable: Observable; + dataObservable: Observable; +} + +const dataMap = new WeakMap(); + +function getDataTask(response: XhrResponse): Task { + const data = dataMap.get(response)!; + + if (data.used) { + return Task.reject(new TypeError('Body already read')); + } + + data.used = true; + + return data.task; +} + +/** + * Wraps an XHR request in a response that mimics the fetch API + */ +export class XhrResponse extends Response { + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + + get bodyUsed(): boolean { + return dataMap.get(this)!.used; + } + + get nativeResponse(): XMLHttpRequest { + return dataMap.get(this)!.nativeResponse; + } + + get requestOptions(): XhrRequestOptions { + return dataMap.get(this)!.requestOptions; + } + + get url(): string { + return dataMap.get(this)!.url; + } + + get download(): Observable { + return dataMap.get(this)!.downloadObservable; + } + + get data(): Observable { + return dataMap.get(this)!.dataObservable; + } + + constructor(request: XMLHttpRequest) { + super(); + + const headers = (this.headers = new Headers()); + + const responseHeaders = request.getAllResponseHeaders(); + if (responseHeaders) { + const lines = responseHeaders.split(/\r\n/g); + + for (let i = 0; i < lines.length; i++) { + const match = lines[i].match(/^(.*?): (.*)$/); + if (match) { + headers.append(match[1], match[2]); + } + } + } + + this.status = request.status; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = request.statusText || 'OK'; + } + + arrayBuffer(): Task { + return Task.reject(new Error('ArrayBuffer not supported')); + } + + blob(): Task { + return Task.reject(new Error('Blob not supported')); + } + + formData(): Task { + return Task.reject(new Error('FormData not supported')); + } + + text(): Task { + return getDataTask(this).then((request: XMLHttpRequest) => { + return String(request.responseText); + }); + } + + xml(): Task { + return this.text().then((text: string) => { + const parser = new DOMParser(); + return parser.parseFromString(text, this.headers.get('content-type') || 'text/html'); + }); + } +} + +if (has('blob')) { + XhrResponse.prototype.blob = function(this: XhrResponse): Task { + return getDataTask(this).then((request: XMLHttpRequest) => request.response); + }; + + XhrResponse.prototype.text = function(this: XhrResponse): Task { + return this.blob().then(getTextFromBlob); + }; + + if (has('arraybuffer')) { + XhrResponse.prototype.arrayBuffer = function(this: XhrResponse): Task { + return this.blob().then(getArrayBufferFromBlob); + }; + } +} + +if (has('formdata')) { + XhrResponse.prototype.formData = function(this: XhrResponse): Task { + return this.text().then((text: string) => { + const data = new FormData(); + + text + .trim() + .split('&') + .forEach((keyValues) => { + if (keyValues) { + const pairs = keyValues.split('='); + const name = (pairs.shift() || '').replace(/\+/, ' '); + const value = pairs.join('=').replace(/\+/, ' '); + + data.append(decodeURIComponent(name), decodeURIComponent(value)); + } + }); + + return data; + }); + }; +} + +function noop() {} + +function setOnError(request: XMLHttpRequest, reject: Function) { + request.addEventListener('error', function(event) { + reject(new TypeError(event.error || 'Network request failed')); + }); +} + +export default function xhr(url: string, options: XhrRequestOptions = {}): UploadObservableTask { + const request = new XMLHttpRequest(); + const requestUrl = generateRequestUrl(url, options); + + options = Object.create(options); + + if (!options.method) { + options.method = 'GET'; + } + + let isAborted = false; + + function abort() { + isAborted = true; + if (request) { + request.abort(); + request.onreadystatechange = noop; + } + } + + let timeoutHandle: Handle; + let timeoutReject: Function; + + const task = >new Task((resolve, reject) => { + timeoutReject = reject; + + request.onreadystatechange = function() { + if (isAborted) { + return; + } + + if (request.readyState === 2) { + const response = new XhrResponse(request); + + const downloadSubscriptionPool = new SubscriptionPool(); + const dataSubscriptionPool = new SubscriptionPool(); + + const task = new Task((resolve, reject) => { + timeoutReject = reject; + + request.onprogress = function(event: any) { + if (isAborted) { + return; + } + + downloadSubscriptionPool.next(event.loaded); + }; + + request.onreadystatechange = function() { + if (isAborted) { + return; + } + + if (request.readyState === 4) { + request.onreadystatechange = noop; + timeoutHandle && timeoutHandle.destroy(); + + dataSubscriptionPool.next(request.response); + dataSubscriptionPool.complete(); + + resolve(request); + } + }; + + setOnError(request, reject); + }, abort); + + dataMap.set(response, { + task, + used: false, + nativeResponse: request, + requestOptions: options, + url: requestUrl, + downloadObservable: new Observable((observer) => downloadSubscriptionPool.add(observer)), + dataObservable: new Observable((observer) => dataSubscriptionPool.add(observer)) + }); + + resolve(response); + } + }; + + setOnError(request, reject); + }, abort); + + request.open(options.method, requestUrl, !options.blockMainThread, options.user, options.password); + + if (has('filereader') && has('blob')) { + request.responseType = 'blob'; + } + + if (options.timeout && options.timeout > 0 && options.timeout !== Infinity) { + timeoutHandle = createTimer(() => { + // Reject first, since aborting will also fire onreadystatechange which would reject with a + // less specific error. (This is also why we set up our own timeout rather than using + // native timeout and ontimeout, because that aborts and fires onreadystatechange before ontimeout.) + timeoutReject && timeoutReject(new TimeoutError('The XMLHttpRequest request timed out')); + abort(); + }, options.timeout); + } + + let hasContentTypeHeader = false; + let hasRequestedWithHeader = false; + const { includeRequestedWithHeader = true, includeUploadProgress = true } = options; + + if (options.headers) { + const requestHeaders = new Headers(options.headers); + + hasRequestedWithHeader = requestHeaders.has('x-requested-with'); + hasContentTypeHeader = requestHeaders.has('content-type'); + + for (const [key, value] of requestHeaders) { + request.setRequestHeader(key, value); + } + } + + if (!hasRequestedWithHeader && includeRequestedWithHeader) { + request.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); + } + + if (!hasContentTypeHeader && has('formdata') && options.body instanceof global.FormData) { + // Assume that most forms do not contain large binary files. If that is not the case, + // then "multipart/form-data" should be manually specified as the "Content-Type" header. + request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + } + + task.finally(() => { + if (task.state !== State.Fulfilled) { + request.onreadystatechange = noop; + timeoutHandle && timeoutHandle.destroy(); + } + }); + + if (includeUploadProgress) { + const uploadObserverPool = new SubscriptionPool(); + task.upload = new Observable((observer) => uploadObserverPool.add(observer)); + + if (has('host-browser') || has('web-worker-xhr-upload')) { + request.upload.addEventListener('progress', (event) => { + uploadObserverPool.next(event.loaded); + }); + } + } + + request.send(options.body || null); + + return task; +} diff --git a/src/lib/core/src/request/util.ts b/src/lib/core/src/request/util.ts new file mode 100644 index 0000000..36e27a3 --- /dev/null +++ b/src/lib/core/src/request/util.ts @@ -0,0 +1,28 @@ +import { RequestOptions } from './interfaces'; +import UrlSearchParams from '../UrlSearchParams'; + +/** + * Returns a URL formatted with optional query string and cache-busting segments. + * + * @param url The base URL. + * @param options The RequestOptions used to generate the query string or cacheBust. + */ +export function generateRequestUrl(url: string, options: RequestOptions = {}): string { + let query = new UrlSearchParams(options.query).toString(); + if (options.cacheBust) { + const bustString = String(Date.now()); + query += query ? `&${bustString}` : bustString; + } + const separator = url.indexOf('?') > -1 ? '&' : '?'; + return query ? `${url}${separator}${query}` : url; +} + +export function getStringFromFormData(formData: any): string { + const fields: string[] = []; + + for (const key of formData.keys()) { + fields.push(encodeURIComponent(key) + '=' + encodeURIComponent(formData.get(key))); + } + + return fields.join('&'); +} diff --git a/src/lib/core/src/stringExtras.ts b/src/lib/core/src/stringExtras.ts new file mode 100644 index 0000000..37b8bee --- /dev/null +++ b/src/lib/core/src/stringExtras.ts @@ -0,0 +1,39 @@ +import { Hash } from './interfaces'; + +const escapeRegExpPattern = /[[\]{}()|\/\\^$.*+?]/g; +const escapeXmlPattern = /[&<]/g; +const escapeXmlForPattern = /[&<>'"]/g; +const escapeXmlMap: Hash = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' +}; + +/** + * Escapes a string so that it can safely be passed to the RegExp constructor. + * @param text The string to be escaped + * @return The escaped string + */ +export function escapeRegExp(text: string): string { + return !text ? text : text.replace(escapeRegExpPattern, '\\$&'); +} + +/** + * Sanitizes a string to protect against tag injection. + * @param xml The string to be escaped + * @param forAttribute Whether to also escape ', ", and > in addition to < and & + * @return The escaped string + */ +export function escapeXml(xml: string, forAttribute: boolean = true): string { + if (!xml) { + return xml; + } + + const pattern = forAttribute ? escapeXmlForPattern : escapeXmlPattern; + + return xml.replace(pattern, function(character: string): string { + return escapeXmlMap[character]; + }); +} diff --git a/src/lib/core/src/text.ts b/src/lib/core/src/text.ts new file mode 100644 index 0000000..257389a --- /dev/null +++ b/src/lib/core/src/text.ts @@ -0,0 +1,116 @@ +import Promise from '@dojo/shim/Promise'; +import has from './has'; +import request from './request'; +import { NodeRequire, AmdRequire, AmdConfig } from './interfaces'; +import { Require, isAmdRequire } from './load'; + +declare const require: Require; + +/* + * Strips declarations so that external SVG and XML + * documents can be added to a document without worry. Also, if the string + * is an HTML document, only the part inside the body tag is returned. + */ +function strip(text: string): string { + if (!text) { + return ''; + } + + text = text.replace(/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, ''); + let matches = text.match(/]*>\s*([\s\S]+)\s*<\/body>/im); + text = matches ? matches[1] : text; + + return text; +} + +/* + * Host-specific method to retrieve text + */ +let getText: (url: string, callback: (value: string | null) => void) => void; + +if (has('host-browser')) { + getText = function(url: string, callback: (value: string | null) => void): void { + request(url).then((response) => { + response.text().then((data) => { + callback(data); + }); + }); + }; +} else if (has('host-node')) { + let fs = isAmdRequire(require) && require.nodeRequire ? require.nodeRequire('fs') : (require)('fs'); + getText = function(url: string, callback: (value: string) => void): void { + fs.readFile(url, { encoding: 'utf8' }, function(error: Error, data: string): void { + if (error) { + throw error; + } + + callback(data); + }); + }; +} else { + getText = function(): void { + throw new Error('dojo/text not supported on this platform'); + }; +} + +/* + * Cache of previously-loaded text resources + */ +let textCache: { [key: string]: any } = {}; + +/* + * Cache of pending text resources + */ +let pending: { [key: string]: any } = {}; + +export function get(url: string): Promise { + let promise = new Promise(function(resolve, reject) { + getText(url, function(text) { + resolve(text); + }); + }); + + return promise; +} + +export function normalize(id: string, toAbsMid: (moduleId: string) => string): string { + let parts = id.split('!'); + let url = parts[0]; + + return (/^\./.test(url) ? toAbsMid(url) : url) + (parts[1] ? '!' + parts[1] : ''); +} + +export function load(id: string, require: AmdRequire, load: (value?: any) => void, config?: AmdConfig): void { + let parts = id.split('!'); + let stripFlag = parts.length > 1; + let mid = parts[0]; + let url = require.toUrl(mid); + let text: string | undefined; + + function finish(text: string): void { + load(stripFlag ? strip(text) : text); + } + + if (mid in textCache) { + text = textCache[mid]; + } else if (url in textCache) { + text = textCache[url]; + } + + if (!text) { + if (pending[url]) { + pending[url].push(finish); + } else { + let pendingList = (pending[url] = [finish]); + getText(url, function(value) { + textCache[mid] = textCache[url] = value; + for (let i = 0; i < pendingList.length; ) { + pendingList[i++](value || ''); + } + delete pending[url]; + }); + } + } else { + finish(text); + } +} diff --git a/src/lib/core/src/util.ts b/src/lib/core/src/util.ts new file mode 100644 index 0000000..fe1437f --- /dev/null +++ b/src/lib/core/src/util.ts @@ -0,0 +1,122 @@ +import { Handle } from './interfaces'; +import { createHandle } from './lang'; + +/** + * Wraps a setTimeout call in a handle, allowing the timeout to be cleared by calling destroy. + * + * @param callback Callback to be called when the timeout elapses + * @param delay Number of milliseconds to wait before calling the callback + * @return Handle which can be destroyed to clear the timeout + */ +export function createTimer(callback: (...args: any[]) => void, delay?: number): Handle { + let timerId: number | null = setTimeout(callback, delay); + + return createHandle(function() { + if (timerId) { + clearTimeout(timerId); + timerId = null; + } + }); +} + +/** + * Wraps a callback, returning a function which fires after no further calls are received over a set interval. + * + * @param callback Callback to wrap + * @param delay Number of milliseconds to wait after any invocations before calling the original callback + * @return Debounced function + */ +export function debounce void>(callback: T, delay: number): T { + // node.d.ts clobbers setTimeout/clearTimeout with versions that return/receive NodeJS.Timer, + // but browsers return/receive a number + let timer: Handle | null; + + return function() { + timer && timer.destroy(); + + let context = this; + let args: IArguments | null = arguments; + + timer = guaranteeMinimumTimeout(function() { + callback.apply(context, args); + args = context = timer = null; + }, delay); + }; +} + +/** + * Wraps a callback, returning a function which fires at most once per set interval. + * + * @param callback Callback to wrap + * @param delay Number of milliseconds to wait before allowing the original callback to be called again + * @return Throttled function + */ +export function throttle void>(callback: T, delay: number): T { + let ran: boolean | null; + + return function() { + if (ran) { + return; + } + + ran = true; + + callback.apply(this, arguments); + guaranteeMinimumTimeout(function() { + ran = null; + }, delay); + }; +} + +/** + * Like throttle, but calls the callback at the end of each interval rather than the beginning. + * Useful for e.g. resize or scroll events, when debounce would appear unresponsive. + * + * @param callback Callback to wrap + * @param delay Number of milliseconds to wait before calling the original callback and allowing it to be called again + * @return Throttled function + */ +export function throttleAfter void>(callback: T, delay: number): T { + let ran: boolean | null; + + return function() { + if (ran) { + return; + } + + ran = true; + + let context = this; + let args: IArguments | null = arguments; + + guaranteeMinimumTimeout(function() { + callback.apply(context, args); + args = context = ran = null; + }, delay); + }; +} + +export function guaranteeMinimumTimeout(callback: (...args: any[]) => void, delay?: number): Handle { + const startTime = Date.now(); + let timerId: number | null; + + function timeoutHandler() { + const delta = Date.now() - startTime; + if (delay == null || delta >= delay) { + callback(); + } else { + // Cast setTimeout return value to fix TypeScript parsing bug. Without it, + // it thinks we are using the Node version of setTimeout. + // Revisit this with the next TypeScript update. + // Set another timer for the mount of time that we came up short. + timerId = setTimeout(timeoutHandler, delay - delta); + } + } + timerId = setTimeout(timeoutHandler, delay); + return createHandle(() => { + if (timerId != null) { + clearTimeout(timerId); + timerId = null; + } + }); +} diff --git a/src/lib/core/src/uuid.ts b/src/lib/core/src/uuid.ts new file mode 100644 index 0000000..7ba5eed --- /dev/null +++ b/src/lib/core/src/uuid.ts @@ -0,0 +1,12 @@ +/** + * Returns a v4 compliant UUID. + * + * @returns {string} + */ +export default function uuid(): string { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + const r = (Math.random() * 16) | 0, + v = c === 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +} diff --git a/src/lib/core/tests/benchmark/all.ts b/src/lib/core/tests/benchmark/all.ts new file mode 100644 index 0000000..4b85c8a --- /dev/null +++ b/src/lib/core/tests/benchmark/all.ts @@ -0,0 +1,2 @@ +import './lang'; +import './stringExtras'; diff --git a/src/lib/core/tests/benchmark/lang.ts b/src/lib/core/tests/benchmark/lang.ts new file mode 100644 index 0000000..53d7ea7 --- /dev/null +++ b/src/lib/core/tests/benchmark/lang.ts @@ -0,0 +1,269 @@ +import Benchmark = require('benchmark'); +import lang = require('../../src/lang'); + +function onComplete(this: any) { + console.log(this.name + ': ' + this.hz + ' with a margin of error of ' + this.stats.moe); +} + +const simpleSource = { a: 1, b: 'Lorem ipsum', c: 4 }; +const simpleSourceWithArray = { + a: 1, + b: 'Dolor sit amet.', + c: [1, 2, 3], + d: 5 +}; +const sourceFromConstructor = (function() { + function Answers(this: any, kwArgs: { [key: string]: any }) { + Object.keys(kwArgs).forEach(function(this: any, key: string): void { + (this)[key] = kwArgs[key]; + }, this); + } + + return new (Answers)({ + universe: 42 + }); +})(); +const sourceWithInherited = Object.create( + Object.create(null, { + x: { + value: '1234567890'.split('') + }, + y: { + enumerable: true, + value: /\s/ + } + }), + { + a: { + value: 1, + enumerable: true, + configurable: true, + writable: true + }, + b: { + value: 'Lorem ipsum', + enumerable: true, + configurable: true, + writable: true + }, + c: { + value: [], + enumerable: true, + configurable: true, + writable: true + }, + d: { + value: 4, + enumerable: true, + configurable: true, + writable: true + } + } +); + +let benchmarks: Benchmark[] = []; + +benchmarks.push( + new Benchmark( + 'lang.assign (single source)', + function() { + lang.assign(Object.create(null), simpleSource); + }, + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.assign (multiple sources)', + function() { + lang.assign( + Object.create(null), + simpleSource, + simpleSourceWithArray, + sourceWithInherited, + sourceFromConstructor + ); + }, + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.deepAssign (single source)', + function() { + lang.deepAssign(Object.create(null), simpleSource); + }, + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.deepAssign (multiple sources)', + function() { + lang.deepAssign( + Object.create(null), + simpleSource, + simpleSourceWithArray, + sourceWithInherited, + sourceFromConstructor + ); + }, + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.mixin (single source)', + function() { + lang.mixin(Object.create(null), simpleSource); + }, + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.mixin (multiple sources)', + function() { + lang.mixin( + Object.create(null), + simpleSource, + simpleSourceWithArray, + sourceWithInherited, + sourceFromConstructor + ); + }, + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.deepMixin (single source)', + function() { + lang.deepMixin(Object.create(null), simpleSource); + }, + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.deepMixin (multiple sources)', + function() { + lang.deepMixin( + Object.create(null), + simpleSource, + simpleSourceWithArray, + sourceWithInherited, + sourceFromConstructor + ); + }, + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.create', + function() { + lang.create(simpleSource, simpleSource, simpleSource, simpleSource); + }, + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.isIdentical', + (function() { + let a = Number('asdfx{}'); + let b = Number('xkcd'); + + return function() { + lang.isIdentical(a, b); + }; + })(), + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.lateBind', + (function() { + let object: any = { + method: function() {} + }; + + return function() { + lang.lateBind(object, 'method'); + }; + })(), + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.lateBind (partial application)', + (function() { + let object: any = { + method: function() {} + }; + + return function() { + lang.lateBind(object, 'method', 1, 2, 3); + }; + })(), + { + onComplete: onComplete + } + ) +); + +benchmarks.push( + new Benchmark( + 'lang.partial', + (function() { + function f() {} + + return function() { + lang.partial(f, 1, 2, 3); + }; + })(), + { + onComplete: onComplete + } + ) +); + +benchmarks.forEach(function(benchmark: Benchmark): void { + benchmark.run(); +}); diff --git a/src/lib/core/tests/benchmark/stringExtras.ts b/src/lib/core/tests/benchmark/stringExtras.ts new file mode 100644 index 0000000..06bc389 --- /dev/null +++ b/src/lib/core/tests/benchmark/stringExtras.ts @@ -0,0 +1,11 @@ +import Benchmark = require('benchmark'); + +let benchmarks: any[] = []; + +benchmarks.forEach(function(benchmark: any): void { + new Benchmark(benchmark.name, benchmark.fn, { + onComplete: function(this: any) { + console.log(this.name + ': ' + this.hz + ' with a margin of error of ' + this.stats.moe); + } + }).run(); +}); diff --git a/src/lib/core/tests/functional/all.ts b/src/lib/core/tests/functional/all.ts new file mode 100644 index 0000000..64347dc --- /dev/null +++ b/src/lib/core/tests/functional/all.ts @@ -0,0 +1 @@ +import './text/textPlugin'; diff --git a/src/lib/core/tests/functional/text/textPlugin.html b/src/lib/core/tests/functional/text/textPlugin.html new file mode 100644 index 0000000..223ede2 --- /dev/null +++ b/src/lib/core/tests/functional/text/textPlugin.html @@ -0,0 +1,30 @@ + + + + + Text Plugin Test + + + + + + + + diff --git a/src/lib/core/tests/functional/text/textPlugin.ts b/src/lib/core/tests/functional/text/textPlugin.ts new file mode 100644 index 0000000..3326eac --- /dev/null +++ b/src/lib/core/tests/functional/text/textPlugin.ts @@ -0,0 +1,44 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import Test from 'intern/lib/Test'; +import pollUntil from '@theintern/leadfoot/helpers/pollUntil'; + +async function executeTest(test: Test, htmlTestPath: string, timeout = 10000) { + try { + return await test.remote.get(htmlTestPath).then( + pollUntil<{ text: string }>( + function() { + return (window).loaderTestResults || null; + }, + undefined, + timeout + ) + ); + } catch (e) { + throw new Error('loaderTestResult was not set.'); + } +} + +const text = 'abc'; + +registerSuite('text plugin', { + async 'correct text'() { + const results = await executeTest(this, `${__dirname}/textPlugin.html`); + assert.strictEqual(results.text, text); + }, + + async 'strips XML'(this: any) { + const results = await executeTest(this, `${__dirname}/textPluginXML.html`); + assert.strictEqual(results.text, text); + }, + + async 'strips HTML'(this: any) { + const results = await executeTest(this, `${__dirname}/textPluginHTML.html`); + assert.strictEqual(results.text, text); + }, + + async 'strips empty file'(this: any) { + const results = await executeTest(this, `${__dirname}/textPluginEmpty.html`); + assert.strictEqual(results.text, ''); + } +}); diff --git a/src/lib/core/tests/functional/text/textPluginEmpty.html b/src/lib/core/tests/functional/text/textPluginEmpty.html new file mode 100644 index 0000000..e163b2e --- /dev/null +++ b/src/lib/core/tests/functional/text/textPluginEmpty.html @@ -0,0 +1,30 @@ + + + + + Text Plugin Test + + + + + + + + diff --git a/src/lib/core/tests/functional/text/textPluginHTML.html b/src/lib/core/tests/functional/text/textPluginHTML.html new file mode 100644 index 0000000..d367ace --- /dev/null +++ b/src/lib/core/tests/functional/text/textPluginHTML.html @@ -0,0 +1,30 @@ + + + + + Text Plugin Test + + + + + + + + diff --git a/src/lib/core/tests/functional/text/textPluginXML.html b/src/lib/core/tests/functional/text/textPluginXML.html new file mode 100644 index 0000000..570c567 --- /dev/null +++ b/src/lib/core/tests/functional/text/textPluginXML.html @@ -0,0 +1,30 @@ + + + + + Text Plugin Test + + + + + + + + diff --git a/src/lib/core/tests/plugins/echo-service.ts b/src/lib/core/tests/plugins/echo-service.ts new file mode 100644 index 0000000..d55a942 --- /dev/null +++ b/src/lib/core/tests/plugins/echo-service.ts @@ -0,0 +1,50 @@ +import * as express from 'express'; +import * as multer from 'multer'; +import * as path from 'path'; + +intern.registerPlugin('echo-service', () => { + intern.on('serverStart', (server) => { + const app: express.Express = (server)._app; + const echo = express(); + const upload = multer(); + + echo.use((request, _, next) => { + if (request.query.delay) { + setTimeout(() => next(), Number(request.query.delay)); + return; + } + next(); + }); + + echo.post('/post', upload.any()); + + echo.use((request, response, next) => { + const responseType: string | undefined = request.query.responseType; + if (!responseType || responseType.localeCompare('json') === 0) { + response + .status(200) + .type('json') + .send({ + method: request.method, + query: request.query, + headers: request.headers, + payload: request.files || request.body + }); + } else { + if (responseType.localeCompare('xml') === 0) { + response.sendFile(path.resolve(__dirname, '..', 'support', 'data', 'foo.xml')); + return; + } + next(); + } + }, express.static(path.resolve(__dirname, '..', 'support', 'data'), { fallthrough: false })); + + // A hack until Intern allows custom middleware + const stack: any[] = (app)._router.stack; + const layers = stack.splice(stack.length - 3); + + app.use('/__echo', echo); + + stack.push(...layers); + }); +}); diff --git a/src/lib/core/tests/run.html b/src/lib/core/tests/run.html new file mode 100644 index 0000000..872415e --- /dev/null +++ b/src/lib/core/tests/run.html @@ -0,0 +1,11 @@ + + + + + Intern suite + + + + Redirecting to Intern client + + diff --git a/src/lib/core/tests/support/data/blob.gif b/src/lib/core/tests/support/data/blob.gif new file mode 100644 index 0000000..4bcc753 Binary files /dev/null and b/src/lib/core/tests/support/data/blob.gif differ diff --git a/src/lib/core/tests/support/data/correctText.txt b/src/lib/core/tests/support/data/correctText.txt new file mode 100644 index 0000000..f2ba8f8 --- /dev/null +++ b/src/lib/core/tests/support/data/correctText.txt @@ -0,0 +1 @@ +abc \ No newline at end of file diff --git a/src/lib/core/tests/support/data/foo.html b/src/lib/core/tests/support/data/foo.html new file mode 100644 index 0000000..74e7b02 --- /dev/null +++ b/src/lib/core/tests/support/data/foo.html @@ -0,0 +1,10 @@ + + + + + Foo + + +

Bar

+ + diff --git a/src/lib/core/tests/support/data/foo.json b/src/lib/core/tests/support/data/foo.json new file mode 100644 index 0000000..8c850a5 --- /dev/null +++ b/src/lib/core/tests/support/data/foo.json @@ -0,0 +1 @@ +{ "foo": "bar" } diff --git a/src/lib/core/tests/support/data/foo.xml b/src/lib/core/tests/support/data/foo.xml new file mode 100644 index 0000000..4ff9b6a --- /dev/null +++ b/src/lib/core/tests/support/data/foo.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/lib/core/tests/support/data/strip.html b/src/lib/core/tests/support/data/strip.html new file mode 100644 index 0000000..480b26d --- /dev/null +++ b/src/lib/core/tests/support/data/strip.html @@ -0,0 +1,9 @@ + + + + + HTML Strip Test + + + abc + \ No newline at end of file diff --git a/src/lib/core/tests/support/data/strip.xml b/src/lib/core/tests/support/data/strip.xml new file mode 100644 index 0000000..5d9dbfa --- /dev/null +++ b/src/lib/core/tests/support/data/strip.xml @@ -0,0 +1 @@ +abc \ No newline at end of file diff --git a/src/lib/core/tests/support/data/stripEmpty.xml b/src/lib/core/tests/support/data/stripEmpty.xml new file mode 100644 index 0000000..e69de29 diff --git a/src/lib/core/tests/support/data/textLoad.txt b/src/lib/core/tests/support/data/textLoad.txt new file mode 100644 index 0000000..30d74d2 --- /dev/null +++ b/src/lib/core/tests/support/data/textLoad.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/src/lib/core/tests/support/load/a.ts b/src/lib/core/tests/support/load/a.ts new file mode 100644 index 0000000..707bad2 --- /dev/null +++ b/src/lib/core/tests/support/load/a.ts @@ -0,0 +1,5 @@ +export const one = 1; +export const two = 2; + +const a = 'A'; +export default a; diff --git a/src/lib/core/tests/support/load/b.ts b/src/lib/core/tests/support/load/b.ts new file mode 100644 index 0000000..c9028aa --- /dev/null +++ b/src/lib/core/tests/support/load/b.ts @@ -0,0 +1,5 @@ +export const three = 3; +export const four = 4; + +const b = 'B'; +export default b; diff --git a/src/lib/core/tests/support/load/c.ts b/src/lib/core/tests/support/load/c.ts new file mode 100644 index 0000000..d3ef374 --- /dev/null +++ b/src/lib/core/tests/support/load/c.ts @@ -0,0 +1,2 @@ +export const five = 5; +export const six = 6; diff --git a/src/lib/core/tests/support/load/node.ts b/src/lib/core/tests/support/load/node.ts new file mode 100644 index 0000000..9280284 --- /dev/null +++ b/src/lib/core/tests/support/load/node.ts @@ -0,0 +1,14 @@ +import load from '../../../src/load'; +import { useDefault } from '../../../src/load/util'; +import { Require } from '../../../src/load'; + +declare const require: Require; + +export const succeed = load.bind(null, require, './a', './b'); +export const succeedDefault = () => { + return load(require, './a', './b').then(useDefault); +}; +export const fail = load.bind(null, require, './a', './nonexistent'); + +export const globalSucceed = load.bind(null, 'fs', 'path'); +export const globalFail = load.bind(null, 'fs', './a'); diff --git a/src/lib/core/tests/support/load/plugin-default.ts b/src/lib/core/tests/support/load/plugin-default.ts new file mode 100644 index 0000000..dc602a6 --- /dev/null +++ b/src/lib/core/tests/support/load/plugin-default.ts @@ -0,0 +1,10 @@ +import Promise from '@dojo/shim/Promise'; +const plugin = { + load(resourceId: string) { + return Promise.resolve(resourceId); + }, + normalize(moduleId: string) { + return moduleId === 'normalize' ? 'path/to/normalized' : moduleId; + } +}; +export default plugin; diff --git a/src/lib/core/tests/support/load/plugin.ts b/src/lib/core/tests/support/load/plugin.ts new file mode 100644 index 0000000..2aa769f --- /dev/null +++ b/src/lib/core/tests/support/load/plugin.ts @@ -0,0 +1,5 @@ +import Promise from '@dojo/shim/Promise'; + +export function load(resourceId: string) { + return Promise.resolve(resourceId); +} diff --git a/src/lib/core/tests/support/util.ts b/src/lib/core/tests/support/util.ts new file mode 100644 index 0000000..46eb5b5 --- /dev/null +++ b/src/lib/core/tests/support/util.ts @@ -0,0 +1,27 @@ +export function isEventuallyRejected(promise: PromiseLike): PromiseLike { + return promise.then( + function() { + throw new Error('unexpected code path'); + }, + function() { + return true; // expect rejection + } + ); +} + +export function throwImmediatly() { + throw new Error('unexpected code path'); +} + +let _hasClassName: boolean; + +/** + * Detects if the runtime environment supports a class name + */ +export function hasClassName(): boolean { + if (_hasClassName !== undefined) { + return _hasClassName; + } + class Foo {} + return (_hasClassName = Boolean((Foo.constructor).name)); +} diff --git a/src/lib/core/tests/unit/DateObject.ts b/src/lib/core/tests/unit/DateObject.ts new file mode 100644 index 0000000..a83141e --- /dev/null +++ b/src/lib/core/tests/unit/DateObject.ts @@ -0,0 +1,443 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import DateObject, { KwArgs, OperationKwArgs, DateProperties } from '../../src/DateObject'; + +let date: Date; +let object: DateObject; + +function assertPropertiesEqual(left: DateProperties, right: DateProperties): void { + assert.strictEqual(left.isLeapYear, right.isLeapYear); + assert.strictEqual(left.daysInMonth, right.daysInMonth); + assert.strictEqual(left.year, right.year); + assert.strictEqual(left.month, right.month); + assert.strictEqual(left.dayOfMonth, right.dayOfMonth); + assert.strictEqual(left.hours, right.hours); + assert.strictEqual(left.minutes, right.minutes); + assert.strictEqual(left.seconds, right.seconds); + assert.strictEqual(left.milliseconds, right.milliseconds); + assert.strictEqual(left.dayOfWeek, right.dayOfWeek); +} + +registerSuite('DateObject', { + creation: function() { + const date = new Date(); + let object = new DateObject(); + + assert.closeTo(object.valueOf(), +date, 100); + + object = new DateObject(date); + assert.strictEqual(object.valueOf(), +date); + + object = new DateObject(+date); + assert.strictEqual(object.valueOf(), +date); + + object = new DateObject(date.toISOString()); + assert.strictEqual(object.valueOf(), +date); + + object = new DateObject({ + year: date.getFullYear(), + month: date.getMonth() + 1 + }); + date.setDate(1); + date.setHours(0, 0, 0, 0); + assert.strictEqual(object.valueOf(), +date); + }, + + properties: { + beforeEach: function() { + date = new Date(); + object = new DateObject(date); + }, + + tests: { + year: function() { + assert.strictEqual(object.year, date.getFullYear()); + date.setFullYear((object.year = 1)); + assert.strictEqual(object.year, date.getFullYear()); + + object = new DateObject({ year: 2005, month: 12, dayOfMonth: 27 }); + object.year += 1; + assert.strictEqual(+object, +new Date(2006, 11, 27)); + + object = new DateObject({ year: 2005, month: 12, dayOfMonth: 27 }); + object.year -= 1; + assert.strictEqual(+object, +new Date(2004, 11, 27)); + + object = new DateObject({ year: 2000, month: 2, dayOfMonth: 29 }); + object.year += 1; + assert.strictEqual(+object, +new Date(2001, 1, 28)); + + object = new DateObject({ year: 2000, month: 2, dayOfMonth: 29 }); + object.year += 5; + assert.strictEqual(+object, +new Date(2005, 1, 28)); + + object = new DateObject({ year: 1900, month: 12, dayOfMonth: 31 }); + object.year += 30; + assert.strictEqual(+object, +new Date(1930, 11, 31)); + + object = new DateObject({ year: 1995, month: 12, dayOfMonth: 31 }); + object.year += 35; + assert.strictEqual(+object, +new Date(2030, 11, 31)); + }, + + month: function() { + assert.strictEqual(object.month, date.getMonth() + 1); + date.setMonth((object.month = 1) - 1); + assert.strictEqual(object.month, date.getMonth() + 1); + + object = new DateObject({ year: 2000, month: 1, dayOfMonth: 1 }); + object.month += 1; + assert.strictEqual(+object, +new Date(2000, 1, 1)); + + object = new DateObject({ year: 2000, month: 1, dayOfMonth: 31 }); + object.month += 1; + assert.strictEqual(+object, +new Date(2000, 1, 29)); + + object = new DateObject({ year: 2000, month: 2, dayOfMonth: 29 }); + object.month += 12; + assert.strictEqual(+object, +new Date(2001, 1, 28)); + }, + + dayOfMonth: function() { + assert.strictEqual(object.dayOfMonth, date.getDate()); + date.setDate((object.dayOfMonth = 1)); + assert.strictEqual(object.dayOfMonth, date.getDate()); + }, + + hours: function() { + assert.strictEqual(object.hours, date.getHours()); + date.setHours((object.hours = 12)); + assert.strictEqual(object.hours, date.getHours()); + }, + + minutes: function() { + assert.strictEqual(object.minutes, date.getMinutes()); + date.setMinutes((object.minutes = 12)); + assert.strictEqual(object.minutes, date.getMinutes()); + }, + + seconds: function() { + assert.strictEqual(object.seconds, date.getSeconds()); + date.setSeconds((object.seconds = 12)); + assert.strictEqual(object.seconds, date.getSeconds()); + }, + + milliseconds: function() { + assert.strictEqual(object.milliseconds, date.getMilliseconds()); + date.setMilliseconds((object.milliseconds = 12)); + assert.strictEqual(object.milliseconds, date.getMilliseconds()); + }, + + time: function() { + assert.strictEqual(object.time, +date); + date.setTime((object.time = 0)); + assert.strictEqual(object.time, +date); + }, + + dayOfWeek: function() { + assert.strictEqual(object.dayOfWeek, date.getDay()); + }, + + timezoneOffset: function() { + assert.strictEqual(object.timezoneOffset, date.getTimezoneOffset()); + }, + + utc: { + basic: function() { + const date = new Date(1979, 2, 20, 7, 20, 12, 123); + const obj = new DateObject(date); + const utc = obj.utc; + + assertPropertiesEqual(obj.add(60000 * date.getTimezoneOffset()), utc); + }, + + 'leap year': function() { + const date = new Date(2012, 1, 29, 7, 20, 12, 123); + const obj = new DateObject(date); + const utc = obj.utc; + + assertPropertiesEqual(obj.add(60000 * date.getTimezoneOffset()), utc); + }, + + setters: (function() { + function assertChange(property: string, dateProperty: string, value: number = 2) { + const date = new DateObject(); + const time = date.time; + const expectedDate: any = new Date(time); + const initialValue = expectedDate[`getUTC${dateProperty}`](); + expectedDate[`setUTC${dateProperty}`](initialValue + value); + let expected: number = expectedDate[`getUTC${dateProperty}`](); + if (property === 'month') { + // Months are 0-indexed in Date and 1-indexed in DateObject + expected += 1; + } + (date.utc)[property] += value; + + assert.strictEqual((date.utc)[property], expected); + assert.notEqual(date.time, time); + } + + return { + year: function() { + assertChange('year', 'FullYear'); + }, + + month: function() { + assertChange('month', 'Month'); + }, + + dayOfMonth: function() { + assertChange('dayOfMonth', 'Date'); + }, + + hours: function() { + assertChange('hours', 'Hours'); + }, + + minutes: function() { + assertChange('minutes', 'Minutes'); + }, + + seconds: function() { + assertChange('seconds', 'Seconds'); + }, + + milliseconds: function() { + assertChange('milliseconds', 'Milliseconds'); + } + }; + })(), + + toString: function() { + const milliseconds = Date.UTC(1979, 2, 20); + const expected = new Date(milliseconds); + const date = new DateObject(milliseconds); + assert.strictEqual(date.utc.toString(), expected.toUTCString()); + } + } + } + }, + + parse: function() { + const date = DateObject.parse('Tue, 20 Mar 1979 00:00:00'); + assertPropertiesEqual(date, new DateObject(new Date(1979, 2, 20))); + }, + + now: function() { + assert.closeTo(DateObject.now().time, Date.now(), 100); + }, + + '.to* methods': function() { + const date = new Date(); + const object = new DateObject(date); + + assert.strictEqual(object.toString(), date.toString()); + assert.strictEqual(object.toDateString(), date.toDateString()); + assert.strictEqual(object.toTimeString(), date.toTimeString()); + assert.strictEqual(object.toLocaleString(), date.toLocaleString()); + assert.strictEqual(object.toLocaleDateString(), date.toLocaleDateString()); + assert.strictEqual(object.toLocaleTimeString(), date.toLocaleTimeString()); + assert.strictEqual(object.toISOString(), date.toISOString()); + assert.strictEqual(object.toJSON(), date.toJSON()); + }, + + '.add': (function() { + function addAndAssertEqual(kwArgs: KwArgs, addArgs: OperationKwArgs, expected: Date) { + const object = new DateObject(kwArgs); + assert.strictEqual(+object.add(addArgs), +expected); + } + return { + 'returns new object': function() { + const object: DateObject = new DateObject(); + + assert.notStrictEqual(object, object.add(1)); + }, + + years: function() { + addAndAssertEqual({ year: 2005, month: 12, dayOfMonth: 27 }, { years: 1 }, new Date(2006, 11, 27)); + addAndAssertEqual({ year: 2005, month: 12, dayOfMonth: 27 }, { years: -1 }, new Date(2004, 11, 27)); + addAndAssertEqual({ year: 2000, month: 2, dayOfMonth: 29 }, { years: 1 }, new Date(2001, 1, 28)); + addAndAssertEqual({ year: 2000, month: 2, dayOfMonth: 29 }, { years: 5 }, new Date(2005, 1, 28)); + addAndAssertEqual({ year: 1900, month: 12, dayOfMonth: 31 }, { years: 30 }, new Date(1930, 11, 31)); + addAndAssertEqual({ year: 1995, month: 12, dayOfMonth: 31 }, { years: 35 }, new Date(2030, 11, 31)); + }, + + months: function() { + addAndAssertEqual({ year: 2000, month: 1, dayOfMonth: 1 }, { months: 1 }, new Date(2000, 1, 1)); + addAndAssertEqual({ year: 2000, month: 1, dayOfMonth: 31 }, { months: 1 }, new Date(2000, 1, 29)); + addAndAssertEqual({ year: 2000, month: 3, dayOfMonth: 31 }, { months: -1 }, new Date(2000, 1, 29)); + addAndAssertEqual({ year: 2000, month: 2, dayOfMonth: 29 }, { months: 12 }, new Date(2001, 1, 28)); + }, + + days: function() { + addAndAssertEqual({ year: 2000, month: 1, dayOfMonth: 1 }, { days: 1 }, new Date(2000, 0, 2)); + addAndAssertEqual({ year: 2001, month: 1, dayOfMonth: 1 }, { days: 365 }, new Date(2002, 0, 1)); + addAndAssertEqual({ year: 2000, month: 1, dayOfMonth: 1 }, { days: 366 }, new Date(2001, 0, 1)); + addAndAssertEqual({ year: 2000, month: 2, dayOfMonth: 28 }, { days: 1 }, new Date(2000, 1, 29)); + addAndAssertEqual({ year: 2001, month: 2, dayOfMonth: 28 }, { days: 1 }, new Date(2001, 2, 1)); + addAndAssertEqual({ year: 2000, month: 3, dayOfMonth: 1 }, { days: -1 }, new Date(2000, 1, 29)); + addAndAssertEqual({ year: 2001, month: 3, dayOfMonth: 1 }, { days: -1 }, new Date(2001, 1, 28)); + addAndAssertEqual({ year: 2000, month: 1, dayOfMonth: 1 }, { days: -1 }, new Date(1999, 11, 31)); + }, + + hours: function() { + addAndAssertEqual( + { year: 2000, month: 1, dayOfMonth: 1, hours: 11 }, + { hours: 1 }, + new Date(2000, 0, 1, 12) + ); + addAndAssertEqual( + { year: 2001, month: 10, dayOfMonth: 28, hours: 0 }, + { hours: 1 }, + new Date(+new Date(2001, 9, 28, 0) + 60 * 60 * 1000) + ); + addAndAssertEqual( + { year: 2001, month: 10, dayOfMonth: 28, hours: 23 }, + { hours: 1 }, + new Date(2001, 9, 29, 0) + ); + addAndAssertEqual( + { year: 2001, month: 12, dayOfMonth: 31, hours: 23 }, + { hours: 1 }, + new Date(2002, 0, 1, 0) + ); + }, + + minutes: function() { + addAndAssertEqual( + { year: 2000, month: 12, dayOfMonth: 31, hours: 23, minutes: 59 }, + { minutes: 1 }, + new Date(2001, 0, 1, 0, 0) + ); + addAndAssertEqual( + { year: 2000, month: 12, dayOfMonth: 27, hours: 12, minutes: 2 }, + { minutes: 60 }, + new Date(2000, 11, 27, 13, 2) + ); + }, + + seconds: function() { + addAndAssertEqual( + { year: 2000, month: 12, dayOfMonth: 31, hours: 23, minutes: 59, seconds: 59 }, + { seconds: 1 }, + new Date(2001, 0, 1, 0, 0, 0) + ); + addAndAssertEqual( + { year: 2000, month: 12, dayOfMonth: 27, hours: 8, minutes: 10, seconds: 59 }, + { seconds: 60 }, + new Date(2000, 11, 27, 8, 11, 59) + ); + }, + + number: function() { + const date = new DateObject({ year: 2000, month: 2, dayOfMonth: 29 }); + + assert.strictEqual(date.add(100).time, date.time + 100); + } + }; + })(), + + isLeapYear: function() { + const date = new DateObject({ + year: 2006, + month: 1, + dayOfMonth: 1 + }); + + assert.isFalse(date.isLeapYear); + date.year = 2004; + assert.isTrue(date.isLeapYear); + date.year = 2000; + assert.isTrue(date.isLeapYear); + date.year = 1900; + assert.isFalse(date.isLeapYear); + date.year = 1800; + assert.isFalse(date.isLeapYear); + date.year = 1700; + assert.isFalse(date.isLeapYear); + date.year = 1600; + assert.isTrue(date.isLeapYear); + }, + + daysInMonth: function() { + const date = new DateObject({ + year: 2006, + month: 1, + dayOfMonth: 1 + }); + + assert.strictEqual(date.daysInMonth, 31); + date.month = 2; + assert.strictEqual(date.daysInMonth, 28); + date.month = 3; + assert.strictEqual(date.daysInMonth, 31); + date.month = 4; + assert.strictEqual(date.daysInMonth, 30); + date.month = 5; + assert.strictEqual(date.daysInMonth, 31); + date.month = 6; + assert.strictEqual(date.daysInMonth, 30); + date.month = 7; + assert.strictEqual(date.daysInMonth, 31); + date.month = 8; + assert.strictEqual(date.daysInMonth, 31); + date.month = 9; + assert.strictEqual(date.daysInMonth, 30); + date.month = 10; + assert.strictEqual(date.daysInMonth, 31); + date.month = 11; + assert.strictEqual(date.daysInMonth, 30); + date.month = 12; + assert.strictEqual(date.daysInMonth, 31); + + // Februarys + date.month = 2; + date.year = 2004; + assert.strictEqual(date.daysInMonth, 29); + date.year = 2000; + assert.strictEqual(date.daysInMonth, 29); + date.year = 1900; + assert.strictEqual(date.daysInMonth, 28); + date.year = 1800; + assert.strictEqual(date.daysInMonth, 28); + date.year = 1700; + assert.strictEqual(date.daysInMonth, 28); + date.year = 1600; + assert.strictEqual(date.daysInMonth, 29); + }, + + comparisons: (function() { + const younger = new DateObject(new Date(2012, 0, 31, 23, 55)); + const older = new DateObject(new Date(2010, 7, 26, 4, 15)); + + return { + compare: { + 'if date is newer than comparison: return positive': function() { + assert.isTrue(younger.compare(older) > 0); + }, + + 'if date is less recent than comparison: return negative': function() { + assert.isTrue(older.compare(younger) < 0); + }, + + 'if dates are identical: return 0': function() { + assert.strictEqual(younger.compare(younger), 0); + } + }, + + compareDate: function() { + const similarDate1 = new DateObject(new Date(1979, 2, 20, 2, 4, 6)); + const similarDate2 = new DateObject(new Date(1979, 2, 20, 1, 3, 5)); + + assert.strictEqual(similarDate1.compareDate(similarDate2), 0); + }, + + compareTime: function() { + const similarTime1 = new DateObject(new Date(2015, 1, 1, 2, 4, 6)); + const similarTime2 = new DateObject(new Date(1977, 3, 20, 2, 4, 6)); + + assert.strictEqual(similarTime1.compareTime(similarTime2), 0); + } + }; + })() +}); diff --git a/src/lib/core/tests/unit/Destroyable.ts b/src/lib/core/tests/unit/Destroyable.ts new file mode 100644 index 0000000..9f74235 --- /dev/null +++ b/src/lib/core/tests/unit/Destroyable.ts @@ -0,0 +1,80 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { Destroyable } from '../../src/Destroyable'; +import * as sinon from 'sinon'; + +registerSuite('Destroyable', { + 'own/destroy handle': { + handle() { + const destroy = sinon.spy(); + const destroyable = new Destroyable(); + destroyable.own({ destroy }); + + assert.strictEqual(destroy.callCount, 0, 'handle should not be called yet'); + return destroyable.destroy().then(() => { + assert.strictEqual(destroy.callCount, 1, 'handle should have been called'); + return destroyable.destroy().then(() => { + assert.strictEqual(destroy.callCount, 1, 'handle should not have been called again'); + }); + }); + }, + + 'array of handles'() { + const destroy1 = sinon.spy(); + const destroy2 = sinon.spy(); + + const destroyable = new Destroyable(); + destroyable.own([{ destroy: destroy1 }, { destroy: destroy2 }]); + + assert.strictEqual(destroy1.callCount, 0, 'first handle should not be called yet'); + assert.strictEqual(destroy2.callCount, 0, 'second handle should not be called yet'); + return destroyable.destroy().then(() => { + assert.strictEqual(destroy1.callCount, 1, 'first handle should have been called'); + assert.strictEqual(destroy2.callCount, 1, 'second handle should have been called'); + return destroyable.destroy().then(() => { + assert.strictEqual(destroy1.callCount, 1, 'first handle should not have been called'); + assert.strictEqual(destroy2.callCount, 1, 'second handle should not have been called'); + }); + }); + } + }, + 'own after destruction throws'() { + const destroyable = new Destroyable(); + destroyable.own({ + destroy() {} + }); + return destroyable.destroy().then(() => { + assert.throws(() => { + destroyable.own({ + destroy() {} + }); + }, Error); + }); + }, + 'own handle destruction': { + handle() { + const destroy = sinon.spy(); + const destroyable = new Destroyable(); + const handle = destroyable.own({ destroy }); + assert.strictEqual(destroy.callCount, 0, 'destroy not called yet'); + handle.destroy(); + assert.strictEqual(destroy.callCount, 1, 'handle was destroyed'); + destroyable.destroy(); + assert.strictEqual(destroy.callCount, 1, 'destroy was not called again'); + }, + 'array of handles'() { + const destroy1 = sinon.spy(); + const destroy2 = sinon.spy(); + const destroyable = new Destroyable(); + const handle = destroyable.own([{ destroy: destroy1 }, { destroy: destroy2 }]); + assert.strictEqual(destroy1.callCount, 0, 'first destroy not called yet'); + assert.strictEqual(destroy2.callCount, 0, 'second destroy not called yet'); + handle.destroy(); + assert.strictEqual(destroy1.callCount, 1, 'first handle was destroyed'); + assert.strictEqual(destroy2.callCount, 1, 'second handle was destroyed'); + destroyable.destroy(); + assert.strictEqual(destroy1.callCount, 1, 'first destroy was not called again'); + assert.strictEqual(destroy2.callCount, 1, 'second destroy was not called again'); + } + } +}); diff --git a/src/lib/core/tests/unit/Evented.ts b/src/lib/core/tests/unit/Evented.ts new file mode 100644 index 0000000..3ef706d --- /dev/null +++ b/src/lib/core/tests/unit/Evented.ts @@ -0,0 +1,190 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { Evented, CustomEventTypes } from '../../src/Evented'; +import { EventObject } from '../../src/interfaces'; + +interface FooBarEvents extends CustomEventTypes { + foo: R; + bar: R; +} + +interface R extends EventObject { + value: number; +} + +registerSuite('Evented', { + creation() { + const evented = new Evented(); + assert(evented); + assert.isFunction(evented.on); + assert.isFunction(evented.emit); + }, + on: { + 'on()'() { + const eventStack: string[] = []; + const evented = new Evented(); + const handle = evented.on('foo', (event) => { + eventStack.push(event.type); + }); + + evented.emit<'foo'>({ type: 'foo', value: 1 }); + evented.emit({ type: 'bar' }); + + handle.destroy(); + + evented.emit({ type: 'foo' }); + evented.emit({ type: 'bar' }); + + assert.deepEqual(eventStack, ['foo']); + }, + 'on() with Symbol type'() { + const foo = Symbol(); + const bar = Symbol(); + const eventStack: symbol[] = []; + const evented = new Evented<{}, symbol>(); + const handle = evented.on(foo, (event) => { + eventStack.push(event.type); + }); + + evented.emit({ type: foo }); + evented.emit({ type: bar }); + evented.emit({ type: 'bar' }); + + handle.destroy(); + + evented.emit({ type: foo }); + evented.emit({ type: 'bar' }); + + assert.deepEqual(eventStack, [foo]); + }, + 'multiple listeners, same event'() { + const eventStack: string[] = []; + const evented = new Evented(); + + const handle1 = evented.on('foo', () => { + eventStack.push('one'); + }); + const handle2 = evented.on('foo', () => { + eventStack.push('two'); + }); + + evented.emit({ type: 'foo' }); + handle1.destroy(); + evented.emit({ type: 'foo' }); + handle2.destroy(); + evented.emit({ type: 'foo' }); + + assert.deepEqual(eventStack, ['one', 'two', 'two']); + }, + 'on(type, listener[])'() { + const eventStack: string[] = []; + const evented = new Evented(); + + const handle = evented.on('foo', [ + function(event) { + eventStack.push('foo1'); + }, + function(event) { + eventStack.push('foo2'); + } + ]); + + evented.emit({ type: 'foo' }); + handle.destroy(); + evented.emit({ type: 'foo' }); + + assert.deepEqual(eventStack, ['foo1', 'foo2']); + }, + 'listener removes itself'() { + const eventStack: string[] = []; + const evented = new Evented(); + + evented.on('foo', () => { + eventStack.push('one'); + }); + const handle = evented.on('foo', () => { + eventStack.push('two'); + handle.destroy(); + }); + evented.on('foo', () => { + eventStack.push('three'); + }); + + evented.emit({ type: 'foo' }); + evented.emit({ type: 'foo' }); + + assert.deepEqual(eventStack, ['one', 'two', 'three', 'one', 'three']); + } + }, + 'wildcards in event type name': { + 'all event types'() { + const eventStack: string[] = []; + const evented = new Evented<{}, string>(); + evented.on('*', (event) => { + eventStack.push(event.type); + }); + + evented.emit({ type: 'foo' }); + evented.emit({ type: 'bar' }); + evented.emit({ type: 'foo:bar' }); + + assert.deepEqual(eventStack, ['foo', 'bar', 'foo:bar']); + }, + 'event types starting with a pattern'() { + const eventStack: string[] = []; + const evented = new Evented<{}, string>(); + evented.on('foo:*', (event) => { + eventStack.push(event.type); + }); + + evented.emit({ type: 'foo' }); + evented.emit({ type: 'foo:' }); + evented.emit({ type: 'foo:bar' }); + + assert.deepEqual(eventStack, ['foo:', 'foo:bar']); + }, + 'event types ending with a pattern'() { + const eventStack: string[] = []; + const evented = new Evented<{}, string>(); + evented.on('*:bar', (event) => { + eventStack.push(event.type); + }); + + evented.emit({ type: 'bar' }); + evented.emit({ type: ':bar' }); + evented.emit({ type: 'foo:bar' }); + + assert.deepEqual(eventStack, [':bar', 'foo:bar']); + }, + 'event types contains a pattern'() { + const eventStack: string[] = []; + const evented = new Evented<{}, string>(); + evented.on('*foo*', (event) => { + eventStack.push(event.type); + }); + + evented.emit({ type: 'foo' }); + evented.emit({ type: 'foobar' }); + evented.emit({ type: 'barfoo' }); + evented.emit({ type: 'barfoobiz' }); + + assert.deepEqual(eventStack, ['foo', 'foobar', 'barfoo', 'barfoobiz']); + }, + 'multiple matches'() { + const eventStack: string[] = []; + const evented = new Evented(); + evented.on('foo', (event) => { + eventStack.push(`foo->${event.type}`); + }); + evented.on('*foo', (event) => { + eventStack.push(`*foo->${event.type}`); + }); + + evented.emit({ type: 'foo' }); + evented.emit({ type: 'foobar' }); + evented.emit({ type: 'barfoo' }); + + assert.deepEqual(eventStack, ['foo->foo', '*foo->foo', '*foo->barfoo']); + } + } +}); diff --git a/src/lib/core/tests/unit/IdentityRegistry.ts b/src/lib/core/tests/unit/IdentityRegistry.ts new file mode 100644 index 0000000..5f2125b --- /dev/null +++ b/src/lib/core/tests/unit/IdentityRegistry.ts @@ -0,0 +1,232 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import Symbol from '@dojo/shim/Symbol'; +import { from as arrayFrom } from '@dojo/shim/array'; + +import IdentityRegistry from '../../src/IdentityRegistry'; + +class Value {} + +const idSymbol = Symbol('id'); +// Store the expected string due to . +const idSymbolString = idSymbol.toString(); + +registerSuite('IdentityRegistry', { + '#get': { + 'string id was not registered'() { + const registry = new IdentityRegistry(); + assert.throws(() => registry.get('id'), Error, "Could not find a value for identity 'id'"); + }, + + 'symbol id was not registered'() { + const registry = new IdentityRegistry(); + assert.throws( + () => registry.get(idSymbol), + Error, + "Could not find a value for identity '" + idSymbolString + "'" + ); + }, + + registered() { + const registry = new IdentityRegistry(); + const expected = new Value(); + registry.register('id', expected); + assert.strictEqual(registry.get('id'), expected); + } + }, + + '#contains': { + 'not registered'() { + const registry = new IdentityRegistry(); + assert.isFalse(registry.contains(new Value())); + }, + + registered() { + const registry = new IdentityRegistry(); + const value = new Value(); + registry.register('id', value); + assert.isTrue(registry.contains(value)); + } + }, + + delete: { + 'not registered'() { + const registry = new IdentityRegistry(); + assert.isFalse(registry.delete('id')); + }, + + registered() { + const registry = new IdentityRegistry(); + registry.register('id', new Value()); + assert.isTrue(registry.has('id')); + assert.isTrue(registry.delete('id')); + assert.isFalse(registry.has('id')); + } + }, + + '#has': { + 'not registered'() { + const registry = new IdentityRegistry(); + assert.isFalse(registry.has('id')); + }, + + registered() { + const registry = new IdentityRegistry(); + registry.register('id', new Value()); + assert.isTrue(registry.has('id')); + } + }, + + '#identify': { + 'not registered'() { + const registry = new IdentityRegistry(); + assert.throws(() => registry.identify(new Value()), Error, 'Could not identify non-registered value'); + }, + + registered() { + const registry = new IdentityRegistry(); + const value = new Value(); + const expected = Symbol(); + registry.register(expected, value); + assert.strictEqual(registry.identify(value), expected); + } + }, + + '#register': { + ok() { + const registry = new IdentityRegistry(); + const expected = new Value(); + registry.register('id', expected); + assert.strictEqual(registry.get('id'), expected); + }, + + 'string id is already used'() { + const registry = new IdentityRegistry(); + registry.register('id', new Value()); + assert.throws( + () => { + registry.register('id', new Value()); + }, + Error, + 'A value has already been registered for the given identity (id)' + ); + }, + + 'symbol id is already used'() { + const registry = new IdentityRegistry(); + const id = idSymbol; + registry.register(id, new Value()); + assert.throws( + () => { + registry.register(id, new Value()); + }, + Error, + 'A value has already been registered for the given identity (' + idSymbolString + ')' + ); + }, + + 'value has already been registered with a different (string) id'() { + const registry = new IdentityRegistry(); + const value = new Value(); + registry.register('id1', value); + assert.throws( + () => { + registry.register(Symbol('id2'), value); + }, + Error, + 'The value has already been registered with a different identity (id1)' + ); + }, + + 'value has already been registered with a different (symbol) id'() { + const registry = new IdentityRegistry(); + const value = new Value(); + const id1Symbol = Symbol('id1'); + registry.register(id1Symbol, value); + assert.throws( + () => { + registry.register('id2', value); + }, + Error, + 'The value has already been registered with a different identity (' + id1Symbol.toString() + ')' + ); + }, + + 'value has already been registered with the same id'() { + const registry = new IdentityRegistry(); + const value = new Value(); + const expected = registry.register('id', value); + const actual = registry.register('id', value); + assert.strictEqual(actual, expected); + }, + + 'returns handle'() { + const registry = new IdentityRegistry(); + const handle = registry.register('id', new Value()); + assert.isTrue(registry.has('id')); + handle.destroy(); + assert.isFalse(registry.has('id')); + }, + + 'destroying handle more than once is a noop'() { + const registry = new IdentityRegistry(); + const handle = registry.register('id', new Value()); + assert.isTrue(registry.has('id')); + handle.destroy(); + handle.destroy(); + assert.isFalse(registry.has('id')); + } + }, + + '#values'() { + const value1 = new Value(); + const value2 = new Value(); + const value3 = new Value(); + + const registry = new IdentityRegistry(); + registry.register('id1', value1); + registry.register('id2', value2); + registry.register('id3', value3); + + assert.deepEqual(arrayFrom(registry.values()), [value1, value2, value3]); + }, + + '#ids'() { + const value1 = new Value(); + const value2 = new Value(); + const value3 = new Value(); + + const registry = new IdentityRegistry(); + registry.register('id1', value1); + registry.register('id2', value2); + registry.register('id3', value3); + + assert.deepEqual(arrayFrom(registry.ids()), ['id1', 'id2', 'id3']); + }, + + '#entries'() { + const value1 = new Value(); + const value2 = new Value(); + const value3 = new Value(); + + const registry = new IdentityRegistry(); + registry.register('id1', value1); + registry.register('id2', value2); + registry.register('id3', value3); + + assert.deepEqual(arrayFrom(registry.entries()), [['id1', value1], ['id2', value2], ['id3', value3]]); + }, + + iterator() { + const value1 = new Value(); + const value2 = new Value(); + const value3 = new Value(); + + const registry = new IdentityRegistry(); + registry.register('id1', value1); + registry.register('id2', value2); + registry.register('id3', value3); + + assert.deepEqual(arrayFrom(registry), [['id1', value1], ['id2', value2], ['id3', value3]]); + } +}); diff --git a/src/lib/core/tests/unit/List.ts b/src/lib/core/tests/unit/List.ts new file mode 100644 index 0000000..7278c65 --- /dev/null +++ b/src/lib/core/tests/unit/List.ts @@ -0,0 +1,220 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import Set from '@dojo/shim/Set'; +import List from '../../src/List'; + +registerSuite('List', function() { + function listWith(...items: T[]): List { + const list = new List(); + + for (let i = 0; i < items.length; i++) { + list.add(items[i]); + } + + return list; + } + + return { + add() { + const list = new List(); + + list.add(1); + assert.equal(list.size, 1); + + list.add(2); + assert.equal(list.size, 2); + }, + + clear() { + const list = new List(); + + list.add(1); + list.clear(); + assert.equal(list.size, 0); + }, + + delete() { + const list = listWith(1, 2, 3); + + assert.strictEqual(list.delete(1), true); + + assert.equal(list.size, 2); + assert.equal(list.indexOf(2), -1, 'Did not expect 2 to be in the list'); + + assert.strictEqual(list.delete(2), false); + }, + entries() { + const list = listWith('one', 'two', 'three'); + + let entries: [number, string][] = []; + + for (const value of list.entries()) { + entries.push(value); + } + + assert.deepEqual(entries, [[0, 'one'], [1, 'two'], [2, 'three']]); + }, + + forEach() { + const list = listWith('one', 'two', 'three'); + + let items: string[] = []; + let indicies: number[] = []; + let obj = { + myValue: 'test' + }; + + list.forEach(function(this: any, value: string, index: number) { + assert(this.myValue, 'test'); + + items.push(value); + indicies.push(index); + }, obj); + + assert.deepEqual(items, ['one', 'two', 'three']); + assert.deepEqual(indicies, [0, 1, 2]); + + list.forEach(function(this: any) { + assert.equal(this, list); + }); + }, + + has() { + const list = listWith('one', 'two', 'three'); + + assert.isFalse(list.has(3)); + assert.isTrue(list.has(2)); + assert.isTrue(list.has(0)); + }, + + keys() { + const list = listWith('one', 'two', 'three'); + + let keys: number[] = []; + + for (const key of list.keys()) { + keys.push(key); + } + + assert.deepEqual(keys, [0, 1, 2]); + }, + + values() { + const list = listWith('one', 'two', 'three'); + + let values: string[] = []; + + for (const value of list.values()) { + values.push(value); + } + + assert.deepEqual(values, ['one', 'two', 'three']); + }, + + includes() { + const list = listWith('one', 'two', 'three'); + + assert.isTrue(list.includes('two')); + assert.isFalse(list.includes('four')); + assert.isTrue(list.includes('one')); + }, + + indexOf() { + const list = listWith('one', 'two', 'three', 'two'); + + assert.equal(list.indexOf('two'), 1); + assert.equal(list.indexOf('test'), -1); + }, + + lastIndexOf() { + const list = listWith('one', 'two', 'three', 'two'); + + assert.equal(list.lastIndexOf('two'), 3); + assert.equal(list.lastIndexOf('test'), -1); + }, + + push() { + const list = new List(); + + list.push('one'); + + assert.equal(list.size, 1); + assert.equal(list.indexOf('one'), 0); + }, + + pop() { + const list = listWith(1, 2, 3); + + assert.equal(list.pop(), 3); + assert.equal(list.size, 2); + assert.equal(list.indexOf(3), -1); + assert.equal(list.indexOf(2), 1); + }, + + splice() { + const list = listWith(1, 2, 3); + + assert.deepEqual(list.splice(0, 1), [1]); + assert.deepEqual(list.splice(1, 0, 1), []); + + assert.equal(list.indexOf(1), 1); + assert.equal(list.indexOf(2), 0); + assert.equal(list.indexOf(3), 2); + + assert.deepEqual(list.splice(1), [1, 3]); + assert.equal(list.size, 1); + assert.equal(list.indexOf(2), 0); + }, + + join() { + let list = listWith('the', 'quick', 'brown', 'fox'); + + assert.equal(list.join(), 'the,quick,brown,fox'); + assert.equal(list.join(' '), 'the quick brown fox'); + + list = new List(); + + assert.equal(list.join(), ''); + + list.push('one'); + + assert.equal(list.join(), 'one'); + }, + + '@@iterator'() { + const list = listWith('the', 'quick', 'brown', 'fox'); + let values: string[] = []; + + for (const value of list) { + values.push(value); + } + + assert.deepEqual(values, ['the', 'quick', 'brown', 'fox']); + }, + + constructor() { + // empty list + let list = new List(); + assert.equal(list.size, 0); + + // array like + list = new List([1, 2, 3]); + assert.equal(list.size, 3); + assert.strictEqual(list.indexOf(1), 0); + assert.strictEqual(list.indexOf(2), 1); + assert.strictEqual(list.indexOf(3), 2); + + // iterable + const set = new Set(); + set.add(1); + set.add(2); + set.add(3); + + list = new List(set); + assert.equal(list.size, 3); + assert.strictEqual(list.indexOf(1), 0); + assert.strictEqual(list.indexOf(2), 1); + assert.strictEqual(list.indexOf(3), 2); + } + }; +}); diff --git a/src/lib/core/tests/unit/MatchRegistry.ts b/src/lib/core/tests/unit/MatchRegistry.ts new file mode 100644 index 0000000..b6501c1 --- /dev/null +++ b/src/lib/core/tests/unit/MatchRegistry.ts @@ -0,0 +1,56 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import MatchRegistry from '../../src/MatchRegistry'; + +function stringTest(value: string) { + return (...args: any[]): boolean => { + return value === args[0]; + }; +} + +registerSuite('MatchRegistry', { + '#match'() { + const registry = new MatchRegistry(); + const handler = () => {}; + registry.register((name: string) => { + return name === 'foo'; + }, handler); + assert.strictEqual(registry.match('foo'), handler); + assert.throws(() => registry.match('bar')); + }, + + '#register': { + multiple() { + const registry = new MatchRegistry(); + const handler = () => {}; + registry.register(stringTest('foo'), handler); + registry.register(stringTest('foo'), () => {}); + assert.strictEqual(registry.match('foo'), handler); + }, + + first() { + const registry = new MatchRegistry(); + registry.register(stringTest('foo'), 1); + registry.register(stringTest('foo'), 2, true); + assert.strictEqual(registry.match('foo'), 2); + registry.register(stringTest('foo'), 3, true); + assert.notEqual(registry.match('foo'), 2); + }, + + destroy() { + const registry = new MatchRegistry(2); + const handle = registry.register(stringTest('foo'), 1); + assert.equal(registry.match('foo'), 1); + handle.destroy(); + assert.equal(registry.match('foo'), 2); + + // check that destroying a second time doesn't throw + handle.destroy(); + } + }, + + 'default value'() { + const registry = new MatchRegistry('foo'); + assert.strictEqual(registry.match('bar'), 'foo'); + } +}); diff --git a/src/lib/core/tests/unit/MultiMap.ts b/src/lib/core/tests/unit/MultiMap.ts new file mode 100644 index 0000000..981de73 --- /dev/null +++ b/src/lib/core/tests/unit/MultiMap.ts @@ -0,0 +1,244 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import MultiMap from '../../src/MultiMap'; +import { isIterable, IterableIterator, ShimIterator } from '@dojo/shim/iterator'; + +let map: MultiMap; +function foo() {} +const object = Object.create(null); +const array: any[] = []; +const mapArgs: any[] = [ + [[0], 0], + [[0, 1, 2], '1'], + [[2, 3, 4, 5, 6], object], + [[3], array], + [[4, 3, 2, 1], foo], + [[5], undefined] +]; + +registerSuite('Map', { + instantiation: { + 'null data'() { + assert.doesNotThrow(function() { + map = new MultiMap(null); + }); + }, + + 'undefined data'() { + assert.doesNotThrow(function() { + map = new MultiMap(undefined); + }); + }, + + 'empty data'() { + assert.doesNotThrow(function() { + map = new MultiMap([]); + }); + }, + + 'iterator data'() { + assert.doesNotThrow(function() { + map = new MultiMap( + new ShimIterator<[any[], any]>({ + length: 1, + 0: [[1], 'foo'] + }) + ); + }); + } + }, + + clear: { + 'empty map'() { + map = new MultiMap(); + assert.doesNotThrow(function() { + map.clear(); + }); + }, + + 'non-empty map'() { + map = new MultiMap([[[1], 'foo']]); + assert.isFalse(map.has([3])); + map.clear(); + assert.isFalse(map.has([3])); + } + }, + + delete: { + before() { + map = new MultiMap([[[1], 'foo'], [[1, 2], 'bar'], [[2], 'baz']]); + }, + + tests: { + 'key found'() { + assert.strictEqual(map.get([1, 2]), 'bar'); + assert.isTrue(map.delete([1, 2])); + assert.isUndefined(map.get([1, 2])); + assert.strictEqual(map.get([1]), 'foo'); + assert.strictEqual(map.get([2]), 'baz'); + }, + + 'key not found'() { + assert.isFalse(map.delete(['foo'])); + } + } + }, + + size() { + map = new MultiMap(mapArgs); + assert.strictEqual(map.size, 6); + map.delete([2, 3, 4, 5, 6]); + assert.strictEqual(map.size, 5); + map.clear(); + assert.strictEqual(map.size, 0); + }, + + entries() { + map = new MultiMap(mapArgs); + const entries: IterableIterator<[any[], any]> = map.entries(); + + assert.isTrue(isIterable(entries), 'Returns an iterable.'); + + let i = 0; + for (const value of entries) { + value[0].forEach((key, index) => { + assert.strictEqual(key, mapArgs[i][0][index]); + }); + assert.strictEqual(value[1], mapArgs[i][1]); + i++; + } + }, + + 'Symbol iterator'() { + map = new MultiMap(mapArgs); + const entries = map[Symbol.iterator](); + + assert.isTrue(isIterable(entries), 'Returns an iterable.'); + + let i = 0; + for (const value of entries) { + value[0].forEach((key, index) => { + assert.strictEqual(key, mapArgs[i][0][index]); + }); + assert.strictEqual(value[1], mapArgs[i][1]); + i++; + } + }, + + forEach: { + before() { + map = new MultiMap(mapArgs); + }, + + tests: { + 'callback arguments'() { + map.forEach(function(value, key, mapInstance) { + assert.lengthOf(arguments, 3); + assert.strictEqual(map.get(key), value); + assert.strictEqual(map, mapInstance); + }); + }, + + 'times executed'() { + let counter = 0; + map.forEach(function(key, value, mapInstance) { + counter++; + }); + assert.strictEqual(counter, mapArgs.length); + } + } + }, + + get: { + before() { + map = new MultiMap(mapArgs); + }, + + tests: { + 'key found'() { + assert.strictEqual(map.get([0]), 0); + assert.strictEqual(map.get([4, 3, 2, 1]), foo); + }, + + 'key not found'() { + assert.isUndefined(map.get([2, 3, 4, 5, 7])); + } + } + }, + + has: { + before() { + map = new MultiMap(mapArgs); + }, + + tests: { + 'key found'() { + assert.isTrue(map.has([4, 3, 2, 1])); + }, + + 'key not found'() { + assert.isFalse(map.has(['key', 'not', 'exist'])); + } + } + }, + + keys() { + map = new MultiMap(mapArgs); + const keys: IterableIterator = map.keys(); + + assert.isTrue(isIterable(keys), 'Returns an iterable.'); + + let i = 0; + for (const value of keys) { + value.forEach((key, index) => { + assert.strictEqual(key, mapArgs[i][0][index]); + }); + i++; + } + }, + + set: { + beforeEach() { + map = new MultiMap(); + }, + + tests: { + 'single key'() { + map = new MultiMap(); + map.set([1], 'foo'); + assert.strictEqual(map.get([1]), 'foo'); + }, + + 'multiple keys'() { + map = new MultiMap(); + map.set(['foo', 'bar', 'baz', foo, object, array], 'qux'); + assert.strictEqual(map.get(['foo', 'bar', 'baz', foo, object, array]), 'qux'); + }, + + 'returns instance'() { + map = new MultiMap(); + assert.instanceOf(map.set(['foo'], 'bar'), MultiMap); + assert.strictEqual(map.set(['foo'], 'bar'), map); + }, + + 'key exists'() { + map = new MultiMap([[[3], 'abc']]); + map.set([3], 'def'); + assert.strictEqual(map.get([3]), 'def'); + } + } + }, + + values() { + map = new MultiMap(mapArgs); + const values: IterableIterator = map.values(); + + assert.isTrue(isIterable(values), 'Returns an iterable.'); + + let i = 0; + for (const value of values) { + assert.strictEqual(value, mapArgs[i][1]); + i++; + } + } +}); diff --git a/src/lib/core/tests/unit/Observable.ts b/src/lib/core/tests/unit/Observable.ts new file mode 100644 index 0000000..c6130de --- /dev/null +++ b/src/lib/core/tests/unit/Observable.ts @@ -0,0 +1,465 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import Observable from '../../src/Observable'; + +function asyncRange(start: number, end: number) { + return new Observable((observer) => { + let i = start; + + function handler() { + observer.next(i++); + if (i > end) { + observer.complete(); + } else { + setTimeout(handler, 0); + } + } + + setTimeout(handler, 0); + }); +} + +registerSuite('Observable', { + toPromise: { + 'resolution with single'() { + return Observable.of(42) + .toPromise() + .then((value: number) => { + assert.strictEqual(value, 42); + }); + }, + 'resolution with multiple'() { + return Observable.from([1, 2, 3]) + .toPromise() + .then((value: number) => { + assert.strictEqual(value, 1); + }); + }, + reject(this: any) { + let dfd = this.async(); + + new Observable(() => { + throw new Error('error'); + }) + .toPromise() + .then( + dfd.rejectOnError(() => { + assert.fail('should not have succeeded'); + }), + dfd.callback((error: Error) => { + assert.strictEqual(error.message, 'error'); + }) + ); + } + }, + map: { + 'transforms values'() { + let values: any[] = [], + returns: any[] = []; + + new Observable((observer) => { + returns.push(observer.next(1)); + returns.push(observer.next(2)); + observer.complete(); + }) + .map((x) => x * 2) + .subscribe({ + next(v) { + values.push(v); + return -v; + } + }); + + assert.deepEqual(values, [2, 4], 'Mapped values are sent to the observer'); + assert.deepEqual(returns, [-2, -4], 'Return values from the observer are returned to the caller'); + }, + 'errors during callback get sent to the observer'() { + let error = new Error(), + thrown = null, + returned = null, + token = {}; + + new Observable((observer) => { + returned = observer.next(1); + }) + .map(() => { + throw error; + }) + .subscribe({ + error(e) { + thrown = e; + return token; + } + }); + + assert.equal(thrown, error, 'Exceptions from callback are sent to the observer'); + assert.equal(returned, token, 'The result of calling error is returned to the caller'); + }, + 'errors are sent to the observer'() { + let error = new Error(), + thrown = null, + returned = null, + token = {}; + + new Observable((observer) => { + returned = observer.error(error); + }) + .map((x) => x) + .subscribe({ + error(e) { + thrown = e; + return token; + } + }); + + assert.equal(thrown, error, 'Error values are forwarded'); + assert.equal(returned, token, 'The return value of the error method is returned to the caller'); + }, + 'invalid argument errors'() { + const observable = new Observable(() => {}); + + assert.throws(() => observable.map(undefined), TypeError); + assert.throws(() => observable.map(null), TypeError); + assert.throws(() => observable.map({}), TypeError); + assert.throws(() => observable.map(42), TypeError); + }, + 'complete is forwarded to the observer'() { + let arg = {}, + passed = null; + + new Observable((observer) => { + observer.complete(arg); + }) + .map((x) => x) + .subscribe({ + complete(v) { + passed = v; + } + }); + + assert.equal(passed, arg, 'Complete values are forwarded'); + } + }, + + filter: { + 'allowed argument'() { + let observable = new Observable(() => undefined); + + assert.throws(() => observable.filter(undefined), TypeError); + assert.throws(() => observable.filter(null), TypeError); + assert.throws(() => observable.filter({}), TypeError); + }, + 'even numbers'() { + const source = Observable.of(1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10).filter((x) => { + return x % 2 ? false : true; + }); + + let values: any[] = []; + let finished = false; + + source.subscribe({ + next(value: number) { + values.push(value); + }, + complete() { + finished = true; + } + }); + + assert.isTrue(finished); + assert.deepEqual(values, [2, 4, 6, 8, 10]); + }, + + 'errors thrown from callback are returned to observer'() { + let error = new Error(), + thrown = null, + returned = null, + token = {}; + + new Observable((observer) => { + returned = observer.next(1); + }) + .filter((x) => { + throw error; + }) + .subscribe({ + error(e) { + thrown = e; + return token; + } + }); + + assert.equal(thrown, error, 'The result of calling error is returned to the caller'); + assert.equal(returned, token); + }, + + 'errors propagate'() { + let error = new Error(), + thrown = null, + returned = null, + token = {}; + + new Observable((observer) => { + returned = observer.error(error); + }) + .filter((x) => true) + .subscribe({ + error(e) { + thrown = e; + return token; + } + }); + + assert.equal(thrown, error, 'Error values are forwarded'); + assert.equal(returned, token, 'The return value of the error method is returned to the caller'); + }, + + 'complete is called on the observer'() { + let arg = {}, + passed = null, + token = {}; + + new Observable((observer) => { + observer.complete(arg); + }) + .filter((x) => true) + .subscribe({ + complete(v) { + passed = v; + return token; + } + }); + + assert.equal(passed, arg, 'Complete values are forwarded'); + } + }, + defer: { + 'execution is deferred until subscribe'() { + let called = false; + let values: number[] = []; + + const source = Observable.defer(() => { + return new Observable((observer) => { + called = true; + + observer.next(1); + observer.next(2); + }); + }); + + assert.isFalse(called); + + source.subscribe({ + next(value) { + values.push(value); + } + }); + + assert.isTrue(called); + assert.deepEqual(values, [1, 2]); + }, + + 'errors thrown during factory call are sent to subscriber'() { + let error: any = undefined; + + const source = Observable.defer(() => { + throw new Error('error'); + }); + + source.subscribe({ + error(e) { + error = e; + } + }); + + assert.equal(error.message, 'error'); + }, + + 'errors created in factory observable get propagated to the observer'() { + const source = Observable.defer(() => { + return new Observable((observer) => { + observer.error(new Error('error')); + }); + }); + + source.subscribe({ + error(error) { + assert.equal(error.message, 'error'); + } + }); + } + }, + + toArray: { + 'complete list'() { + let called = false; + + Observable.from([1, 2, 3]) + .toArray() + .subscribe((values) => { + called = true; + assert.deepEqual(values, [1, 2, 3]); + }); + + assert.isTrue(called); + }, + 'errors thrown during subscription are sent to observer'() { + new Observable(() => { + throw new Error('test'); + }) + .toArray() + .subscribe( + () => { + assert.fail('should not have succeeded'); + }, + (error) => { + assert.equal(error.message, 'test'); + } + ); + }, + 'errors called are sent to observer'() { + new Observable((observer) => { + observer.error(new Error('test')); + }) + .toArray() + .subscribe( + () => { + assert.fail('should not have succeeded'); + }, + (error) => { + assert.equal(error.message, 'test'); + } + ); + }, + 'complete calls are sent to observer'() { + let completeValue = 0; + + new Observable((observer) => { + observer.complete(4); + }) + .toArray() + .subscribe({ + complete(value) { + completeValue = value; + } + }); + + assert.equal(completeValue, 4); + } + }, + + mergeAll: { + 'synchronous concat'() { + let values: any[] = []; + + const source = Observable.of( + Observable.defer(() => Observable.of(1, 2, 3)), + Observable.defer(() => Observable.of(4, 5, 6)) + ); + + source.mergeAll(1).subscribe({ + next(value) { + values.push(value); + } + }); + + assert.deepEqual(values, [1, 2, 3, 4, 5, 6]); + }, + + 'asynchronous concat'(this: any) { + const dfd = this.async(); + let values: any[] = []; + + const source = Observable.of( + Observable.defer(() => asyncRange(1, 2)), + Observable.defer(() => asyncRange(3, 4)) + ); + + source.mergeAll(1).subscribe({ + next(value) { + values.push(value); + }, + complete: dfd.callback(() => { + assert.deepEqual(values, [1, 2, 3, 4]); + }) + }); + }, + + 'non observable values'() { + let values: any[] = []; + + Observable.of(1, 2, 3) + .mergeAll(1) + .subscribe((value) => { + values.push(value); + }); + + assert.deepEqual(values, [1, 2, 3]); + }, + + concurrency(this: any) { + const dfd = this.async(); + let values: any[] = []; + + let observables: Observable[] = []; + + observables.push(Observable.defer(() => asyncRange(1, 2))); + observables.push(Observable.defer(() => asyncRange(3, 4))); + observables.push(Observable.defer(() => asyncRange(5, 6))); + observables.push(Observable.defer(() => asyncRange(7, 8))); + observables.push(Observable.defer(() => asyncRange(9, 10))); + observables.push(Observable.defer(() => asyncRange(11, 12))); + + const source = Observable.from(observables); + + source.mergeAll(2).subscribe({ + next(value) { + values.push(value); + }, + complete: dfd.callback(() => { + assert.sameMembers(values, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); + }) + }); + }, + + 'underused concurrency'(this: any) { + const dfd = this.async(); + let values: any[] = []; + + const source = Observable.of(Observable.defer(() => asyncRange(1, 2))); + + source.mergeAll(2).subscribe({ + next(value) { + values.push(value); + }, + complete: dfd.callback(() => { + assert.deepEqual(values, [1, 2]); + }) + }); + }, + + 'thrown errors during merge call observer'() { + Observable.of( + new Observable(() => { + throw new Error('error'); + }) + ).subscribe({ + error(error) { + assert.equal(error.message, 'error'); + } + }); + }, + + 'called errors during merge call observer'() { + Observable.of( + new Observable((observer) => { + observer.error(new Error('error')); + }) + ).subscribe({ + error(error) { + assert.equal(error.message, 'error'); + } + }); + } + } +}); diff --git a/src/lib/core/tests/unit/QueuingEvented.ts b/src/lib/core/tests/unit/QueuingEvented.ts new file mode 100644 index 0000000..ac44a57 --- /dev/null +++ b/src/lib/core/tests/unit/QueuingEvented.ts @@ -0,0 +1,84 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); + +import QueuingEvented from '../../src/QueuingEvented'; +import { EventObject } from '../../src/interfaces'; + +interface CustomEvent extends EventObject { + type: 'test'; + target: any; + value: number; +} + +function isCustomEvent(object: any): object is CustomEvent { + return object.type === 'test'; +} + +registerSuite('QueuingEvented', { + 'events are queued for the first subscriber': function() { + const evented = new QueuingEvented(); + let listenerCallCount = 0; + + evented.emit({ + type: 'test', + value: 1 + }); + + evented.on('test', function() { + listenerCallCount++; + }); + + assert.strictEqual(listenerCallCount, 1); + }, + + 'events do not get queued over maximum'() { + const evented = new QueuingEvented(); + evented.maxEvents = 5; + let expectedValues: number[] = []; + + for (let i = 1; i <= 10; i++) { + evented.emit({ + type: 'test', + value: i + }); + } + + evented.on('test', function(event) { + if (isCustomEvent(event)) { + expectedValues.push(event.value); + } + }); + + assert.deepEqual(expectedValues, [6, 7, 8, 9, 10]); + }, + + 'events work fine if used normally'() { + const evented = new QueuingEvented(); + let listenerCallCount = 0; + + evented.on('test', function() { + listenerCallCount++; + }); + + evented.emit({ + type: 'test' + }); + + assert.strictEqual(listenerCallCount, 1); + }, + + 'events have glob matching'() { + const evented = new QueuingEvented(); + let listenerCallCount = 0; + + evented.emit({ + type: 'test' + }); + + evented.on('t*', function() { + listenerCallCount++; + }); + + assert.strictEqual(listenerCallCount, 1); + } +}); diff --git a/src/lib/core/tests/unit/Scheduler.ts b/src/lib/core/tests/unit/Scheduler.ts new file mode 100644 index 0000000..5b66830 --- /dev/null +++ b/src/lib/core/tests/unit/Scheduler.ts @@ -0,0 +1,174 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { queueMicroTask, queueTask } from '../../src/queue'; +import Scheduler from '../../src/Scheduler'; + +registerSuite('Scheduler', () => { + let parts: string[]; + let scheduler: Scheduler; + + function a() { + parts.push('a'); + } + function b() { + parts.push('b'); + } + + return { + beforeEach(): void { + parts = []; + scheduler = new Scheduler(); + }, + + tests: { + 'callback handling': function(this: any) { + const dfd = this.async(5000); + + function c() { + a(); + scheduler.schedule(function() { + parts.push('first'); + }); + queueTask(function() { + parts.push('third'); + }); + scheduler.schedule(function() { + parts.push('second'); + }); + b(); + } + + c(); + setTimeout( + dfd.callback(function() { + assert.equal( + parts.join(','), + 'a,b,first,second,third', + 'Callbacks registered with scheduler should be executed as part of the same task.' + ); + }), + 300 + ); + }, + + 'scheduler type': function(this: any) { + const dfd = this.async(5000); + const macroScheduler = new Scheduler(); + scheduler = new Scheduler({ queueFunction: queueMicroTask }); + + function test() { + macroScheduler.schedule(function() { + parts.push('second'); + }); + scheduler.schedule(function() { + parts.push('first'); + }); + } + + test(); + setTimeout( + dfd.callback(function() { + assert.equal( + parts.join(','), + 'first,second', + 'It should be possible to change the type of task being registered.' + ); + }), + 300 + ); + }, + + 'when deferWhileProcessing is true': function(this: any) { + const dfd = this.async(5000); + + function test() { + scheduler.schedule(function() { + parts.push('first'); + + scheduler.schedule(function() { + parts.push('third'); + }); + }); + queueTask(function() { + parts.push('second'); + }); + } + + test(); + setTimeout( + dfd.callback(function() { + assert.equal( + parts.join(','), + 'first,second,third', + 'Callbacks registered while the current batch is processing should be deferred.' + ); + }), + 300 + ); + }, + + 'when deferWhileProcessing is false': function(this: any) { + const dfd = this.async(5000); + scheduler = new Scheduler({ deferWhileProcessing: false }); + + function test() { + scheduler.schedule(function() { + parts.push('first'); + + scheduler.schedule(function() { + parts.push('second'); + }); + }); + queueTask(function() { + parts.push('third'); + }); + } + + test(); + setTimeout( + dfd.callback(function() { + assert.equal( + parts.join(','), + 'first,second,third', + 'Callbacks registered while the current batch is processing should be queued immediately.' + ); + }), + 300 + ); + }, + + 'scheduler.schedule() => handle.destroy()': function(this: any) { + const dfd = this.async(5000); + + function test() { + scheduler + .schedule(function() { + parts.push('first'); + }) + .destroy(); + scheduler.schedule(function() { + parts.push('second'); + + scheduler + .schedule(function() { + parts.push('third'); + }) + .destroy(); + }); + } + + test(); + setTimeout( + dfd.callback(function() { + assert.equal( + parts.join(','), + 'second', + 'Destroying a callback should result in it not being called.' + ); + }), + 300 + ); + } + } + }; +}); diff --git a/src/lib/core/tests/unit/UrlSearchParams.ts b/src/lib/core/tests/unit/UrlSearchParams.ts new file mode 100644 index 0000000..b91c426 --- /dev/null +++ b/src/lib/core/tests/unit/UrlSearchParams.ts @@ -0,0 +1,154 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import UrlSearchParams from '../../src/UrlSearchParams'; + +registerSuite('UrlSearchParams', { + construct: (function() { + function checkParams(params: UrlSearchParams) { + assert.deepEqual(params.getAll('foo'), ['bar', 'baz']); + assert.deepEqual(params.getAll('bar'), ['foo']); + assert.deepEqual(params.getAll('baz'), ['']); + } + + return { + empty() { + // Empty UrlSearchParams should have no properties + const params = new UrlSearchParams(); + assert.isUndefined(params.get('foo')); + }, + + // Next three tests should generate 'params' objects with same contents + + object() { + const params = new UrlSearchParams({ foo: ['bar', 'baz'], bar: 'foo', baz: null }); + checkParams(params); + }, + + string() { + let params = new UrlSearchParams('foo=bar&foo=baz&bar=foo&baz'); + checkParams(params); + + // Equals signs after the first will be included in the value + params = new UrlSearchParams('foo=bar=baz'); + assert.deepEqual(params.getAll('foo'), ['bar=baz']); + + // Handle empty keys + params = new UrlSearchParams('=foo&'); + assert.deepEqual(params.getAll(''), ['foo', '']); + }, + + UrlSearchParams() { + const params1 = new UrlSearchParams({ foo: ['bar', 'baz'], bar: 'foo', baz: null }); + const params = new UrlSearchParams(params1); + checkParams(params); + } + }; + })(), + + '#append': { + 'new key'() { + // Appending with a new key is the same as 'set' + const params = new UrlSearchParams(); + params.append('foo', 'bar'); + assert.deepEqual(params.getAll('foo'), ['bar']); + }, + + 'existing key'() { + const params = new UrlSearchParams({ foo: 'bar' }); + params.append('foo', 'baz'); + assert.deepEqual(params.getAll('foo'), ['bar', 'baz']); + } + }, + + '#delete'() { + const params = new UrlSearchParams({ foo: 'bar' }); + params.delete('foo'); + assert.isUndefined(params.get('foo')); + }, + + '#get'() { + // Get should always return the first entry for a key + const params1 = new UrlSearchParams({ foo: ['bar', 'baz'] }); + const params2 = new UrlSearchParams({ foo: ['baz', 'bar'] }); + assert.strictEqual(params1.get('foo'), 'bar'); + assert.strictEqual(params2.get('foo'), 'baz'); + assert.isUndefined(params2.get('bar')); + }, + + '#getAll'() { + const params = new UrlSearchParams({ foo: ['bar', 'baz'] }); + assert.deepEqual(params.getAll('foo'), ['bar', 'baz']); + assert.isUndefined(params.getAll('bar')); + }, + + '#has'() { + const params = new UrlSearchParams({ foo: 'bar', bar: undefined, baz: [] }); + assert.isTrue(params.has('foo'), 'expected string property to be present'); + assert.isTrue(params.has('bar'), 'expected undefined property to be present'); + assert.isTrue(params.has('baz'), 'expected empty array property to be present'); + assert.isFalse(params.has('qux'), 'expected unassigned property to be false'); + }, + + '#keys'() { + const params = new UrlSearchParams({ foo: 'bar', bar: undefined, baz: [] }); + assert.deepEqual(params.keys(), ['foo', 'bar', 'baz']); + params.delete('foo'); + assert.deepEqual(params.keys(), ['bar', 'baz']); + + // Re-add to test consistent ordering across all platforms + params.append('foo', 'bar'); + assert.deepEqual(params.keys(), ['foo', 'bar', 'baz']); + }, + + '#set'() { + const params = new UrlSearchParams({ foo: 'bar' }); + params.set('foo', 'baz'); + assert.deepEqual(params.getAll('foo'), ['baz']); + params.set('foo', 'qux'); + assert.deepEqual(params.getAll('foo'), ['qux']); + params.set('bar', 'foo'); + assert.deepEqual(params.getAll('foo'), ['qux']); + assert.deepEqual(params.getAll('bar'), ['foo']); + }, + + '#toString'() { + let params = new UrlSearchParams({ foo: ['bar', 'baz'], bar: 'foo' }); + assert.strictEqual(params.toString(), 'foo=bar&foo=baz&bar=foo'); + + params = new UrlSearchParams({ foo: 'bar', baz: null }); + assert.strictEqual(params.toString(), 'foo=bar&baz'); + + params = new UrlSearchParams({ foo: 'bar', bar: null, baz: null }); + assert.strictEqual(params.toString(), 'foo=bar&bar&baz'); + + params = new UrlSearchParams({ foo: 'bar', bar: undefined, baz: [] }); + assert.strictEqual(params.toString(), 'foo=bar&bar&baz'); + params.delete('foo'); + assert.strictEqual(params.toString(), 'bar&baz'); + + params = new UrlSearchParams({ foo: [null] }); + assert.strictEqual(params.toString(), 'foo'); + }, + + 'list not enumerable'() { + const params = new UrlSearchParams(); + for (let key in params) { + assert.notEqual(key, 'list'); + } + }, + + 'no data sharing'() { + const params1 = new UrlSearchParams({ foo: ['bar', 'baz'], bar: 'foo' }); + const params2 = new UrlSearchParams(params1); + + assert.deepEqual(params1.getAll('foo'), params2.getAll('foo')); + assert.deepEqual(params1.getAll('bar'), params2.getAll('bar')); + + params1.append('foo', 'qux'); + assert.strictEqual(params1.get('foo'), params2.get('foo')); + assert.notDeepEqual(params1.getAll('foo'), params2.getAll('foo')); + + params1.set('bar', 'qux'); + assert.notEqual(params1.get('bar'), params2.get('bar')); + } +}); diff --git a/src/lib/core/tests/unit/all-browser.ts b/src/lib/core/tests/unit/all-browser.ts new file mode 100644 index 0000000..fc8be7e --- /dev/null +++ b/src/lib/core/tests/unit/all-browser.ts @@ -0,0 +1,5 @@ +import './on/browserOnly'; +import './request/xhr'; +import './request_browser'; +import './text'; +import './text_browser'; diff --git a/src/lib/core/tests/unit/all-node-loader.ts b/src/lib/core/tests/unit/all-node-loader.ts new file mode 100644 index 0000000..c52edf4 --- /dev/null +++ b/src/lib/core/tests/unit/all-node-loader.ts @@ -0,0 +1,2 @@ +import './text'; +import './text_node'; diff --git a/src/lib/core/tests/unit/all-node.ts b/src/lib/core/tests/unit/all-node.ts new file mode 100644 index 0000000..ebccab2 --- /dev/null +++ b/src/lib/core/tests/unit/all-node.ts @@ -0,0 +1,3 @@ +import './on/nodeOnly'; +import './request/node'; +import './request_node'; diff --git a/src/lib/core/tests/unit/all.ts b/src/lib/core/tests/unit/all.ts new file mode 100644 index 0000000..b86c210 --- /dev/null +++ b/src/lib/core/tests/unit/all.ts @@ -0,0 +1,37 @@ +import './aspect'; +import './async/iteration'; +import './async/ExtensiblePromise'; +import './async/Task'; +import './async/timing'; +import './base64'; +import './compare'; +import './Destroyable'; +import './Evented'; +import './global'; +import './IdentityRegistry'; +import './instrument'; +import './lang'; +import './List'; +import './load'; +import './load/util'; +import './load/webpack'; +import './main'; +import './Observable'; +import './on/all'; +import './MatchRegistry'; +import './MultiMap'; +import './QueuingEvented'; +import './request'; +import './request/all'; +import './Scheduler'; +import './stringExtras'; +import './UrlSearchParams'; +import './DateObject'; +import './uuid'; +import './util'; +import './has'; + +if (typeof (require).toUrl === 'function') { + // tslint:disable-next-line + import('./text'); +} diff --git a/src/lib/core/tests/unit/aspect.ts b/src/lib/core/tests/unit/aspect.ts new file mode 100644 index 0000000..dd671a6 --- /dev/null +++ b/src/lib/core/tests/unit/aspect.ts @@ -0,0 +1,800 @@ +/* tslint:disable:no-var-keyword */ + +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); + +import * as sinon from 'sinon'; +import * as aspect from '../../src/aspect'; +import { Handle } from '../../src/interfaces'; +import Map from '@dojo/shim/Map'; +import { ObjectSuiteDescriptor } from 'intern/lib/interfaces/object'; + +const slice = Array.prototype.slice; +let obj: any; +let methodSpy: any; +let map: Map any>; + +function createBeforeSpy() { + return sinon.spy(function(a: number) { + return [a + 1]; + }); +} + +function indexableTests(property: string | symbol): ObjectSuiteDescriptor { + return { + beforeEach() { + methodSpy = sinon.spy(function(a: number) { + return a + 1; + }); + obj = { [property]: methodSpy }; + }, + + tests: { + '.before': { + 'return value passed as arguments'() { + let aspectSpy = createBeforeSpy(); + + aspect.before(obj, property, aspectSpy); + + obj[property](0); + assert.isTrue(aspectSpy.calledBefore(methodSpy)); + assert.isTrue(aspectSpy.calledOnce); + assert.isTrue(methodSpy.calledOnce); + assert.strictEqual(aspectSpy.lastCall.args[0], 0); + assert.strictEqual(methodSpy.lastCall.args[0], 1); + assert.strictEqual(methodSpy.returnValues[0], 2); + }, + + 'no return value from advising function'() { + let receivedArgs: string[] = []; + let beforeCalled = false; + let obj = { + [property]: function(...args: string[]) { + receivedArgs = args; + } + }; + + aspect.before(obj, property, function() { + beforeCalled = true; + }); + + obj[property]('foo', 'bar'); + + assert.isTrue(beforeCalled, 'Before advice should be called before original function'); + assert.deepEqual( + receivedArgs, + ['foo', 'bar'], + 'Arguments passed to original method should be unaltered if before advice returns undefined' + ); + }, + + 'multiple aspect.before()'() { + const aspectSpy1 = createBeforeSpy(); + const aspectSpy2 = createBeforeSpy(); + + aspect.before(obj, property, aspectSpy1); + aspect.before(obj, property, aspectSpy2); + + obj[property](5); + assert.isTrue(aspectSpy2.calledBefore(aspectSpy1)); + assert.isTrue(aspectSpy1.calledBefore(methodSpy)); + assert.strictEqual(aspectSpy2.lastCall.args[0], 5); + assert.strictEqual(aspectSpy1.lastCall.args[0], 6); + assert.strictEqual(methodSpy.lastCall.args[0], 7); + assert.strictEqual(methodSpy.returnValues[0], 8); + }, + + 'multiple aspect.before() with removal inside handler'() { + let count = 0; + + const handle1 = aspect.before(obj, property, function() { + count++; + }); + + // FIXME: TDZ + var handle2 = aspect.before(obj, property, function() { + handle2.destroy(); + handle1.destroy(); + count++; + }); + + assert.doesNotThrow(function() { + obj[property](); + }); + assert.strictEqual(count, 1, 'Only one advising function should be called'); + } + }, + + '.after': { + 'overriding return value from original method'() { + const expected = 'override!'; + const aspectSpy = sinon.stub().returns(expected); + + aspect.after(obj, property, aspectSpy); + assert.strictEqual(obj[property](0), expected); + assert.isTrue(aspectSpy.calledAfter(methodSpy)); + }, + + 'multiple aspect.after()'() { + const aspectStub1 = sinon.stub(); + const aspectStub2 = sinon.stub(); + + aspect.after(obj, property, aspectStub1); + aspect.after(obj, property, aspectStub2); + + obj[property](0); + assert.isTrue(aspectStub1.calledAfter(methodSpy)); + assert.isTrue(aspectStub2.calledAfter(aspectStub1)); + }, + + 'multiple aspect.after() with removal inside handler'() { + let count = 0; + + let handle2: Handle; + + // FIXME: TDZ + var handle1 = aspect.after(obj, property, function() { + handle1.destroy(); + handle2.destroy(); + count++; + }); + + handle2 = aspect.after(obj, property, function() { + count++; + }); + + assert.doesNotThrow(function() { + obj[property](); + }); + assert.strictEqual(count, 1, 'Only one advising function should be called'); + }, + + 'provides the original arguments to the aspect method'() { + const expected = 'expected'; + const aspectStub = sinon.stub().returns(expected); + + aspect.after(obj, property, aspectStub); + assert.strictEqual(obj[property](0), expected); + assert.isTrue(aspectStub.calledAfter(methodSpy)); + assert.strictEqual(aspectStub.lastCall.args[0], 1); + assert.deepEqual(slice.call(aspectStub.lastCall.args[1]), methodSpy.lastCall.args); + } + }, + + '.around': { + 'single around'() { + const expected = 5; + const aroundFunction = sinon.stub().returns(expected); + const aspectStub = sinon.stub().returns(aroundFunction); + + aspect.around(obj, property, aspectStub); + + assert.strictEqual(obj[property](0), expected); + assert.isTrue(aspectStub.calledOnce); + assert.isTrue(aroundFunction.calledOnce); + assert.strictEqual(aroundFunction.firstCall.args[0], 0); + assert.isFalse(methodSpy.called); + + // test that the original method was provided + aspectStub.callArgWith(0, 10); + assert.isTrue(methodSpy.calledOnce); + assert.strictEqual(methodSpy.firstCall.args[0], 10); + } + }, + + '.on()': { + 'advising function returns undefined, returns original result'() { + const aspectStub = sinon.stub(); + + aspect.on(obj, property, aspectStub); + + assert.strictEqual(obj[property](0), 1); + + assert.deepEqual(aspectStub.lastCall.args, methodSpy.lastCall.args); + assert.isTrue(methodSpy.calledOnce); + assert.isTrue(aspectStub.calledOnce); + assert.isTrue(aspectStub.calledAfter(methodSpy)); + }, + + 'advising function returns defined values, returns advising function result'() { + const aspectStub = sinon.stub().returns(2); + + aspect.on(obj, property, aspectStub); + + assert.strictEqual(obj[property](0), 2); + assert.deepEqual(aspectStub.lastCall.args, methodSpy.lastCall.args); + assert.isTrue(methodSpy.calledOnce); + assert.isTrue(aspectStub.calledOnce); + assert.isTrue(aspectStub.calledAfter(methodSpy)); + }, + + 'there are previous advising functions (covering previous.next)'() { + const aspectStub1 = sinon.stub().returns(2); + const aspectStub2 = sinon.stub(); + const aspectStub3 = sinon.stub().returns(6); + + aspect.on(obj, property, aspectStub1); + aspect.on(obj, property, aspectStub2); + aspect.on(obj, property, aspectStub3); + + assert.strictEqual(obj[property](0), 6); + + assert.deepEqual(aspectStub1.lastCall.args, methodSpy.lastCall.args); + assert.deepEqual(aspectStub2.lastCall.args, methodSpy.lastCall.args); + assert.deepEqual(aspectStub3.lastCall.args, methodSpy.lastCall.args); + + assert.isTrue(methodSpy.calledOnce); + assert.isTrue(aspectStub1.calledOnce); + assert.isTrue(aspectStub2.calledOnce); + assert.isTrue(aspectStub3.calledOnce); + + sinon.assert.callOrder(methodSpy, aspectStub1, aspectStub2, aspectStub3); + } + }, + + 'handle.destroy()': { + 'prevents aspect from being called'() { + const aspectSpy = createBeforeSpy(); + const handle = aspect.before(obj, property, aspectSpy); + + obj[property](0); + assert.notEqual(obj[property], methodSpy); + + handle.destroy(); + obj[property](1); + assert.notEqual(obj[property], methodSpy); + assert.isTrue(methodSpy.calledTwice); + assert.isTrue(aspectSpy.calledOnce); + }, + + 'can remove an aspect from the middle of a list'() { + const aspectSpy1 = createBeforeSpy(); + const aspectSpy2 = createBeforeSpy(); + const handle = aspect.before(obj, property, aspectSpy1); + + aspect.before(obj, property, aspectSpy2); + handle.destroy(); + + obj[property](0); + assert.isTrue(methodSpy.called); + assert.isTrue(aspectSpy2.called); + assert.isFalse(aspectSpy1.called); + }, + + 'removing a aspect stub'() { + const obj: any = {}; + const aspectSpy = sinon.stub(); + aspect.before(obj, property, sinon.stub()); + const handle = aspect.before(obj, property, aspectSpy); + + handle.destroy(); + obj[property](0); + assert.isFalse(aspectSpy.called); + }, + + 'removing the first of multiple aspects'() { + const aroundFunction = sinon.stub(); + const aspectStub = sinon.stub().returns(aroundFunction); + const handle = aspect.around(obj, property, aspectStub); + + handle.destroy(); + obj[property](0); + assert.isTrue(aspectStub.calledOnce); + assert.isTrue(methodSpy.calledOnce); + assert.isFalse(aroundFunction.called); + } + } + } + }; +} + +function mapTests(property: string | symbol): ObjectSuiteDescriptor { + return { + beforeEach() { + methodSpy = sinon.spy(function(a: number) { + return a + 1; + }); + map = new Map([[property, methodSpy]]); + }, + + tests: { + '.before': { + 'return value passed as arguments'() { + let aspectSpy = createBeforeSpy(); + + aspect.before(map, property, aspectSpy); + + const method = map.get(property); + method && method(0); + assert.isTrue(aspectSpy.calledBefore(methodSpy)); + assert.isTrue(aspectSpy.calledOnce); + assert.isTrue(methodSpy.calledOnce); + assert.strictEqual(aspectSpy.lastCall.args[0], 0); + assert.strictEqual(methodSpy.lastCall.args[0], 1); + assert.strictEqual(methodSpy.returnValues[0], 2); + }, + + 'no return value from advising function'() { + let receivedArgs: string[] = []; + let beforeCalled = false; + map = new Map([ + [ + property, + function(...args: string[]) { + receivedArgs = args; + } + ] + ]); + + aspect.before(map, property, function() { + beforeCalled = true; + }); + + const method = map.get(property); + method && method('foo', 'bar'); + + assert.isTrue(beforeCalled, 'Before advice should be called before original function'); + assert.deepEqual( + receivedArgs, + ['foo', 'bar'], + 'Arguments passed to original method should be unaltered if before advice returns undefined' + ); + }, + + 'multiple aspect.before()'() { + const aspectSpy1 = createBeforeSpy(); + const aspectSpy2 = createBeforeSpy(); + + aspect.before(map, property, aspectSpy1); + aspect.before(map, property, aspectSpy2); + + const method = map.get(property); + method && method(5); + assert.isTrue(aspectSpy2.calledBefore(aspectSpy1)); + assert.isTrue(aspectSpy1.calledBefore(methodSpy)); + assert.strictEqual(aspectSpy2.lastCall.args[0], 5); + assert.strictEqual(aspectSpy1.lastCall.args[0], 6); + assert.strictEqual(methodSpy.lastCall.args[0], 7); + assert.strictEqual(methodSpy.returnValues[0], 8); + }, + + 'multiple aspect.before() with removal inside handler'() { + let count = 0; + + const handle1 = aspect.before(map, property, function() { + count++; + }); + + // FIXME: TDZ + var handle2 = aspect.before(map, property, function() { + handle2.destroy(); + handle1.destroy(); + count++; + }); + + assert.doesNotThrow(function() { + const method = map.get(property); + method && method(); + }); + assert.strictEqual(count, 1, 'Only one advising function should be called'); + } + }, + + '.after': { + 'overriding return value from original method'() { + const expected = 'override!'; + const aspectSpy = sinon.stub().returns(expected); + + aspect.after(map, property, aspectSpy); + const method = map.get(property); + assert.strictEqual(method && method(0), expected); + assert.isTrue(aspectSpy.calledAfter(methodSpy)); + }, + + 'multiple aspect.after()'() { + const aspectStub1 = sinon.stub(); + const aspectStub2 = sinon.stub(); + + aspect.after(map, property, aspectStub1); + aspect.after(map, property, aspectStub2); + + const method = map.get(property); + method && method(0); + assert.isTrue(aspectStub1.calledAfter(methodSpy)); + assert.isTrue(aspectStub2.calledAfter(aspectStub1)); + }, + + 'multiple aspect.after() with removal inside handler'() { + let count = 0; + + let handle2: Handle; + + // FIXME: TDZ + var handle1 = aspect.after(map, property, function() { + handle1.destroy(); + handle2.destroy(); + count++; + }); + + handle2 = aspect.after(map, property, function() { + count++; + }); + + assert.doesNotThrow(function() { + const method = map.get(property); + method && method(); + }); + assert.strictEqual(count, 1, 'Only one advising function should be called'); + }, + + 'provides the original arguments to the aspect method'() { + const expected = 'expected'; + const aspectStub = sinon.stub().returns(expected); + + aspect.after(map, property, aspectStub); + const method = map.get(property); + assert.strictEqual(method && method(0), expected); + assert.isTrue(aspectStub.calledAfter(methodSpy)); + assert.strictEqual(aspectStub.lastCall.args[0], 1); + assert.deepEqual(slice.call(aspectStub.lastCall.args[1]), methodSpy.lastCall.args); + } + }, + + '.around': { + 'single around'() { + const expected = 5; + const aroundFunction = sinon.stub().returns(expected); + const aspectStub = sinon.stub().returns(aroundFunction); + + aspect.around(map, property, aspectStub); + + const method = map.get(property); + assert.strictEqual(method && method(0), expected); + assert.isTrue(aspectStub.calledOnce); + assert.isTrue(aroundFunction.calledOnce); + assert.strictEqual(aroundFunction.firstCall.args[0], 0); + assert.isFalse(methodSpy.called); + + // test that the original method was provided + aspectStub.callArgWith(0, 10); + assert.isTrue(methodSpy.calledOnce); + assert.strictEqual(methodSpy.firstCall.args[0], 10); + } + }, + + '.on()': { + 'advising function returns undefined, returns original result'() { + const aspectStub = sinon.stub(); + + aspect.on(map, property, aspectStub); + + const method = map.get(property); + assert.strictEqual(method && method(0), 1); + + assert.deepEqual(aspectStub.lastCall.args, methodSpy.lastCall.args); + assert.isTrue(methodSpy.calledOnce); + assert.isTrue(aspectStub.calledOnce); + assert.isTrue(aspectStub.calledAfter(methodSpy)); + }, + + 'advising function returns defined values, returns advising function result'() { + const aspectStub = sinon.stub().returns(2); + + aspect.on(map, property, aspectStub); + + const method = map.get(property); + assert.strictEqual(method && method(0), 2); + assert.deepEqual(aspectStub.lastCall.args, methodSpy.lastCall.args); + assert.isTrue(methodSpy.calledOnce); + assert.isTrue(aspectStub.calledOnce); + assert.isTrue(aspectStub.calledAfter(methodSpy)); + }, + + 'there are previous advising functions (covering previous.next)'() { + const aspectStub1 = sinon.stub().returns(2); + const aspectStub2 = sinon.stub(); + const aspectStub3 = sinon.stub().returns(6); + + aspect.on(map, property, aspectStub1); + aspect.on(map, property, aspectStub2); + aspect.on(map, property, aspectStub3); + + const method = map.get(property); + assert.strictEqual(method && method(0), 6); + + assert.deepEqual(aspectStub1.lastCall.args, methodSpy.lastCall.args); + assert.deepEqual(aspectStub2.lastCall.args, methodSpy.lastCall.args); + assert.deepEqual(aspectStub3.lastCall.args, methodSpy.lastCall.args); + + assert.isTrue(methodSpy.calledOnce); + assert.isTrue(aspectStub1.calledOnce); + assert.isTrue(aspectStub2.calledOnce); + assert.isTrue(aspectStub3.calledOnce); + + sinon.assert.callOrder(methodSpy, aspectStub1, aspectStub2, aspectStub3); + } + }, + + 'handle.destroy()': { + 'prevents aspect from being called'() { + const aspectSpy = createBeforeSpy(); + const handle = aspect.before(map, property, aspectSpy); + + let method = map.get(property); + method && method(0); + assert.notEqual(map.get(property), methodSpy); + + handle.destroy(); + method = map.get(property); + method && method(1); + assert.notEqual(map.get(property), methodSpy); + assert.isTrue(methodSpy.calledTwice); + assert.isTrue(aspectSpy.calledOnce); + }, + + 'can remove an aspect from the middle of a list'() { + const aspectSpy1 = createBeforeSpy(); + const aspectSpy2 = createBeforeSpy(); + const handle = aspect.before(map, property, aspectSpy1); + + aspect.before(map, property, aspectSpy2); + handle.destroy(); + + const method = map.get(property); + method && method(0); + assert.isTrue(methodSpy.called); + assert.isTrue(aspectSpy2.called); + assert.isFalse(aspectSpy1.called); + }, + + 'removing a aspect stub'() { + const map = new Map(); + const aspectSpy = sinon.stub(); + aspect.before(map, property, sinon.stub()); + const handle = aspect.before(map, property, aspectSpy); + + handle.destroy(); + const method: any = map.get(property); + method && method(0); + assert.isFalse(aspectSpy.called); + }, + + 'removing the first of multiple aspects'() { + const aroundFunction = sinon.stub(); + const aspectStub = sinon.stub().returns(aroundFunction); + const handle = aspect.around(map, property, aspectStub); + + handle.destroy(); + const method = map.get(property); + method && method(0); + assert.isTrue(aspectStub.calledOnce); + assert.isTrue(methodSpy.calledOnce); + assert.isFalse(aroundFunction.called); + } + } + } + }; +} + +registerSuite('aspect', { + 'with indexable objects': { + 'string properties': indexableTests('method'), + 'symbol properties': indexableTests(Symbol()) + }, + + 'with maps': { + 'string indexes': mapTests('method'), + 'symbol indexes': mapTests(Symbol()) + }, + 'join points': { + 'before advice': { + 'adjust arguments': function() { + let result = 0; + function foo(a: number) { + result = a; + } + + function advice(a: number) { + return [a * a]; + } + + const fn = aspect.before(foo, advice); + + fn(2); + + assert.strictEqual(result, 4, '"result" should equal 4'); + }, + 'passes this': function() { + let result = 0; + function foo(this: any) { + result = this.a; + } + + function advice(this: any) { + this.a = 2; + } + + const fn = aspect.before(foo, advice); + const context = { a: 0 }; + fn.call(context); + assert.strictEqual(context.a, 2, 'context.a should equal 2'); + assert.strictEqual(result, 2, 'result should equal 2'); + }, + 'multiple before advice': function() { + let result = 0; + const calls: string[] = []; + function foo(a: number) { + result = a; + } + + function advice1(...args: any[]) { + calls.push('1'); + args[0] = args[0] + args[0]; + return args; + } + + function advice2(a: number) { + calls.push('2'); + return [++a]; + } + + const fn = aspect.before(aspect.before(foo, advice1), advice2); + fn(2); + assert.strictEqual(result, 6, '"result" should equal 5'); + assert.deepEqual(calls, ['2', '1'], 'advice should be called in order'); + } + }, + 'after advice': { + 'adjust return value': function() { + function foo(a: number) { + return a; + } + + function advice(prevResult: number, ...args: any[]) { + return prevResult * args[0]; + } + + const fn = aspect.after(foo, advice); + + const result = fn(2); + + assert.strictEqual(result, 4, '"result" should equal 4'); + }, + 'passes this': function() { + function foo(this: any) { + return this.a; + } + + function advice(this: any, prevResult: number) { + this.c = prevResult + this.b; + return this.c; + } + + const fn = aspect.after(foo, advice); + const context = { a: 2, b: 2, c: 0 }; + const result = fn.call(context); + assert.strictEqual(result, 4, '"result" should equal 4'); + assert.strictEqual(context.c, 4, '"context.c" should equal 4'); + }, + 'multiple after advice': function() { + const calls: string[] = []; + function foo(a: number): number { + return a; + } + + function advice1(prevResult: number, ...args: any[]) { + calls.push('1'); + return prevResult + args[0]; + } + + function advice2(prevResult: number, ...args: any[]) { + calls.push('2'); + return prevResult + args[0] + 1; + } + + let fn = aspect.after(foo, advice1); + fn = aspect.after(fn, advice2); + const result = fn(2); + assert.strictEqual(result, 7, '"result" should equal 7'); + assert.deepEqual(calls, ['1', '2'], 'call should have been made in order'); + } + }, + 'around advice': { + 'basic function': function() { + function foo(a: number): number { + return a; + } + + function advice(origFn: Function): (...args: any[]) => number { + return function(this: any, ...args: any[]): number { + args[0] = args[0] + args[0]; + let result = origFn.apply(this, args); + return ++result; + }; + } + + const fn = aspect.around(foo, advice); + const result = fn(2); + assert.strictEqual(result, 5, '"result" should equal 5'); + }, + 'preserves this': function() { + function foo(this: any, a: number): number { + return this.a; + } + + function advice(origFn: Function): (...args: any[]) => number { + return function(this: any, ...args: any[]): number { + this.a = 2; + return origFn.apply(this, args); + }; + } + + const context = { a: 2 }; + const fn = aspect.around(foo, advice); + const result = fn.apply(context); + assert.strictEqual(result, 2, '"result" should equal 2'); + }, + 'multiple around advice': function() { + const calls: string[] = []; + function foo(a: number): number { + return a; + } + + function advice1(origFn: Function): (...args: any[]) => number { + return function(this: any, ...args: any[]): number { + calls.push('1'); + args[0]++; + return origFn.apply(this, args) + 1; + }; + } + + function advice2(origFn: Function): (...args: any[]) => number { + return function(this: any, ...args: any[]): number { + calls.push('2'); + args[0] += args[0]; + return origFn.apply(this, args) + 1; + }; + } + + const fn = aspect.around(aspect.around(foo, advice1), advice2); + const result = fn(2); + assert.strictEqual(result, 7, '"result" should equal 7'); + assert.deepEqual(calls, ['2', '1']); + } + }, + 'combined advice': { + 'before and after': function() { + function foo(a: number): number { + return a + a; + } + + function adviceBefore(...args: any[]): any[] { + args[0] = args[0] + args[0]; + return args; + } + + function adviceAfter(origResult: number, ...args: any[]): number { + return origResult + args[0] + 1; + } + + let fn = aspect.after(foo, adviceAfter); + fn = aspect.before(fn, adviceBefore); + const result = fn(2); + assert.strictEqual(result, 13, '"result" should equal 13'); + } + }, + 'chained advice'() { + function foo(a: string): string { + return a; + } + + function adviceAfter(origResult: string): string { + return origResult + 'foo'; + } + + const fn = aspect.after(aspect.after(foo, adviceAfter), adviceAfter); + aspect.after(fn, adviceAfter); + assert.strictEqual(fn('bar'), 'barfoofoo', 'should only apply advice twice'); + } + } +}); diff --git a/src/lib/core/tests/unit/async/ExtensiblePromise.ts b/src/lib/core/tests/unit/async/ExtensiblePromise.ts new file mode 100644 index 0000000..aaae117 --- /dev/null +++ b/src/lib/core/tests/unit/async/ExtensiblePromise.ts @@ -0,0 +1,92 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import ExtensiblePromise from '../../../src/async/ExtensiblePromise'; + +registerSuite('ExtensiblePromise', { + reject: function(this: any) { + let dfd = this.async(); + ExtensiblePromise.reject().then( + dfd.rejectOnError(() => assert.isTrue(false, 'Should not have called then with a rejected promise')), + dfd.callback(() => {}) + ); + }, + + resolve: function(this: any) { + let dfd = this.async(); + ExtensiblePromise.resolve().then( + dfd.callback(() => {}), + dfd.rejectOnError(() => assert.isTrue(false, 'Promise was rejected but it should have resolved')) + ); + }, + + catch: function(this: any) { + let dfd = this.async(); + ExtensiblePromise.reject().catch(dfd.callback(() => {})); + }, + + 'then resolve w/ no handler': function(this: any) { + let dfd = this.async(); + ExtensiblePromise.resolve().then( + undefined, + dfd.rejectOnError(() => { + assert.isTrue(false, 'Should not have rejected'); + }) + ); + setTimeout(dfd.callback(() => {}), 100); + }, + + 'then reject w/ no handler': function(this: any) { + let dfd = this.async(); + + ExtensiblePromise.reject() + .then( + dfd.rejectOnError(() => { + assert.isTrue(false, 'Should not have resolved'); + }), + undefined + ) + .catch(dfd.callback(() => {})); + }, + + '.all': { + 'with array'() { + return ExtensiblePromise.all([ + 1, + ExtensiblePromise.resolve(2), + new ExtensiblePromise((resolve) => { + setTimeout(() => resolve(3), 100); + }) + ]).then((results: any) => { + assert.deepEqual(results, [1, 2, 3]); + }); + }, + + 'with object'() { + return ExtensiblePromise.all({ + one: 1, + two: ExtensiblePromise.resolve(2), + three: new ExtensiblePromise((resolve) => { + setTimeout(() => resolve(3), 100); + }) + }).then((results: any) => { + assert.deepEqual(results, { one: 1, two: 2, three: 3 }); + }); + }, + + 'errors with object'(this: any) { + let dfd = this.async(); + + ExtensiblePromise.all({ + one: ExtensiblePromise.resolve(1), + two: ExtensiblePromise.reject(new Error('error message')) + }).then( + dfd.rejectOnError(() => { + assert.fail('should have failed'); + }), + dfd.callback((error: Error) => { + assert.equal(error.message, 'error message'); + }) + ); + } + } +}); diff --git a/src/lib/core/tests/unit/async/Task.ts b/src/lib/core/tests/unit/async/Task.ts new file mode 100644 index 0000000..4f29668 --- /dev/null +++ b/src/lib/core/tests/unit/async/Task.ts @@ -0,0 +1,973 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { Tests } from 'intern/lib/interfaces/object'; +import Promise from '@dojo/shim/Promise'; +import { Thenable } from '@dojo/shim/interfaces'; +import { ShimIterator } from '@dojo/shim/iterator'; +import Task, { State, isTask } from '../../../src/async/Task'; + +const suite: Tests = { + 'isTask()'() { + const task = new Task((resolve) => resolve(), () => {}); + + assert.isTrue(isTask(task), 'Should return true'); + assert.isFalse(isTask(Promise.resolve()), 'Should return false'); + assert.isFalse(isTask(true), 'Should return false'); + assert.isFalse(isTask(null), 'Should return false'); + assert.isFalse(isTask({}), 'Should return false'); + assert.isFalse(isTask(1), 'Should return false'); + assert.isFalse(isTask(NaN), 'Should return false'); + }, + + 'Task#cancel'(this: any) { + let dfd = this.async(); + let cancelerCalled = false; + let resolver: any; + let task = new Task( + function(resolve) { + resolver = resolve; + }, + function() { + cancelerCalled = true; + } + ).then( + dfd.rejectOnError(function() { + assert(false, 'Task should not have resolved'); + }) + ); + + task.cancel(); + resolver(); + + assert.isTrue(cancelerCalled, 'Canceler should have been called synchronously'); + assert.strictEqual(task.state, State.Canceled, 'Task should have Canceled state'); + + setTimeout(dfd.callback(function() {}), 100); + }, + + 'Task#cancel with no canceler'(this: any) { + let dfd = this.async(); + let resolver: any; + let task = new Task((resolve) => { + resolver = resolve; + }).then( + dfd.rejectOnError(function() { + assert(false, 'Task should not have resolved'); + }) + ); + + task.cancel(); + resolver(); + + assert.strictEqual(task.state, State.Canceled, 'Task should have canceled state'); + setTimeout(dfd.callback(() => {}), 100); + }, + + "Task#cancel resolved/rejected promises don't call canceler"(this: any) { + let dfd = this.async(); + let cancelCalled = false; + let task = new Task( + (resolve) => { + setTimeout(() => { + resolve(); + }, 0); + }, + () => { + cancelCalled = true; + } + ); + + setTimeout(() => { + task.cancel(); + }, 10); + + setTimeout( + dfd.callback(() => { + assert.strictEqual(task.state, State.Fulfilled, 'Task should have fulfilled state'); + assert.isFalse(cancelCalled, 'Cancel should not have been called'); + }), + 100 + ); + }, + + 'Task#finally': { + 'canceled resolve'(this: any) { + let dfd = this.async(); + let resolver: any; + let task = new Task( + function(resolve) { + resolver = resolve; + }, + function() {} + ) + .then( + dfd.rejectOnError(function() { + assert(false, 'Task should not have resolved'); + }), + dfd.rejectOnError(function() { + assert(false, 'Task should not have rejected'); + }) + ) + .finally(dfd.callback(function() {})); + + task.cancel(); + resolver(); + }, + + 'canceled reject'(this: any) { + let dfd = this.async(); + let resolver: any; + let task = new Task( + function(resolve, reject) { + resolver = reject; + }, + function() {} + ) + .then( + dfd.rejectOnError(function() { + assert(false, 'Task should not have resolved'); + }), + dfd.rejectOnError(function() { + assert(false, 'Task should not have rejected'); + }) + ) + .finally(dfd.callback(function() {})); + + task.cancel(); + resolver(); + }, + + 'canceled with multiple children'(this: any) { + let dfd = this.async(5000, 4); + let resolver: any; + let task = new Task( + function(resolve, reject) { + resolver = resolve; + }, + function() {} + ).finally(function() { + return Task.resolve(5); + }); + + let taskA = task.finally(function() { + dfd.resolve(); + throw new Error('foo'); + }); + taskA.finally(dfd.callback(function() {})); + task.finally(dfd.callback(function() {})); + task.finally(dfd.callback(function() {})); + + task.cancel(); + resolver(); + }, + + 'canceled and resolved inside then callback'(this: any) { + let dfd = this.async(); + let resolver: any; + + let task = new Task( + function(resolve, reject) { + resolver = resolve; + }, + function() {} + ) + .then(function() { + task.cancel(); + return new Promise(function(resolve, reject) { + setTimeout(resolve); + }); + }) + .then( + dfd.rejectOnError(function() { + assert(false, 'should not have run'); + }) + ) + .then( + dfd.rejectOnError(function() { + assert(false, 'should not have run'); + }) + ) + .finally(dfd.callback(function() {})); + + resolver(); + }, + + 'canceled and rejected inside then callback'(this: any) { + let dfd = this.async(); + let resolver: any; + + let task = new Task( + function(resolve, reject) { + resolver = resolve; + }, + function() {} + ) + .then(function() { + task.cancel(); + return new Promise(function(resolve, reject) { + setTimeout(reject); + }).catch(() => {}); + }) + .then( + dfd.rejectOnError(function() { + assert(false, 'should not have run'); + }) + ) + .then( + dfd.rejectOnError(function() { + assert(false, 'should not have run'); + }) + ) + .catch(() => {}) + .finally(dfd.callback(function() {})); + + resolver(); + }, + + 'invoked if already canceled'(this: any) { + const dfd = this.async(); + const task = new Task(() => {}); + task.cancel(); + + task.finally(dfd.callback(() => {})); + }, + + 'finally is only called once when called after cancel'(this: any) { + let callCount = 0; + const dfd = this.async(); + const task = new Task((resolve) => { + setTimeout(resolve, 10); + }); + task.cancel(); + task.finally( + dfd.callback(() => { + callCount++; + }) + ); + + setTimeout( + dfd.callback(() => { + assert.equal(callCount, 1); + }), + 100 + ); + }, + + 'finally is only called once when called before cancel'(this: any) { + let callCount = 0; + const dfd = this.async(); + const task = new Task((resolve) => { + setTimeout(resolve, 10); + }); + task.finally( + dfd.callback(() => { + callCount++; + }) + ); + task.cancel(); + + setTimeout( + dfd.callback(() => { + assert.equal(callCount, 1); + }), + 100 + ); + }, + + 'finally does not change the resolve value'(this: any) { + const dfd = this.async(); + let task = new Task((resolve) => { + setTimeout(resolve.bind(null, 'test'), 10); + }); + task = task.finally(() => 'changed'); + task.then( + dfd.callback((value: string) => { + assert.strictEqual(value, 'test'); + }) + ); + } + }, + + 'Task.resolve': { + 'returns a task'() { + const task = Task.resolve('foo'); + + assert.isFunction(task.cancel, 'A task should have a cancel function'); + assert.isFunction(task.finally, 'A task should have a finally function'); + + return task.then((result) => { + assert.strictEqual(result, 'foo', 'result should equal "foo"'); + }); + } + } +}; + +/* tslint:disable-next-line:variable-name */ +function addPromiseTests(suite: any, Promise: any) { + suite['.all'] = { + 'empty array': function(this: any) { + let dfd = this.async(); + let promise = Promise.all([]).then( + dfd.callback(function(value: any[]) { + assert.isArray(value); + assert.deepEqual(value, []); + }) + ); + assert.instanceOf(promise, Promise, 'promise should have expected type'); + }, + + 'mixed values and resolved': function(this: any) { + let dfd = this.async(); + Promise.all([0, Promise.resolve(1), Promise.resolve(2)]).then( + dfd.callback(function(value: number[]) { + assert.isArray(value); + assert.deepEqual(value, [0, 1, 2]); + }) + ); + }, + + 'iterable argument': function(this: any) { + let dfd = this.async(); + Promise.all({ + [Symbol.iterator]() { + return new ShimIterator>([0, Promise.resolve(1), Promise.resolve(2)]); + } + }).then( + dfd.callback(function(value: number[]) { + assert.isArray(value); + assert.deepEqual(value, [0, 1, 2]); + }) + ); + }, + + 'reject if any rejected': function(this: any) { + let dfd = this.async(); + let pending = new Promise(function() {}); + let rejected = Promise.reject(new Error('rejected')); + + Promise.all([pending, rejected]).then( + dfd.rejectOnError(function() { + assert(false, 'Should not have resolved'); + }), + dfd.callback(function(error: Error) { + assert.strictEqual(error.message, 'rejected'); + }) + ); + }, + + 'foreign thenables': function(this: any) { + let dfd = this.async(); + let normal = Promise.resolve(1); + let foreign = { + then: function(f: Function) { + f(2); + } + }; + + Promise.all([normal, foreign]).then( + dfd.callback(function(value: number[]) { + assert.deepEqual(value, [1, 2]); + }) + ); + }, + + 'non-callable thenables': function(this: any) { + let dfd = this.async(); + let normal = Promise.resolve(1); + let foreign = { then: 'foo' }; + + Promise.all([normal, foreign]).then( + dfd.callback(function(value: number[]) { + assert.deepEqual(value, [1, foreign]); + }) + ); + }, + + 'sparse array': { + all(this: any) { + let dfd = this.async(); + let iterable: any[] = []; + + iterable[1] = Promise.resolve(1); + iterable[3] = Promise.resolve(3); + + Promise.all(iterable).then( + dfd.callback(function(value: number[]) { + assert.isUndefined(value[0]); + assert.strictEqual(value[1], 1); + assert.isUndefined(value[2]); + assert.strictEqual(value[3], 3); + }) + ); + }, + + race(this: any) { + let dfd = this.async(); + let iterable: any[] = []; + + iterable[1] = Promise.resolve(1); + iterable[3] = Promise.resolve(3); + + Promise.race(iterable).then( + dfd.callback(function(value: number) { + assert.isUndefined(value); + }) + ); + } + }, + + 'value not input': function(this: any) { + let dfd = this.async(); + let iterable = [0, 1]; + + Promise.all(iterable).then( + dfd.callback(function(value: number[]) { + assert.notStrictEqual(value, iterable); + }) + ); + }, + + cancelable: (function() { + return { + isIterable: function(this: any) { + // Make sure it checks whether each PromiseLike is cancelable + const promise = Promise.resolve(); + promise.cancel = null; + const pending = [promise, new Task(() => {}), new Task(() => {})]; + + cancelTasks(pending).then(() => { + pending.forEach((task) => { + if (isTask(task)) { + assert.strictEqual(task.state, State.Canceled, 'Task should have Canceled state'); + } + }); + }); + }, + isObject: function(this: any) { + // Make sure it checks whether each PromiseLike is cancelable + const promise = Promise.resolve(); + promise.cancel = null; + const pending: { [index: string]: PromiseLike } = { + foo: new Task(() => {}), + bar: new Task(() => {}), + promise + }; + + cancelTasks(pending).then(() => { + Object.keys(pending).forEach((key) => { + let task = pending[key]; + if (isTask(task)) { + assert.strictEqual(task.state, State.Canceled, 'Task should have Canceled state'); + } + }); + }); + } + }; + + function cancelTasks(pending: any) { + const tasks = Task.all(pending); + + tasks.cancel(); + + return tasks; + } + })() + }; + + suite['.race'] = { + 'empty array': function(this: any) { + let dfd = this.async(); + Promise.race([]).then( + dfd.rejectOnError(function() { + assert.fail(false, true, 'Promise should not have resolved'); + }) + ); + setTimeout(dfd.callback(function() {}), 10); + }, + + 'mixed values and resolved': function(this: any) { + let dfd = this.async(); + Promise.race([0, Promise.resolve(1), Promise.resolve(2)]).then( + dfd.callback(function(value: any) { + assert.strictEqual(value, 0); + }) + ); + }, + + 'iterable argument': function(this: any) { + let dfd = this.async(); + Promise.race({ + [Symbol.iterator]() { + return new ShimIterator>([0, Promise.resolve(1), Promise.resolve(2)]); + } + }).then( + dfd.callback(function(value: any) { + assert.strictEqual(value, 0); + }) + ); + }, + + 'reject if any rejected': function(this: any) { + let dfd = this.async(); + let pending = new Promise(function() {}); + let rejected = Promise.reject(new Error('rejected')); + + Promise.race([pending, rejected]).then( + dfd.rejectOnError(function() { + assert(false, 'Should not have resolved'); + }), + dfd.callback(function(error: Error) { + assert.strictEqual(error.message, 'rejected'); + }) + ); + }, + + 'foreign thenables': function(this: any) { + let dfd = this.async(); + let normal = Promise.resolve(1); + let foreign = { + then: function(f: Function) { + f(2); + } + }; + + Promise.race([normal, foreign]).then( + dfd.callback(function(value: any) { + assert.strictEqual(value, 1); + }) + ); + } + }; + + suite['.reject'] = { + error(this: any) { + let dfd = this.async(); + let resolved = false; + let promise = Promise.reject(new Error('foo')).then( + dfd.rejectOnError(function() { + resolved = true; + assert(false, 'should not have resolved'); + }), + dfd.callback(function(error: Error) { + resolved = true; + assert.instanceOf(error, Error, 'error value should be an Error'); + assert.propertyVal(error, 'message', 'foo', 'error value should have expected message'); + }) + ); + + assert.instanceOf(promise, Promise, 'promise should have expected type'); + assert.isFalse(resolved, 'promise should not have resolved synchronously'); + }, + + 'rejected thenable'(this: any) { + let dfd = this.async(); + let resolved = false; + let thenable = { + then: function(f: Function, r: Function) { + r(new Error('foo')); + } + }; + Promise.resolve(thenable).then( + dfd.rejectOnError(function() { + resolved = true; + assert(false, 'should not have rejected'); + }), + dfd.callback(function(error: Error) { + resolved = true; + // value should be resolved value of thenable + assert.instanceOf(error, Error, 'error value should be an Error'); + assert.propertyVal(error, 'message', 'foo', 'error value should have expected message'); + }) + ); + + assert.isFalse(resolved, 'promise should not have resolved synchronously'); + } + }; + + suite['.resolve'] = { + 'simple value'(this: any) { + let dfd = this.async(); + let resolved = false; + let promise = Promise.resolve('foo').then( + dfd.callback(function(value: any) { + resolved = true; + assert.equal(value, 'foo', 'unexpected resolution value'); + }), + dfd.rejectOnError(function() { + resolved = true; + assert(false, 'should not have rejected'); + }) + ); + + assert.instanceOf(promise, Promise, 'promise should have expected type'); + assert.isFalse(resolved, 'promise should not have resolved synchronously'); + }, + + thenable(this: any) { + let dfd = this.async(); + let resolved = false; + let thenable = { + then: function(f: Function) { + f(2); + } + }; + Promise.resolve(thenable).then( + dfd.callback(function(value: any) { + resolved = true; + // value should be resolved value of thenable + assert.equal(value, 2, 'unexpected resolution value'); + }), + dfd.rejectOnError(function() { + resolved = true; + assert(false, 'should not have rejected'); + }) + ); + + assert.isFalse(resolved, 'promise should not have resolved synchronously'); + } + }; + + suite['#catch'] = { + rejection: function(this: any) { + let dfd = this.async(); + let error = new Error('foo'); + Promise.reject(error).catch( + dfd.callback(function(err: Error) { + assert.strictEqual(err, error); + }) + ); + }, + + identity: function(this: any) { + let dfd = this.async(); + let error = new Error('foo'); + Promise.reject(error) + .then( + dfd.rejectOnError(function() { + assert(false, 'Should not be resolved'); + }) + ) + .catch( + dfd.callback(function(err: Error) { + assert.strictEqual(err, error); + }) + ); + }, + + 'resolver throws': function(this: any) { + let dfd = this.async(); + + let error = new Error('foo'); + let promise = new Promise(function() { + throw error; + }); + + promise.catch( + dfd.callback((err: Error) => { + assert.strictEqual(err, error); + }) + ); + }, + + 'handler throws': function(this: any) { + let dfd = this.async(); + let error = new Error('foo'); + Promise.resolve(5) + .then(function() { + throw error; + }) + .catch( + dfd.callback(function(err: Error) { + assert.strictEqual(err, error); + }) + ); + }, + + 'then throws': { + 'from resolver': function(this: any) { + let dfd = this.async(); + let error = new Error('foo'); + let foreign = Promise.resolve().then(() => { + throw error; + }); + + let promise = new Promise(function(resolve: Function) { + resolve(foreign); + }); + promise.catch( + dfd.callback(function(err: Error) { + assert.strictEqual(err, error); + }) + ); + }, + + 'from handler': function(this: any) { + let dfd = this.async(); + let error = new Error('foo'); + let foreign = Promise.resolve().then(() => { + throw error; + }); + + Promise.resolve(5) + .then(function() { + return foreign; + }) + .catch( + dfd.callback(function(err: Error) { + assert.strictEqual(err, error); + }) + ); + }, + + 'then throws': { + 'from resolver': function(this: any) { + let dfd = this.async(); + let error = new Error('foo'); + let foreign = Promise.resolve().then(() => { + throw error; + }); + + let promise = new Promise(function(resolve: Function) { + resolve(foreign); + }); + promise.catch( + dfd.callback(function(err: Error) { + assert.strictEqual(err, error); + }) + ); + }, + + 'from handler': function(this: any) { + let dfd = this.async(); + let error = new Error('foo'); + let foreign = Promise.resolve().then(() => { + throw error; + }); + + Promise.resolve(5) + .then(function() { + return foreign; + }) + .catch( + dfd.callback(function(err: Error) { + assert.strictEqual(err, error); + }) + ); + } + } + } + }; + + suite['#finally'] = { + 'called for resolved Promise': function(this: any) { + let dfd = this.async(); + Promise.resolve(5).finally(dfd.callback(function() {})); + }, + + 'called for rejected Promise': function(this: any) { + let dfd = this.async(); + Promise.reject(new Error('foo')) + .catch(() => {}) + .finally(dfd.callback(function() {})); + }, + + 'value passes through': function(this: any) { + let dfd = this.async(); + Promise.resolve(5) + .finally(function() {}) + .then( + dfd.callback(function(value: any) { + assert.strictEqual(value, 5); + }) + ); + }, + + 'rejection passes through': function(this: any) { + let dfd = this.async(); + Promise.reject(new Error('foo')) + .finally(function() {}) + .then( + dfd.rejectOnError(function() { + assert(false, 'Should not have resolved'); + }), + dfd.callback(function(reason: any) { + assert.propertyVal(reason, 'message', 'foo'); + }) + ); + }, + + 'returned value is ignored': function(this: any) { + let dfd = this.async(); + Promise.resolve(5) + .finally(function(): any { + return 4; + }) + .then( + dfd.callback(function(value: any) { + assert.strictEqual(value, 5); + }), + dfd.rejectOnError(function() { + assert(false, 'Should not have rejected'); + }) + ); + }, + + 'returned resolved promise is ignored': function(this: any) { + let dfd = this.async(); + Promise.resolve(5) + .finally(function(): any { + return Promise.resolve(4); + }) + .then( + dfd.callback(function(value: any) { + assert.strictEqual(value, 5); + }), + dfd.rejectOnError(function() { + assert(false, 'Should not have rejected'); + }) + ); + }, + + 'thrown error rejects': function(this: any) { + let dfd = this.async(); + Promise.resolve(5) + .finally(function() { + throw new Error('foo'); + }) + .then( + dfd.rejectOnError(function(value: any) { + assert(false, 'Should not have rejected'); + }), + dfd.callback(function(reason: any) { + assert.propertyVal(reason, 'message', 'foo'); + }) + ); + }, + + 'returned rejected promise rejects': function(this: any) { + let dfd = this.async(); + Promise.resolve(5) + .finally(function() { + return Promise.reject(new Error('foo')); + }) + .then( + dfd.rejectOnError(function(value: any) { + assert(false, 'Should not have rejected'); + }), + dfd.callback(function(reason: any) { + assert.propertyVal(reason, 'message', 'foo'); + }) + ); + }, + + 'returned resolved promise on rejection rejects': function(this: any) { + let dfd = this.async(); + Promise.reject(new Error('foo')) + .finally(function() { + return Promise.resolve(5); + }) + .then( + dfd.rejectOnError(function(value: any) { + assert(false, 'Should not have rejected'); + }), + dfd.callback(function(reason: any) { + assert.propertyVal(reason, 'message', 'foo'); + }) + ); + } + }; + + suite['#then'] = { + fulfillment: function(this: any) { + let dfd = this.async(); + Promise.resolve(5).then( + dfd.callback(function(value: number) { + assert.strictEqual(value, 5); + }) + ); + }, + + identity: function(this: any) { + let dfd = this.async(); + Promise.resolve(5) + .then( + null, + dfd.rejectOnError(function(value: Error) { + assert(false, 'Should not have resolved'); + }) + ) + .then( + dfd.callback(function(value: number) { + assert.strictEqual(value, 5); + }) + ); + }, + + 'resolve once': function(this: any) { + let dfd = this.async(); + let evilPromise = { + then: (f?: Function, r?: Function) => { + if (f) { + f(1); + f(2); + } + } + }; + + let calledAlready = false; + const p = Promise.resolve(evilPromise).then( + dfd.rejectOnError(function(value: number) { + assert.strictEqual(calledAlready, false, 'resolver should not have been called'); + calledAlready = true; + assert.strictEqual(value, 1, 'resolver called with unexpected value'); + }) + ); + + p.catch(dfd.reject.bind(dfd)); + + setTimeout(() => dfd.resolve(), 100); + } + }; + + suite.constructed = { + resolved(this: any) { + let dfd = this.async(); + let resolver: any; + let resolved = false; + new Promise(function(resolve: any, reject: any) { + resolver = resolve; + }).then( + dfd.callback(function() { + resolved = true; + }), + dfd.rejectOnError(function() { + assert(false, 'should not have rejected'); + }) + ); + assert.isFalse(resolved, 'should not be resolved'); + resolver(); + }, + + rejected(this: any) { + let dfd = this.async(); + let resolver: any; + let resolved = false; + new Promise(function(resolve: any, reject: any) { + resolver = reject; + }).then( + dfd.rejectOnError(function() { + assert(false, 'should not have resolved'); + }), + dfd.callback(function() { + resolved = true; + }) + ); + assert.isFalse(resolved, 'should not be resolved'); + resolver(); + } + }; +} + +addPromiseTests(suite, Task); + +registerSuite('Task', suite); diff --git a/src/lib/core/tests/unit/async/iteration.ts b/src/lib/core/tests/unit/async/iteration.ts new file mode 100644 index 0000000..6192808 --- /dev/null +++ b/src/lib/core/tests/unit/async/iteration.ts @@ -0,0 +1,1041 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { Tests } from 'intern/lib/interfaces/object'; +import * as iteration from '../../../src/async/iteration'; +import { ShimIterator } from '@dojo/shim/iterator'; +import Promise from '@dojo/shim/Promise'; +import { isEventuallyRejected, throwImmediatly } from '../../support/util'; + +interface ResolveFunc { + (value: T | Promise): Promise; + (): Promise; +} + +interface RejectFunc { + (reason: any): Promise; + (): Promise; +} + +interface ControlledPromise extends Promise { + resolve: ResolveFunc; + reject: RejectFunc; +} + +function createTriggerablePromise(): ControlledPromise { + let resolveFunc: any; + let rejectFunc: any; + const dfd: ControlledPromise = >new Promise(function(resolve, reject) { + resolveFunc = resolve; + rejectFunc = reject; + }); + dfd.resolve = resolveFunc; + dfd.reject = rejectFunc; + return dfd; +} + +function createTriggerablePromises(amount: number): ControlledPromise[] { + const list = Array(amount); + for (amount--; amount >= 0; amount--) { + list[amount] = createTriggerablePromise(); + } + return list; +} + +function helloWorldTest(value: any): boolean { + return value === 'hello' || value === 'world'; +} + +function doublerMapper(value: any): any { + return value * 2; +} + +function assertTrue(value: boolean): void { + assert.isTrue(value); +} + +function assertFalse(value: boolean): void { + assert.isFalse(value); +} + +function getIterable(useIterator: boolean, values: any[]): any { + return useIterator ? new ShimIterator(values) : values; +} + +function join(current: string, value: string): string { + return current + value; +} + +function findTests( + findMethod: (items: any[], callback: iteration.Filterer) => Promise, + solutions: any +): Tests { + function getExpectedSolution(test: any): any { + return solutions[test.parent.name][test.name]; + } + + function getTests(useIterator: boolean = false): any { + return { + 'synchronous values': { + 'no matching values; returns undefined': function(this: any) { + const expected: any = getExpectedSolution(this); + const values = ['non-matching']; + const iterable = getIterable(useIterator, values); + return findMethod(iterable, helloWorldTest).then(function(result) { + assert.strictEqual(result, expected); + }); + }, + + 'one matching value': function(this: any) { + const expected: any = getExpectedSolution(this); + const values = ['non-matching', 'hello']; + const iterable = getIterable(useIterator, values); + return findMethod(iterable, helloWorldTest).then(function(result) { + assert.strictEqual(result, expected); + }); + }, + + 'multiple matching values; only returns the first': function(this: any) { + const expected: any = getExpectedSolution(this); + const values = ['non-matching', 'hello', 'world']; + const iterable = getIterable(useIterator, values); + return findMethod(iterable, helloWorldTest).then(function(result) { + assert.strictEqual(result, expected); + }); + } + }, + + 'asynchronous values': { + 'no matching values; returns undefined': function(this: any) { + const expected: any = getExpectedSolution(this); + const values = [createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = findMethod(iterable, helloWorldTest).then(function(result) { + assert.strictEqual(result, expected); + }); + + values[0].resolve('non-matching'); + + return promise; + }, + + 'one matching value': function(this: any) { + const expected: any = getExpectedSolution(this); + const values = [createTriggerablePromise(), createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = findMethod(iterable, helloWorldTest).then(function(result) { + assert.strictEqual(result, expected); + }); + + values[0].resolve('non-matching'); + values[1].resolve('hello'); + + return promise; + }, + + 'multiple matching values; only returns the first': function(this: any) { + const expected: any = getExpectedSolution(this); + const values = [createTriggerablePromise(), createTriggerablePromise(), createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = findMethod(iterable, helloWorldTest).then(function(result) { + assert.strictEqual(result, expected); + }); + + values[0].resolve('non-matching'); + values[1].resolve('hello'); + values[2].resolve('world'); + + return promise; + }, + + 'mixed synchronous and asynchronous values': function(this: any) { + const expected: any = getExpectedSolution(this); + const values: [ControlledPromise, string, ControlledPromise] = [ + createTriggerablePromise(), + 'hello', + createTriggerablePromise() + ]; + const iterable = getIterable(useIterator, values); + const promise = findMethod(iterable, helloWorldTest).then(function(result) { + assert.strictEqual(result, expected); + }); + + (>values[0]).resolve('non-matching'); + (>values[2]).resolve('world'); + + return promise; + }, + + 'rejected promise value': function() { + const values = [createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = findMethod(iterable, helloWorldTest); + + values[0].reject(); + + return isEventuallyRejected(promise); + } + }, + + 'asynchronous callback': { + 'one asynchronous result': function(this: any) { + const expected: any = getExpectedSolution(this); + const values = ['value1']; + const iterable = getIterable(useIterator, values); + const result = [createTriggerablePromise()]; + const promise = findMethod(iterable, function(value, i) { + return result[i] as Promise; + }).then(function(value) { + assert.strictEqual(value, expected); + }); + + result[0].resolve(true); + + return promise; + }, + + 'asynchronous result with an eventually rejected promise': function() { + const values = ['value1']; + const iterable = getIterable(useIterator, values); + const result = [createTriggerablePromise()]; + const promise = findMethod(iterable, function(value, i) { + return result[i] as Promise; + }); + + result[0].reject(); + + return isEventuallyRejected(promise); + } + } + }; + } + + return { + 'array-like value': getTests(false), + 'iterator value': getTests(true) + }; +} + +function reduceTests( + reduceMethod: ( + items: (any | Promise)[], + callback: iteration.Reducer, + initialvalue?: any + ) => Promise, + solutions: any +): Tests { + function getExpectedSolution(test: any): any { + return solutions[test.parent.name][test.name]; + } + + function getTests(useIterator: boolean = false): any { + const valueType = useIterator ? 'iterator' : 'array'; + + return { + 'synchronous values': { + [`reduce an empty ${valueType} without initial value is eventually rejected`]: function() { + const value = getIterable(useIterator, []); + const promise = (reduceMethod)(value); + + return isEventuallyRejected(promise); + }, + + 'reduce a single value without an initial value; should not call callback': function(this: any) { + const expected: any = getExpectedSolution(this); + + const values = ['h']; + const iterable = getIterable(useIterator, values); + return reduceMethod(iterable, throwImmediatly).then(function(value) { + assert.strictEqual(value, expected); + }); + }, + + 'reduce multiple values': function(this: any) { + const expected: any = getExpectedSolution(this); + + const values = ['h', 'e', 'l', 'l', 'o']; + const iterable = getIterable(useIterator, values); + return reduceMethod(iterable, join).then(function(value) { + assert.strictEqual(value, expected); + }); + }, + + 'reduce multiple values with initializer': function(this: any) { + const expected: any = getExpectedSolution(this); + + const values = ['w', 'o', 'r', 'l', 'd']; + const iterable = getIterable(useIterator, values); + return reduceMethod(iterable, join, 'hello ').then(function(value) { + assert.strictEqual(value, expected); + }); + } + }, + + 'asynchronous values': { + 'reduce a single value without initial value; should not call callback': function(this: any) { + const expected: any = getExpectedSolution(this); + + const values = [createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = reduceMethod(iterable, throwImmediatly).then(function(value) { + assert.strictEqual(value, expected); + }); + + values[0].resolve('h'); + + return promise; + }, + + 'reduce multiple values': function(this: any) { + const expected: any = getExpectedSolution(this); + + const values = createTriggerablePromises(5); + const iterable = getIterable(useIterator, values); + const promise = reduceMethod(iterable, join).then(function(value) { + assert.strictEqual(value, expected); + }); + + values[0].resolve('h'); + values[1].resolve('e'); + values[2].resolve('l'); + values[3].resolve('l'); + values[4].resolve('o'); + + return promise; + }, + + 'reduce multiple values with initializer': function(this: any) { + const expected: any = getExpectedSolution(this); + + const values = createTriggerablePromises(5); + const iterable = getIterable(useIterator, values); + const promise = reduceMethod(iterable, join, 'hello ').then(function(value) { + assert.strictEqual(value, expected); + }); + + values[0].resolve('w'); + values[1].resolve('o'); + values[2].resolve('r'); + values[3].resolve('l'); + values[4].resolve('d'); + + return promise; + }, + + 'reduce multiple mixed values': function(this: any) { + const expected: any = getExpectedSolution(this); + + const values = ['h', 'e', 'l', 'l', createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = reduceMethod(iterable, join).then(function(value) { + assert.strictEqual(value, expected); + }); + + (>values[4]).resolve('o'); + + return promise; + }, + + 'one promised value is rejected': function() { + const values = createTriggerablePromises(1); + const iterable = getIterable(useIterator, values); + const promise = reduceMethod(iterable, join); + + values[0].reject(); + + return isEventuallyRejected(promise); + } + }, + + 'asynchronous callback': { + 'multiple asynchronous reductions': function(this: any) { + const { step, initialIndex, callbackValues } = getExpectedSolution(this); + const values: string[] = 'hello'.split(''); + const iterable = getIterable(useIterator, values); + const results = createTriggerablePromises(values.length); + let previousIndex = initialIndex; + const promise = reduceMethod(iterable, function( + previous: string, + value: string, + index: number, + array: string[] + ): Promise { + assert.strictEqual(value, values[index]); + assert.strictEqual(index, previousIndex + step); + previousIndex = index; + assert.deepEqual(values, array); + if (index !== initialIndex) { + return results[index - step].then(function(result) { + assert.strictEqual(previous, result); + return results[index]; + }); + } + return results[index]; + }); + + results.forEach(function(result, i) { + result.resolve(callbackValues[i]); + }); + + return promise; + }, + + 'one promised reduction is rejected': function() { + const values: string[] = 'hello'.split(''); + const iterable = getIterable(useIterator, values); + const promise = reduceMethod(iterable, function(): Promise { + throw new Error('expected'); + }); + + return isEventuallyRejected(promise); + } + } + }; + } + + const arrayLikeTests = getTests(false); + arrayLikeTests['synchronous values']['reduces a sparse array'] = function(this: any) { + const expected: any = getExpectedSolution(this); + + const values = Array(10); + values[1] = 'h'; + values[3] = 'e'; + values[5] = 'l'; + values[7] = 'l'; + values[9] = 'o'; + return reduceMethod(values, join).then(function(value) { + assert.strictEqual(value, expected); + }); + }; + arrayLikeTests['asynchronous values']['reduces a sparse array'] = function(this: any) { + const expected: any = getExpectedSolution(this); + + const values = Array(10); + values[1] = createTriggerablePromise(); + values[4] = 'e'; + values[5] = 'l'; + values[7] = 'l'; + values[8] = 'o'; + + const promise = reduceMethod(values, join).then(function(value) { + assert.strictEqual(value, expected); + }); + + values[1].resolve('h'); + + return promise; + }; + + return { + 'array-like value': arrayLikeTests, + 'iterator value': getTests(true) + }; +} + +function haltImmediatelyTests( + haltingMethod: (items: (any | Promise)[], callback: iteration.Filterer) => Promise, + solutions: any +): Tests { + function getParameters(test: any): any { + return solutions[test.parent.name][test.name]; + } + + function getTests(useIterator: boolean = false): any { + function testAsynchronousValues(this: any) { + const { results, assertion } = getParameters(this); + const values = createTriggerablePromises(results.length); + const iterable = getIterable(useIterator, values); + const promise = haltingMethod(iterable, helloWorldTest).then(assertion); + + values.forEach(function(value, index) { + value.resolve(results[index]); + }); + return promise; + } + + return { + 'synchronous values': { + 'one synchronous value': function(this: any) { + const { values, assertion } = getParameters(this); + const iterable = getIterable(useIterator, values); + return haltingMethod(iterable, helloWorldTest).then(assertion); + }, + + 'multiple synchronous values': function(this: any) { + const { values, assertion } = getParameters(this); + const iterable = getIterable(useIterator, values); + return haltingMethod(iterable, helloWorldTest).then(assertion); + }, + + 'multiple synchronous values with failure': function(this: any) { + const { values, assertion } = getParameters(this); + const iterable = getIterable(useIterator, values); + return haltingMethod(iterable, helloWorldTest).then(assertion); + } + }, + + 'asynchronous values': { + 'one asynchronous value': function(this: any) { + return testAsynchronousValues.call(this); + }, + + 'multiple asynchronous values': function(this: any) { + return testAsynchronousValues.call(this); + }, + + 'multiple asynchronous values with failure': function(this: any) { + return testAsynchronousValues.call(this); + }, + + 'mixed synchronous and asynchronous values': function(this: any) { + const { results, assertion } = getParameters(this); + const values: any[] = [results[0], createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = haltingMethod(iterable, helloWorldTest).then(assertion); + + values[1].resolve(results[1]); + return promise; + }, + + 'rejected promise value': function() { + const values: any[] = ['hello', createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = haltingMethod(iterable, helloWorldTest); + + values[1].reject(); + + return isEventuallyRejected(promise); + } + }, + + 'asynchronous callback': { + 'callback returns asynchronous results': function(this: any) { + const { resolution, assertion } = getParameters(this); + const values: any[] = ['unimportant', 'values']; + const iterable = getIterable(useIterator, values); + return haltingMethod(iterable, function() { + return Promise.resolve(resolution); + }).then(assertion); + }, + + 'callback returns asynchronous results with eventually rejected promise': function() { + const values: any[] = ['unimportant', 'values']; + const iterable = getIterable(useIterator, values); + const promise = haltingMethod(iterable, function() { + throw new Error('kablewie!'); + }); + + return isEventuallyRejected(promise); + } + } + }; + } + + return { + 'array-like value': getTests(false), + 'iterator value': getTests(true) + }; +} + +registerSuite('async/iteration', { + '.every()': (function() { + const tests: any = haltImmediatelyTests(iteration.every, { + 'synchronous values': { + 'one synchronous value': { values: ['hello'], assertion: assertTrue }, + 'multiple synchronous values': { values: ['hello', 'world'], assertion: assertTrue }, + 'multiple synchronous values with failure': { + values: ['hello', 'world', 'potato'], + assertion: assertFalse + } + }, + 'asynchronous values': { + 'one asynchronous value': { results: ['hello'], assertion: assertTrue }, + 'multiple asynchronous values': { results: ['hello', 'world'], assertion: assertTrue }, + 'multiple asynchronous values with failure': { + results: ['hello', 'world', 'potato'], + assertion: assertFalse + }, + 'mixed synchronous and asynchronous values': { results: ['hello', 'world'], assertion: assertTrue } + }, + 'asynchronous callback': { + 'callback returns asynchronous results': { resolution: true, assertion: assertTrue } + } + }); + const asyncArrayTests = tests['array-like value']['asynchronous callback']; + + asyncArrayTests[ + 'callback returns multiple asynchronous results with a failure and every exits immediately' + ] = function() { + const values: any[] = ['unimportant', 'values']; + const response: Promise[] = [createTriggerablePromise(), createTriggerablePromise()]; + const promise = iteration + .every(values, function(value: any, i: number) { + return response[i]; + }) + .then(assertFalse); + + (>response[1]).resolve(false); + + return promise; + }; + + return tests; + })(), + + '.filter()': (function() { + function getTests(useIterator: boolean = false): any { + return { + 'synchronous values': { + 'one passing value': function() { + const values = ['hello']; + const iterable = getIterable(useIterator, values); + return iteration.filter(iterable, helloWorldTest).then(function(results) { + assert.deepEqual(results, values); + }); + }, + + 'one failing value': function() { + const values = ['failing value']; + const iterable = getIterable(useIterator, values); + return iteration.filter(iterable, helloWorldTest).then(function(results) { + assert.deepEqual(results, []); + }); + }, + + 'mixed passing and failing values': function() { + const values = ['hello', 'failing value', 'world']; + const iterable = getIterable(useIterator, values); + return iteration.filter(iterable, helloWorldTest).then(function(results) { + assert.deepEqual(results, ['hello', 'world']); + }); + } + }, + + 'asynchronous values': { + 'one passing value': function() { + const values = [createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = iteration.filter(iterable, helloWorldTest).then(function(results) { + assert.deepEqual(results, ['hello']); + }); + + values[0].resolve('hello'); + + return promise; + }, + + 'one failing value': function() { + const values = [createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = iteration.filter(iterable, helloWorldTest).then(function(results) { + assert.deepEqual(results, []); + }); + + values[0].resolve('failing value'); + + return promise; + }, + + 'mixed passing and failing values': function() { + const values = [ + createTriggerablePromise(), + createTriggerablePromise(), + createTriggerablePromise() + ]; + const iterable = getIterable(useIterator, values); + const promise = iteration.filter(iterable, helloWorldTest).then(function(results) { + assert.deepEqual(results, ['hello', 'world']); + }); + + values[0].resolve('hello'); + values[2].resolve('world'); + values[1].resolve('failing value'); + + return promise; + }, + + 'rejected value': function() { + const values = [createTriggerablePromise()]; + const iterable = getIterable(useIterator, values); + const promise = iteration.filter(iterable, helloWorldTest); + + values[0].reject(new Error('kaboom!')); + + return isEventuallyRejected(promise); + } + }, + + 'asynchronous callback': { + 'one asynchronous result': function() { + const values = ['unimportant']; + const iterable = getIterable(useIterator, values); + return iteration + .filter(iterable, function() { + return Promise.resolve(true); + }) + .then(function(results) { + assert.deepEqual(results, values); + }); + }, + + 'asynchronous results with an eventually rejected promise': function() { + const values = ['unimportant']; + const iterable = getIterable(useIterator, values); + const promise = iteration.filter(iterable, function() { + throw new Error('kaboom!'); + }); + + return isEventuallyRejected(promise); + }, + + 'mixed matched/unmatched asynchronous results': function() { + const values = ['hello', 'world', 'non-matching']; + const iterable = getIterable(useIterator, values); + const pass = [ + createTriggerablePromise(), + createTriggerablePromise(), + createTriggerablePromise() + ]; + const promise = iteration + .filter(iterable, function(value, i) { + return pass[i] as Promise; + }) + .then(function(results) { + assert.deepEqual(results, ['hello', 'world']); + }); + + pass[0].resolve(true); + pass[1].resolve(true); + pass[2].resolve(false); + + return promise; + } + } + }; + } + + return { + 'array-like value': getTests(false), + 'iterator value': getTests(true) + }; + })(), + + '.find()': findTests(iteration.find, { + // solutions + 'synchronous values': { + 'no matching values; returns undefined': undefined, + 'one matching value': 'hello', + 'multiple matching values; only returns the first': 'hello' + }, + 'asynchronous values': { + 'no matching values; returns undefined': undefined, + 'one matching value': 'hello', + 'multiple matching values; only returns the first': 'hello', + 'mixed synchronous and asynchronous values': 'hello' + }, + 'asynchronous callback': { + 'one asynchronous result': 'value1' + } + }), + + '.findIndex()': findTests(iteration.findIndex, { + // solutions + 'synchronous values': { + 'no matching values; returns undefined': -1, + 'one matching value': 1, + 'multiple matching values; only returns the first': 1 + }, + 'asynchronous values': { + 'no matching values; returns undefined': -1, + 'one matching value': 1, + 'multiple matching values; only returns the first': 1, + 'mixed synchronous and asynchronous values': 1 + }, + 'asynchronous callback': { + 'one asynchronous result': 0 + } + }), + + '.map()': { + 'synchronous values': { + 'transform a single value': function() { + const values = [1]; + return iteration.map(values, doublerMapper).then(function(values) { + assert.deepEqual(values, [2]); + }); + }, + + 'transform multiple values': function() { + const values = [1, 2, 3]; + return iteration.map(values, doublerMapper).then(function(values) { + assert.deepEqual(values, [2, 4, 6]); + }); + } + }, + + 'asynchronous values': { + 'transform a single value': function() { + const values = [createTriggerablePromise()]; + const promise = iteration.map(values, doublerMapper).then(function(values) { + assert.deepEqual(values, [2]); + }); + + values[0].resolve(1); + + return promise; + }, + + 'transform multiple values': function() { + const values = [createTriggerablePromise(), createTriggerablePromise(), createTriggerablePromise()]; + const promise = iteration.map(values, doublerMapper).then(function(values) { + assert.deepEqual(values, [2, 4, 6]); + }); + + values[0].resolve(1); + values[1].resolve(2); + values[2].resolve(3); + + return promise; + }, + + 'transform multiple mixed values': function() { + const values: any[] = [createTriggerablePromise(), 2, createTriggerablePromise(), 4]; + const promise = iteration.map(values, doublerMapper).then(function(values) { + assert.deepEqual(values, [2, 4, 6, 8]); + }); + + values[0].resolve(1); + values[2].resolve(3); + + return promise; + }, + + 'one promised value is rejected': function() { + const values = [createTriggerablePromise()]; + const promise = iteration.map(values, doublerMapper); + + values[0].reject(); + + return isEventuallyRejected(promise); + } + }, + + 'asynchronous callback': { + 'one asynchronous mapping': function() { + const values = ['unused']; + const results = [createTriggerablePromise()]; + const promise = iteration + .map(values, function(value, i) { + return results[i]; + }) + .then(function(values) { + assert.deepEqual(values, [2]); + }); + + results[0].resolve(2); + + return promise; + }, + + 'multiple asynchronous mappings': function() { + const values = ['unused', 'unused', 'unused']; + const results = [createTriggerablePromise(), createTriggerablePromise(), createTriggerablePromise()]; + const promise = iteration + .map(values, function(value, i) { + return results[i]; + }) + .then(function(values) { + assert.deepEqual(values, [2, 4, 6]); + }); + + results[0].resolve(2); + results[1].resolve(4); + results[2].resolve(6); + + return promise; + }, + + 'one promised mapping is rejected': function() { + const values = ['unused']; + const results = [createTriggerablePromise()]; + const promise = iteration.map(values, function(value, i) { + return results[i]; + }); + + results[0].reject(); + + return isEventuallyRejected(promise); + } + } + }, + + '.reduce()': reduceTests(iteration.reduce, { + 'synchronous values': { + 'reduce a single value without an initial value; should not call callback': 'h', + 'reduce multiple values': 'hello', + 'reduce multiple values with initializer': 'hello world', + 'reduces a sparse array': 'hello' + }, + + 'asynchronous values': { + 'reduce a single value without initial value; should not call callback': 'h', + 'reduce multiple values': 'hello', + 'reduce multiple values with initializer': 'hello world', + 'reduce multiple mixed values': 'hello', + 'reduces a sparse array': 'hello' + }, + + 'asynchronous callback': { + 'multiple asynchronous reductions': { + step: 1, + initialIndex: 0, + callbackValues: ['h', 'he', 'hel', 'hell', 'hello'] + } + } + }), + + '.reduceRight()': reduceTests(iteration.reduceRight, { + 'synchronous values': { + 'reduce a single value without an initial value; should not call callback': 'h', + 'reduce multiple values': 'olleh', + 'reduce multiple values with initializer': 'hello dlrow', + 'reduces a sparse array': 'olleh' + }, + + 'asynchronous values': { + 'reduce a single value without initial value; should not call callback': 'h', + 'reduce multiple values': 'olleh', + 'reduce multiple values with initializer': 'hello dlrow', + 'reduce multiple mixed values': 'olleh', + 'reduces a sparse array': 'olleh' + }, + + 'asynchronous callback': { + 'multiple asynchronous reductions': { + step: -1, + initialIndex: 4, + callbackValues: ['olleh', 'olle', 'oll', 'ol', 'o'] + } + } + }), + + '.series()': { + 'no values returns an empty array': function() { + return iteration.series([], throwImmediatly).then(function(result) { + assert.deepEqual(result, []); + }); + }, + + 'synchronous values': function() { + const values = 'hello'.split(''); + const expected = values; + + const composite: number[] = []; + return iteration + .series(values, function(value, index, array) { + composite.push(index); + assert.deepEqual(array, expected); + return value; + }) + .then(function(results) { + assert.deepEqual(composite, [0, 1, 2, 3, 4]); + assert.deepEqual(results, values); + }); + }, + + 'asynchronous values': function() { + const values = createTriggerablePromises(5); + const expected = 'hello'.split(''); + + const composite: number[] = []; + const promise = iteration + .series(values, function(value, index, array) { + composite.push(index); + assert.deepEqual(array, expected); + return value; + }) + .then(function(results) { + assert.deepEqual(composite, [0, 1, 2, 3, 4]); + assert.deepEqual(results, expected); + }); + + values[1].resolve('e'); + values[3].resolve('l'); + values[2].resolve('l'); + values[0].resolve('h'); + values[4].resolve('o'); + + return promise; + }, + + 'asynchronous callback': function() { + const values = 'hello'.split(''); + const results = createTriggerablePromises(5); + const promise = iteration + .series(values, function(value, index, array) { + assert.strictEqual(value, array[index]); + return results[index].then(function() { + return index; + }); + }) + .then(function(results) { + assert.deepEqual(results, [0, 1, 2, 3, 4]); + }); + + results[1].resolve(); + results[3].resolve(); + results[0].resolve(); + results[2].resolve(); + results[4].resolve(); + + return promise; + } + }, + + '.some()': (function() { + const tests: any = haltImmediatelyTests(iteration.some, { + 'synchronous values': { + 'one synchronous value': { values: ['hello'], assertion: assertTrue }, + 'multiple synchronous values': { values: ['non-matching', 'world'], assertion: assertTrue }, + 'multiple synchronous values with failure': { + values: ['non-matching', 'non-matching'], + assertion: assertFalse + } + }, + 'asynchronous values': { + 'one asynchronous value': { results: ['hello'], assertion: assertTrue }, + 'multiple asynchronous values': { results: ['non-matching', 'world'], assertion: assertTrue }, + 'multiple asynchronous values with failure': { + results: ['non-matching', 'non-matching'], + assertion: assertFalse + }, + 'mixed synchronous and asynchronous values': { + results: ['non-matching', 'world'], + assertion: assertTrue + } + }, + 'asynchronous callback': { + 'callback returns asynchronous results': { resolution: true, assertion: assertTrue } + } + }); + const asyncArrayTests = tests['array-like value']['asynchronous callback']; + + asyncArrayTests[ + 'callback returns multiple asynchronous results with a match and every exits immediately' + ] = function(): Promise { + const values: any[] = ['unused', 'unused']; + const response: Promise[] = createTriggerablePromises(2); + const promise = iteration + .some(values, function(value: any, i: number) { + return response[i]; + }) + .then(assertTrue); + + (>response[0]).resolve(false); + (>response[1]).resolve(true); + + return promise; + }; + + return tests; + })() +}); diff --git a/src/lib/core/tests/unit/async/timing.ts b/src/lib/core/tests/unit/async/timing.ts new file mode 100644 index 0000000..8a4e7a7 --- /dev/null +++ b/src/lib/core/tests/unit/async/timing.ts @@ -0,0 +1,109 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import * as timing from '../../../src/async/timing'; +import { throwImmediatly } from '../../support/util'; +import { isEventuallyRejected } from '../../support/util'; +import Promise from '@dojo/shim/Promise'; + +registerSuite('async/timing', { + 'delay()': { + 'delay returning a value after the given timeout': function() { + return timing + .delay(251)(Date.now()) + .then(function(start: number) { + const diff: number = Date.now() - start; + assert.approximately(diff, 251, 100); + }); + }, + 'delay executing a function that returns a value after the given timeout': function() { + const now = Date.now(); + const getNow = function() { + return Date.now(); + }; + return timing + .delay(251)(getNow) + .then(function(finish: number) { + const diff: number = finish - now; + assert.approximately(diff, 251, 100); + }); + }, + 'delay executing a function that returns another promise after the given timeout': function() { + const now = Date.now(); + const getNow = function() { + return Promise.resolve(Date.now()); + }; + return timing + .delay(251)(getNow) + .then(function(finish: number) { + const diff: number = finish - now; + assert.approximately(diff, 251, 150); + }); + }, + 'delay should return undefined when the value is not passed in': function() { + return timing + .delay(251)() + .then(function(value) { + assert.isUndefined(value); + }); + }, + 'delay can be reusable': function() { + const start = Date.now(); + const delay = timing.delay(251); + const p1 = delay().then(function() { + assert.approximately(Date.now() - start, 251, 150); + }); + const p2 = delay('foo').then(function(value) { + assert.strictEqual(value, 'foo'); + assert.approximately(Date.now() - start, 251, 150); + }); + const p3 = delay(() => Promise.resolve('bar')).then(function(value) { + assert.strictEqual(value, 'bar'); + assert.approximately(Date.now() - start, 251, 150); + }); + return Promise.all([p1, p2, p3]); + } + }, + + 'timeout()': { + 'called before the timeout; resolves the promise': function() { + return Promise.resolve('unused').then(timing.timeout(100, new Error('Error'))); + }, + + 'called before the timeout; passes function; resolves the promise': function() { + return Promise.resolve((): string => 'unused').then(timing.timeout(100, new Error('Error'))); + }, + + 'called after the timeout; rejects the promise': function() { + return isEventuallyRejected( + timing + .delay(100)('unused') + .then(timing.timeout(1, new Error('expected'))) + ); + } + }, + + DelayedRejection: { + 'is eventually rejected': function() { + const start = Date.now(); + return new timing.DelayedRejection(101).then(throwImmediatly, function(reason) { + assert.isUndefined(reason); + assert.isAbove(Date.now(), start + 99); + return true; + }); + }, + + 'is eventually rejected with error': function() { + const start = Date.now(); + const expectedError = new Error('boom!'); + return new timing.DelayedRejection(101, expectedError).then(throwImmediatly, function(reason) { + assert.strictEqual(reason, expectedError); + assert.isAbove(Date.now(), start + 99); + return true; + }); + }, + + 'works with race': function() { + return Promise.race([timing.delay(1)('success!'), new timing.DelayedRejection(100)]); + } + } +}); diff --git a/src/lib/core/tests/unit/base64.ts b/src/lib/core/tests/unit/base64.ts new file mode 100644 index 0000000..ae9a645 --- /dev/null +++ b/src/lib/core/tests/unit/base64.ts @@ -0,0 +1,25 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import * as base64 from '../../src/base64'; + +registerSuite('support/base64', { + 'encode()': { + 'normal string'() { + assert.strictEqual(base64.encode('foo bar baz'), 'Zm9vIGJhciBiYXo=', 'should have encoded properly'); + }, + + 'utf8 string'() { + assert.strictEqual(base64.encode('💩😱🦄'), '8J+SqfCfmLHwn6aE', 'should have encoded properly'); + } + }, + + 'decode()': { + 'normal string'() { + assert.strictEqual(base64.decode('Zm9vIGJhciBiYXo='), 'foo bar baz', 'should have decoded properly'); + }, + + 'utf8 string'() { + assert.strictEqual(base64.decode('8J+SqfCfmLHwn6aE'), '💩😱🦄', 'should have decoded properly'); + } + } +}); diff --git a/src/lib/core/tests/unit/compare.ts b/src/lib/core/tests/unit/compare.ts new file mode 100644 index 0000000..e07430d --- /dev/null +++ b/src/lib/core/tests/unit/compare.ts @@ -0,0 +1,2135 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { createConstructRecord, CustomDiff, diff, patch } from '../../src/compare'; + +registerSuite('compare', { + diff: { + 'plain object': { + 'add property'() { + const patchRecords = diff( + { + foo: 'bar' + }, + {} + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'update property'() { + const patchRecords = diff( + { + foo: 'bar' + }, + { + foo: 'qat' + } + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'update' + } + ]); + }, + + 'delete property'() { + const patchRecords = diff( + {}, + { + foo: 'qat' + } + ); + + assert.deepEqual(patchRecords, [ + { + name: 'foo', + type: 'delete' + } + ]); + }, + + 'allowFunctionValues - equal'() { + const patchRecords = diff( + { + foo() {} + }, + { + foo() {} + }, + { allowFunctionValues: true } + ); + + assert.strictEqual(patchRecords.length, 0, 'should not see a difference'); + }, + + 'allowFunctionValues - add property'() { + function foo() {} + const patchRecords = diff( + { + foo + }, + {}, + { allowFunctionValues: true } + ); + + assert.deepEqual(patchRecords, [ + { + type: 'add', + name: 'foo', + descriptor: { + value: foo, + writable: true, + enumerable: true, + configurable: true + } + } + ]); + }, + + 'primative values'() { + const patchRecords = diff( + { + foo: undefined, + bar: null, + baz: '', + qat: 0, + qux: false + }, + {} + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: undefined, writable: true }, + name: 'foo', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: null, writable: true }, + name: 'bar', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: '', writable: true }, + name: 'baz', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: 0, writable: true }, + name: 'qat', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: false, writable: true }, + name: 'qux', + type: 'add' + } + ]); + }, + + 'deep add value'() { + const patchRecords = diff( + { + foo: { + bar: 'baz' + } + }, + {} + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: {}, writable: true }, + name: 'foo', + type: 'add', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: 'baz', writable: true }, + name: 'bar', + type: 'add' + } + ] + } + ]); + }, + + 'deep update value'() { + const patchRecords = diff( + { + foo: { + bar: 'baz' + } + }, + { + foo: { + bar: 1 + } + } + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: { bar: 1 }, writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: 'baz', writable: true }, + name: 'bar', + type: 'update' + } + ] + } + ]); + }, + + 'complex diff'() { + const patchRecords = diff( + { + foo: { + bar: 'qat' + }, + baz: { + qat: { + qux: true + } + }, + qat: 'foo' + }, + { + foo: { + bar: { + qat: true + }, + baz: undefined + }, + baz: 1, + qux: { + baz: 2 + } + } + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { + configurable: true, + enumerable: true, + value: { bar: { qat: true }, baz: undefined }, + writable: true + }, + name: 'foo', + type: 'update', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: 'qat', writable: true }, + name: 'bar', + type: 'update' + }, + { + name: 'baz', + type: 'delete' + } + ] + }, + { + descriptor: { configurable: true, enumerable: true, value: {}, writable: true }, + name: 'baz', + type: 'update', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: {}, writable: true }, + name: 'qat', + type: 'add', + valueRecords: [ + { + descriptor: { + configurable: true, + enumerable: true, + value: true, + writable: true + }, + name: 'qux', + type: 'add' + } + ] + } + ] + }, + { + descriptor: { configurable: true, enumerable: true, value: 'foo', writable: true }, + name: 'qat', + type: 'add' + }, + { + name: 'qux', + type: 'delete' + } + ]); + }, + + 'no differences'() { + const patchRecords = diff( + { + foo: 'bar' + }, + { + foo: 'bar' + } + ); + + assert.deepEqual(patchRecords, []); + }, + + 'deep no differences'() { + const patchRecords = diff( + { + foo: { bar: 1 } + }, + { + foo: { bar: 1 } + } + ); + + assert.deepEqual(patchRecords, []); + }, + + 'symbols are ignored'() { + const patchRecords = diff( + { + foo: 'bar', + [Symbol.iterator]() {} + }, + {} + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'non-enumerable properties are ignored'() { + const a = { + foo: 'bar' + }; + + Object.defineProperty(a, 'bar', { + value: 'baz', + writable: true, + enumerable: false, + configurable: true + }); + + const patchRecords = diff(a, {}); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'complex objects': { + 'b object differ is called'() { + let called = false; + const a = { + foo: /foo/ + }; + const customDiff = new CustomDiff((value: RegExp, name, parent) => { + called = true; + assert.instanceOf(value, RegExp, 'value should be a regualar expression'); + assert.strictEqual(name, 'foo', 'name should equal "foo"'); + assert.strictEqual(parent, a, 'correct parent should be passed'); + }); + const patchRecords = diff(a, { foo: customDiff }); + assert.isTrue(called, 'object differ should have been called'); + assert.deepEqual(patchRecords, [], 'should have found no differences'); + }, + + 'a object differ is called'() { + let called = false; + const b = { foo: /foo/ }; + const customDiff = new CustomDiff((value: RegExp, name, parent) => { + called = true; + assert.instanceOf(value, RegExp, 'value should be a regualar expression'); + assert.strictEqual(name, 'foo', 'name should equal "foo"'); + assert.strictEqual(parent, b, 'correct parent should be passed'); + }); + const a = { + foo: customDiff + }; + const patchRecords = diff(a, b); + assert.isTrue(called, 'object differ should have been called'); + assert.deepEqual(patchRecords, [], 'should have found no differences'); + }, + + difference() { + const a = { + foo: /foo/ + }; + const customDiff = new CustomDiff(() => { + return createConstructRecord(RegExp); + }); + const patchRecords = diff(a, { foo: customDiff }); + assert.deepEqual( + patchRecords, + [{ Ctor: RegExp, name: 'foo' }], + 'should have expected patch records' + ); + }, + + 'difference with arguments'() { + const a = { + foo: /foo/ + }; + const customDiff = new CustomDiff(() => { + return createConstructRecord(RegExp, ['/bar/']); + }); + const patchRecords = diff(a, { foo: customDiff }); + assert.deepEqual( + patchRecords, + [{ args: ['/bar/'], Ctor: RegExp, name: 'foo' }], + 'should have expected patch records' + ); + }, + + 'difference with descriptor'() { + const a = { + foo: /foo/ + }; + const customDiff = new CustomDiff(() => { + return createConstructRecord(RegExp, undefined, { writable: true }); + }); + const patchRecords = diff(a, { foo: customDiff }); + assert.deepEqual( + patchRecords, + [{ Ctor: RegExp, descriptor: { writable: true }, name: 'foo' }], + 'should have expected patch records' + ); + }, + + 'deleted property'() { + const customDiff = new CustomDiff(() => { + return createConstructRecord(RegExp); + }); + const patchRecords = diff({}, { foo: customDiff }); + assert.deepEqual( + patchRecords, + [{ name: 'foo', type: 'delete' }], + 'should have expected patch records' + ); + }, + + 'added property'() { + const customDiff = new CustomDiff(() => { + return createConstructRecord(RegExp); + }); + const patchRecords = diff({ foo: customDiff }, {}); + assert.deepEqual( + patchRecords, + [{ Ctor: RegExp, name: 'foo' }], + 'should have expected patch records' + ); + } + }, + + 'ignored properties': { + 'string property added'() { + const a = { + foo: 'bar', + bar: 1 + }; + + const patchRecords = diff(a, {}, { ignoreProperties: ['bar'] }); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'string property deleted'() { + const b = { + foo: 'bar', + bar: 1 + }; + + const patchRecords = diff({}, b, { ignoreProperties: ['bar'] }); + + assert.deepEqual(patchRecords, [ + { + name: 'foo', + type: 'delete' + } + ]); + }, + + 'regex property added'() { + const a = { + foo: 'bar', + _bar: 1 + }; + + const patchRecords = diff(a, {}, { ignoreProperties: [/^_/] }); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'regex property deleted'() { + const b = { + foo: 'bar', + _bar: 1 + }; + + const patchRecords = diff({}, b, { ignoreProperties: [/^_/] }); + + assert.deepEqual(patchRecords, [ + { + name: 'foo', + type: 'delete' + } + ]); + }, + + 'combined string - regex added'() { + const a = { + foo: 'bar', + bar: 'bar', + _bar: 1 + }; + + const patchRecords = diff(a, {}, { ignoreProperties: ['bar', /^_/] }); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'combined string - regex deleted'() { + const b = { + foo: 'bar', + bar: 'bar', + _bar: 1 + }; + + const patchRecords = diff({}, b, { ignoreProperties: ['bar', /^_/] }); + + assert.deepEqual(patchRecords, [ + { + name: 'foo', + type: 'delete' + } + ]); + }, + + 'function added'() { + const a = { + foo: 'bar', + _bar: 1 + }; + + const patchRecords = diff(a, {}, { ignoreProperties: (name) => /^_/.test(name) }); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'function deleted'() { + const b = { + foo: 'bar', + _bar: 1 + }; + + const patchRecords = diff({}, b, { ignoreProperties: (name) => /^_/.test(name) }); + + assert.deepEqual(patchRecords, [ + { + name: 'foo', + type: 'delete' + } + ]); + }, + + function() { + const propertyStack: string[] = []; + + const a = { + foo: 'bar', + bar: 1, + baz: false + }; + + const b = { + foo: 'bar', + bar: 1, + baz: false + }; + + const patchRecords = diff(a, b, { + ignoreProperties(name, first, second) { + propertyStack.push(name); + assert.strictEqual(first, a); + assert.strictEqual(second, b); + return false; + } + }); + + assert.deepEqual(patchRecords, [], 'should be no differences'); + assert.deepEqual(propertyStack, ['foo', 'bar', 'baz']); + }, + + 'function and ignored'() { + const propertyStack: string[] = []; + + const a = { + foo: 'bar', + bar: 1, + baz: false + }; + + const b = { + foo: 'bar', + bar: 1, + baz: false + }; + + const patchRecords = diff(a, b, { + ignoreProperties(name, first, second) { + propertyStack.push(name); + assert.strictEqual(first, a); + assert.strictEqual(second, b); + return true; + } + }); + + assert.deepEqual(patchRecords, [], 'should be no differences'); + assert.deepEqual(propertyStack, ['foo', 'bar', 'baz']); + } + }, + + 'ignored values': { + 'string property equal'() { + const a = { + foo: new Error('foo') + }; + + const b = { + foo: new Error('foo') + }; + + const patchRecords = diff(a, b, { ignorePropertyValues: ['foo'] }); + + assert.deepEqual(patchRecords, []); + }, + + 'string property added'() { + const foo = new Error('foo'); + const a = { + foo + }; + + const patchRecords = diff(a, {}, { ignorePropertyValues: ['foo'] }); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: foo, writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'string property deleted'() { + const b = { + foo: new Error('foo') + }; + + const patchRecords = diff({}, b, { ignorePropertyValues: ['foo'] }); + + assert.deepEqual(patchRecords, [ + { + name: 'foo', + type: 'delete' + } + ]); + }, + + 'regex property equal'() { + const a = { + foo: new Error('foo') + }; + + const b = { + foo: new Error('foo') + }; + + const patchRecords = diff(a, b, { ignorePropertyValues: [/^foo$/] }); + + assert.deepEqual(patchRecords, []); + }, + + 'regex property added'() { + const foo = new Error('foo'); + const a = { + foo + }; + + const patchRecords = diff(a, {}, { ignorePropertyValues: [/^foo$/] }); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: foo, writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'regex property deleted'() { + const b = { + foo: new Error('foo') + }; + + const patchRecords = diff({}, b, { ignorePropertyValues: [/^foo$/] }); + + assert.deepEqual(patchRecords, [ + { + name: 'foo', + type: 'delete' + } + ]); + }, + + 'combined property equal'() { + const a = { + foo: new Error('foo'), + bar: new Error('bar') + }; + + const b = { + foo: new Error('foo'), + bar: new Error('bar') + }; + + const patchRecords = diff(a, b, { ignorePropertyValues: ['bar', /^foo$/] }); + + assert.deepEqual(patchRecords, []); + }, + + 'combined property added'() { + const foo = new Error('foo'); + const bar = new Error('bar'); + const a = { + foo, + bar + }; + + const patchRecords = diff(a, {}, { ignorePropertyValues: ['bar', /^foo$/] }); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: foo, writable: true }, + name: 'foo', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: bar, writable: true }, + name: 'bar', + type: 'add' + } + ]); + }, + + 'combined property deleted'() { + const b = { + foo: new Error('foo'), + bar: new Error('bar') + }; + + const patchRecords = diff({}, b, { ignorePropertyValues: ['bar', /^foo$/] }); + + assert.deepEqual(patchRecords, [ + { + name: 'foo', + type: 'delete' + }, + { + name: 'bar', + type: 'delete' + } + ]); + }, + + 'function property equal'() { + const a = { + foo: new Error('foo') + }; + + const b = { + foo: new Error('foo') + }; + + const patchRecords = diff(a, b, { ignorePropertyValues: (name) => /^foo$/.test(name) }); + + assert.deepEqual(patchRecords, []); + }, + + 'function property added'() { + const foo = new Error('foo'); + const a = { + foo + }; + + const patchRecords = diff(a, {}, { ignorePropertyValues: (name) => /^foo$/.test(name) }); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: foo, writable: true }, + name: 'foo', + type: 'add' + } + ]); + }, + + 'function property deleted'() { + const b = { + foo: new Error('foo') + }; + + const patchRecords = diff({}, b, { ignorePropertyValues: (name) => /^foo$/.test(name) }); + + assert.deepEqual(patchRecords, [ + { + name: 'foo', + type: 'delete' + } + ]); + } + } + }, + + array: { + same() { + const patchRecords = diff([1, 2, 3], [1, 2, 3]); + + assert.deepEqual(patchRecords, []); + }, + + shorter() { + const patchRecords = diff([1, 2, 3], [1, 2, 3, 4, 5]); + + assert.deepEqual(patchRecords, [ + { + deleteCount: 2, + start: 3, + type: 'splice' + } + ]); + }, + + longer() { + const patchRecords = diff([1, 2, 3, 4, 5], [1, 2, 3]); + + assert.deepEqual(patchRecords, [ + { + add: [4, 5], + deleteCount: 0, + start: 3, + type: 'splice' + } + ]); + }, + + 'first element changed'() { + const patchRecords = diff([1, 2, 3], [false, 2, 3]); + + assert.deepEqual(patchRecords, [ + { + add: [1], + deleteCount: 1, + start: 0, + type: 'splice' + } + ]); + }, + + 'middle element changed'() { + const patchRecords = diff([1, 2, 3], [1, false, 3]); + + assert.deepEqual(patchRecords, [ + { + add: [2], + deleteCount: 1, + start: 1, + type: 'splice' + } + ]); + }, + + 'last element changed'() { + const patchRecords = diff([1, 2, 3], [1, 2, false]); + + assert.deepEqual(patchRecords, [ + { + add: [3], + deleteCount: 1, + start: 2, + type: 'splice' + } + ]); + }, + + 'tail changed plus shorter'() { + const patchRecords = diff([1, 2, 3], [1, 2, false, 4, 5]); + + assert.deepEqual(patchRecords, [ + { + add: [3], + deleteCount: 3, + start: 2, + type: 'splice' + } + ]); + }, + + 'tail changed plug longer'() { + const patchRecords = diff([1, 2, 3, 4, 5], [1, 2, false]); + + assert.deepEqual(patchRecords, [ + { + add: [3, 4, 5], + deleteCount: 1, + start: 2, + type: 'splice' + } + ]); + }, + + 'multiple changes'() { + const patchRecords = diff([1, 2, 3, 4, 5], [1, false, 3, 4, false, 6, 7]); + + assert.deepEqual(patchRecords, [ + { + add: [2], + deleteCount: 1, + start: 1, + type: 'splice' + }, + { + add: [5], + deleteCount: 3, + start: 4, + type: 'splice' + } + ]); + }, + + 'primative values array'() { + const patchRecords = diff(['', 0, false, undefined, null], []); + + assert.deepEqual(patchRecords, [ + { + add: ['', 0, false, undefined, null], + deleteCount: 0, + start: 0, + type: 'splice' + } + ]); + }, + + 'allowFunctionValues - equal'() { + const patchRecords = diff([function foo() {}], [() => undefined], { allowFunctionValues: true }); + + assert.lengthOf(patchRecords, 0, 'should have no differences'); + }, + + 'allowFunctionValues - add'() { + function foo() {} + const patchRecords = diff([foo], [], { allowFunctionValues: true }); + + assert.deepEqual(patchRecords, [ + { + add: [foo], + deleteCount: 0, + start: 0, + type: 'splice' + } + ]); + }, + + 'array of arrays'() { + const patchRecords = diff( + [[1, 2, 3], ['foo', 'bar', 'baz'], [true, false]], + [[1, false, 3], ['bar', 'baz']] + ); + + assert.deepEqual(patchRecords, [ + { + add: [ + [ + { + add: [2], + deleteCount: 1, + start: 1, + type: 'splice' + } + ], + [ + { + add: ['foo', 'bar', 'baz'], + deleteCount: 2, + start: 0, + type: 'splice' + } + ], + [ + { + add: [true, false], + deleteCount: 0, + start: 0, + type: 'splice' + } + ] + ], + deleteCount: 2, + start: 0, + type: 'splice' + } + ]); + }, + + 'deep no changes'() { + const patchRecords = diff( + [[1, 2, 3], ['foo', 'bar', 'baz'], [true, false]], + [[1, 2, 3], ['foo', 'bar', 'baz'], [true, false]] + ); + + assert.deepEqual(patchRecords, []); + } + }, + + 'mixed object/arrays': { + 'object with array'() { + const patchRecords = diff( + { + foo: [1, 2, 3] + }, + { + foo: [1, false, 3] + } + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: [1, false, 3], writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + add: [2], + deleteCount: 1, + start: 1, + type: 'splice' + } + ] + } + ]); + }, + + 'array with objects'() { + const patchRecords = diff( + [{ bar: 1 }, { foo: 'bar' }, { baz: 1, qat: false }, { qux: null }, {}], + [{ bar: 1 }, { foo: 'baz' }, { baz: 1 }, {}, { qux: null }] + ); + + assert.deepEqual(patchRecords, [ + { + add: [ + [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'update' + } + ], + [ + { + descriptor: { configurable: true, enumerable: true, value: false, writable: true }, + name: 'qat', + type: 'add' + } + ], + [ + { + descriptor: { configurable: true, enumerable: true, value: null, writable: true }, + name: 'qux', + type: 'add' + } + ], + [ + { + name: 'qux', + type: 'delete' + } + ] + ], + deleteCount: 4, + start: 1, + type: 'splice' + } + ]); + }, + + 'object array value to object value'() { + const patchRecords = diff( + { + foo: [1, 2, 3] + }, + { + foo: { bar: 1 } + } + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: [], writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + add: [1, 2, 3], + deleteCount: 0, + start: 0, + type: 'splice' + } + ] + } + ]); + }, + + 'object object value to array value'() { + const patchRecords = diff( + { + foo: { bar: 1 } + }, + { + foo: [1, 2, 3] + } + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: {}, writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: 1, writable: true }, + name: 'bar', + type: 'add' + } + ] + } + ]); + }, + + 'array array value to object value'() { + const patchRecords = diff( + [[1, 2, 3]], + [ + { + foo: 1 + } + ] + ); + + assert.deepEqual(patchRecords, [ + { + add: [ + [ + { + add: [1, 2, 3], + deleteCount: 0, + start: 0, + type: 'splice' + } + ] + ], + deleteCount: 1, + start: 0, + type: 'splice' + } + ]); + }, + + 'array object value to array value'() { + const patchRecords = diff( + [ + { + foo: 1 + } + ], + [[1, 2, 3]] + ); + + assert.deepEqual(patchRecords, [ + { + add: [ + [ + { + descriptor: { configurable: true, enumerable: true, value: 1, writable: true }, + name: 'foo', + type: 'add' + } + ] + ], + deleteCount: 1, + start: 0, + type: 'splice' + } + ]); + }, + + 'array to object'() { + const patchRecords = diff([1, 2, 3], { + foo: 'bar' + }); + + assert.deepEqual(patchRecords, [ + { + add: [1, 2, 3], + deleteCount: 0, + start: 0, + type: 'splice' + } + ]); + }, + + 'object to array'() { + const patchRecords = diff( + { + foo: 'bar' + }, + [1, 2, 3] + ); + + assert.deepEqual(patchRecords, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ]); + } + }, + + 'negative tests'() { + assert.throws( + () => { + diff({}, 'foo'); + }, + TypeError, + 'Arguments are not of type object.' + ); + + assert.throws( + () => { + diff('foo', {}); + }, + TypeError, + 'Arguments are not of type object.' + ); + + assert.throws( + () => { + diff( + { + foo: /bar/ + }, + {} + ); + }, + TypeError, + 'Value of property named "foo" from first argument is not a primative, plain Object, or Array.' + ); + + assert.throws( + () => { + diff([/foo/], []); + }, + TypeError, + 'Value of array element "0" from first argument is not a primative, plain Object, or Array.' + ); + + assert.doesNotThrow(() => { + diff([], [/foo/]); + }); + + class Foo { + bar = 'bar'; + } + + const foo = new Foo(); + + assert.throws( + () => { + diff(foo, {}); + }, + TypeError, + 'Arguments are not plain Objects or Arrays.' + ); + + assert.throws( + () => { + diff({}, foo); + }, + TypeError, + 'Arguments are not plain Objects or Arrays.' + ); + } + }, + + patch: { + 'plain object': { + 'add property'() { + const target = {}; + const result = patch(target, [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ]); + + assert.deepEqual(result, { + foo: 'bar' + }); + assert.strictEqual(result, target); + }, + + 'update property'() { + const result = patch( + { + foo: 'qat' + }, + [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'update' + } + ] + ); + + assert.deepEqual(result, { + foo: 'bar' + }); + }, + + 'delete property'() { + const result = patch( + { + foo: 'qat' + }, + [ + { + name: 'foo', + type: 'delete' + } + ] + ); + + assert.deepEqual(result, {}); + }, + + 'primative values'() { + const result = patch({}, [ + { + descriptor: { configurable: true, enumerable: true, value: undefined, writable: true }, + name: 'foo', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: null, writable: true }, + name: 'bar', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: '', writable: true }, + name: 'baz', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: 0, writable: true }, + name: 'qat', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: false, writable: true }, + name: 'qux', + type: 'add' + } + ]); + + assert.deepEqual(result, { + foo: undefined, + bar: null, + baz: '', + qat: 0, + qux: false + }); + }, + + 'deep add value'() { + const result = patch({}, [ + { + descriptor: { configurable: true, enumerable: true, value: {}, writable: true }, + name: 'foo', + type: 'add', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: 'baz', writable: true }, + name: 'bar', + type: 'add' + } + ] + } + ]); + + assert.deepEqual(result, { + foo: { + bar: 'baz' + } + }); + }, + + 'deep update value'() { + const target = { + foo: { + bar: 1 + } + }; + + const result = patch(target, [ + { + descriptor: { configurable: true, enumerable: true, value: target.foo, writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: 'baz', writable: true }, + name: 'bar', + type: 'update' + } + ] + } + ]); + + assert.deepEqual(result, { + foo: { + bar: 'baz' + } + }); + assert.strictEqual(result.foo, target.foo); + }, + + 'complex diff'() { + const target = { + foo: { + bar: { + qat: true + }, + baz: undefined + }, + baz: 1, + qux: { + baz: 2 + } + }; + + const result = patch(target, [ + { + descriptor: { configurable: true, enumerable: true, value: target.foo, writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: 'qat', writable: true }, + name: 'bar', + type: 'update' + }, + { + name: 'baz', + type: 'delete' + } + ] + }, + { + descriptor: { configurable: true, enumerable: true, value: {}, writable: true }, + name: 'baz', + type: 'update', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: {}, writable: true }, + name: 'qat', + type: 'add', + valueRecords: [ + { + descriptor: { + configurable: true, + enumerable: true, + value: true, + writable: true + }, + name: 'qux', + type: 'add' + } + ] + } + ] + }, + { + descriptor: { configurable: true, enumerable: true, value: 'foo', writable: true }, + name: 'qat', + type: 'add' + }, + { + name: 'qux', + type: 'delete' + } + ]); + + const expected = { + foo: { + bar: 'qat' + }, + baz: { + qat: { + qux: true + } + }, + qat: 'foo' + }; + + assert.deepEqual(result, expected, 'Result should match expected'); + assert.deepEqual(target, expected as any, 'Original target should match expected'); + assert.strictEqual(target, result, 'target and result should be strictly equal'); + }, + + 'empty patch'() { + const target = {}; + const result = patch(target, []); + + assert.deepEqual(result, {}); + assert.strictEqual(result, target); + } + }, + + array: { + same() { + const target = [1, 2, 3]; + const result = patch(target, []); + + assert.deepEqual(result, [1, 2, 3]); + assert.deepEqual(result, target); + assert.strictEqual(target, result); + }, + + shorter() { + const target = [1, 2, 3, 4, 5]; + const result = patch(target, [ + { + deleteCount: 2, + start: 3, + type: 'splice' + } + ]); + + assert.deepEqual(result, [1, 2, 3]); + assert.strictEqual(target, result); + }, + + longer() { + const target = [1, 2, 3]; + const result = patch(target, [ + { + add: [4, 5], + deleteCount: 0, + start: 3, + type: 'splice' + } + ]); + + assert.deepEqual(result, [1, 2, 3, 4, 5]); + assert.strictEqual(result, target); + }, + + 'first element changed'() { + const result = patch( + [false, 2, 3], + [ + { + add: [1], + deleteCount: 1, + start: 0, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [1, 2, 3]); + }, + + 'middle element changed'() { + const result = patch( + [1, false, 3], + [ + { + add: [2], + deleteCount: 1, + start: 1, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [1, 2, 3]); + }, + + 'last element changed'() { + const result = patch( + [1, 2, false], + [ + { + add: [3], + deleteCount: 1, + start: 2, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [1, 2, 3]); + }, + + 'tail changed plus shorter'() { + const result = patch( + [1, 2, false, 4, 5], + [ + { + add: [3], + deleteCount: 3, + start: 2, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [1, 2, 3]); + }, + + 'tail changed plug longer'() { + const result = patch( + [1, 2, false], + [ + { + add: [3, 4, 5], + deleteCount: 1, + start: 2, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [1, 2, 3, 4, 5]); + }, + + 'multiple changes'() { + const result = patch( + [1, false, 3, 4, false, 6, 7], + [ + { + add: [2], + deleteCount: 1, + start: 1, + type: 'splice' + }, + { + add: [5], + deleteCount: 3, + start: 4, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [1, 2, 3, 4, 5]); + }, + + 'primative values array'() { + const result = patch( + [], + [ + { + add: ['', 0, false, undefined, null], + deleteCount: 0, + start: 0, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, ['', 0, false, undefined, null]); + }, + + 'array of arrays'() { + const result = patch( + [[1, false, 3], ['bar', 'baz']], + [ + { + add: [ + [ + { + add: [2], + deleteCount: 1, + start: 1, + type: 'splice' + } + ], + [ + { + add: ['foo', 'bar', 'baz'], + deleteCount: 2, + start: 0, + type: 'splice' + } + ], + [ + { + add: [true, false], + deleteCount: 0, + start: 0, + type: 'splice' + } + ] + ], + deleteCount: 2, + start: 0, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [[1, 2, 3], ['foo', 'bar', 'baz'], [true, false]]); + } + }, + + 'mixed object/arrays': { + 'object with array'() { + const target = { + foo: [1, false, 3] + }; + + const result = patch(target, [ + { + descriptor: { configurable: true, enumerable: true, value: target.foo, writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + add: [2], + deleteCount: 1, + start: 1, + type: 'splice' + } + ] + } + ]); + + assert.deepEqual(result, { + foo: [1, 2, 3] + }); + assert.strictEqual(target, result); + assert.strictEqual(target.foo, result.foo); + }, + + 'array with objects'() { + const target = [{ bar: 1 }, { foo: 'baz' }, { baz: 1 }, {}, { qux: null }]; + + const result = patch(target, [ + { + add: [ + [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'update' + } + ], + [ + { + descriptor: { configurable: true, enumerable: true, value: false, writable: true }, + name: 'qat', + type: 'add' + } + ], + [ + { + descriptor: { configurable: true, enumerable: true, value: null, writable: true }, + name: 'qux', + type: 'add' + } + ], + [ + { + name: 'qux', + type: 'delete' + } + ] + ], + deleteCount: 4, + start: 1, + type: 'splice' + } + ]); + + assert.deepEqual(result, [{ bar: 1 }, { foo: 'bar' }, { baz: 1, qat: false }, { qux: null }, {}]); + assert.strictEqual(target, result); + target.forEach((item, index) => { + assert.strictEqual(item, result[index]); + }); + }, + + 'object array value to object value'() { + const result = patch( + { + foo: { bar: 1 } + }, + [ + { + descriptor: { configurable: true, enumerable: true, value: [], writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + add: [1, 2, 3], + deleteCount: 0, + start: 0, + type: 'splice' + } + ] + } + ] + ); + + assert.deepEqual(result, { + foo: [1, 2, 3] + }); + }, + + 'object object value to array value'() { + const result = patch( + { + foo: [1, 2, 3] + }, + [ + { + descriptor: { configurable: true, enumerable: true, value: {}, writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: 1, writable: true }, + name: 'bar', + type: 'add' + } + ] + } + ] + ); + + assert.deepEqual(result, { + foo: { bar: 1 } + }); + }, + + 'array array value to object value'() { + const result = patch( + [ + { + foo: 1 + } + ], + [ + { + add: [ + [ + { + add: [1, 2, 3], + deleteCount: 0, + start: 0, + type: 'splice' + } + ] + ], + deleteCount: 1, + start: 0, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [[1, 2, 3]]); + }, + + 'array object value to array value'() { + const result = patch( + [[1, 2, 3]], + [ + { + add: [ + [ + { + descriptor: { configurable: true, enumerable: true, value: 1, writable: true }, + name: 'foo', + type: 'add' + } + ] + ], + deleteCount: 1, + start: 0, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [ + { + foo: 1 + } + ]); + }, + + 'array to object'() { + const result = patch( + { + foo: 'bar' + }, + [ + { + add: [1, 2, 3], + deleteCount: 0, + start: 0, + type: 'splice' + } + ] + ); + + assert.deepEqual(result, [1, 2, 3]); + }, + + 'object to array'() { + const result = patch( + [1, 2, 3], + [ + { + descriptor: { configurable: true, enumerable: true, value: 'bar', writable: true }, + name: 'foo', + type: 'add' + } + ] + ); + + assert.deepEqual(result, { + foo: 'bar' + }); + } + }, + + 'plain object with construct records': { + 'basic property construct'() { + const result = patch({}, [{ args: ['foo'], Ctor: RegExp, name: 'foo' }]); + + assert.instanceOf(result.foo, RegExp, 'should be a regular expression'); + assert.strictEqual(result.foo.toString(), '/foo/', 'should have a pattern of foo'); + }, + + 'property construct with descriptor'() { + const result = patch({}, [ + { + args: ['foo'], + Ctor: RegExp, + name: 'foo', + descriptor: { writable: false, enumerable: false, configurable: false } + }, + { args: ['foo'], Ctor: RegExp, name: 'bar' } + ]); + + const descriptorFoo = Object.getOwnPropertyDescriptor(result, 'foo'); + const descriptorBar = Object.getOwnPropertyDescriptor(result, 'bar'); + assert.isFalse(descriptorFoo!.writable); + assert.isFalse(descriptorFoo!.enumerable); + assert.isFalse(descriptorFoo!.configurable); + assert.instanceOf(descriptorFoo!.value, RegExp); + assert.isTrue(descriptorBar!.writable); + assert.isTrue(descriptorBar!.enumerable); + assert.isTrue(descriptorBar!.configurable); + assert.instanceOf(descriptorBar!.value, RegExp); + }, + + 'with property records'() { + class Foo { + foo = 1; + bar = ''; + } + + const result = patch({}, [ + { + Ctor: Foo, + name: 'foo', + propertyRecords: [ + { + descriptor: { configurable: true, enumerable: true, value: 1, writable: true }, + name: 'foo', + type: 'add' + }, + { + descriptor: { configurable: true, enumerable: true, value: 'baz', writable: true }, + name: 'bar', + type: 'add' + } + ] + } + ]); + + assert.instanceOf(result.foo, Foo, 'should be instance of Foo'); + assert.strictEqual(result.foo.foo, 1, 'should have set property value'); + assert.strictEqual(result.foo.bar, 'baz', 'should have set property value'); + }, + + 'with construct property records'() { + class Foo { + foo?: Foo; + } + + const result = patch({}, [ + { + Ctor: Foo, + name: 'foo', + propertyRecords: [ + { + Ctor: Foo, + name: 'foo' + } + ] + } + ]); + + assert.instanceOf(result.foo, Foo); + assert.instanceOf(result.foo.foo, Foo); + }, + + 'plain object has complex property'() { + const result = patch( + { + foo: [] + }, + [ + { + descriptor: { configurable: true, enumerable: true, value: {}, writable: true }, + name: 'foo', + type: 'update', + valueRecords: [ + { + args: ['foo'], + Ctor: RegExp, + name: 'bar' + } + ] + } + ] + ); + + assert.instanceOf(result.foo.bar, RegExp); + assert.strictEqual(result.foo.bar.toString(), '/foo/'); + } + }, + + 'negative tests'() { + assert.throws( + () => { + patch(/foo/, []); + }, + TypeError, + 'A target for a patch must be either an array or a plain object.' + ); + + class Foo { + bar: 'bar' = 'bar'; + } + + assert.throws( + () => { + patch(new Foo(), []); + }, + TypeError, + 'A target for a patch must be either an array or a plain object.' + ); + + const foo = {}; + Object.freeze(foo); + + assert.throws( + () => { + patch(foo, []); + }, + TypeError, + 'Cannot patch sealed or frozen objects.' + ); + + const bar = {}; + Object.seal(bar); + + assert.throws( + () => { + patch(bar, []); + }, + TypeError, + 'Cannot patch sealed or frozen objects.' + ); + } + } +}); diff --git a/src/lib/core/tests/unit/global.ts b/src/lib/core/tests/unit/global.ts new file mode 100644 index 0000000..2e75715 --- /dev/null +++ b/src/lib/core/tests/unit/global.ts @@ -0,0 +1,10 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import global from '../../src/global'; +import shimGlobal from '@dojo/shim/global'; + +registerSuite('global', { + 'global is a re-export of @dojo/shim/global'() { + assert.strictEqual(global, shimGlobal, 'globals should match'); + } +}); diff --git a/src/lib/core/tests/unit/has.ts b/src/lib/core/tests/unit/has.ts new file mode 100644 index 0000000..2247e48 --- /dev/null +++ b/src/lib/core/tests/unit/has.ts @@ -0,0 +1,14 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import has from '../../src/has'; + +registerSuite('has', { + 'has("node-buffer")': function() { + const value = has('node-buffer'); + if (has('host-node')) { + assert.ok(value, 'Should be true running under node'); + } else { + assert.notOk(value, 'Should be false running under node'); + } + } +}); diff --git a/src/lib/core/tests/unit/instrument.ts b/src/lib/core/tests/unit/instrument.ts new file mode 100644 index 0000000..af03ce6 --- /dev/null +++ b/src/lib/core/tests/unit/instrument.ts @@ -0,0 +1,197 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { hasClassName } from '../support/util'; +import { spy, SinonSpy } from 'sinon'; +import { deprecated, deprecatedAdvice, deprecatedDecorator, setWarn } from '../../src/instrument'; + +let consoleWarnSpy: SinonSpy; + +registerSuite('instrument', { + beforeEach() { + consoleWarnSpy = spy(console, 'warn'); + }, + + afterEach() { + (console.warn).restore && (console.warn).restore(); + }, + + tests: { + 'deprecated()': { + 'no options'(this: any) { + deprecated(); + assert.isTrue(consoleWarnSpy.calledOnce); + assert.strictEqual(consoleWarnSpy.lastCall.args.length, 1); + assert.strictEqual( + consoleWarnSpy.lastCall.args[0], + 'DEPRECATED: This function will be removed in future versions.' + ); + }, + + 'message in options'(this: any) { + const message = 'foo'; + deprecated({ message }); + assert.isTrue(consoleWarnSpy.calledOnce); + assert.strictEqual(consoleWarnSpy.lastCall.args.length, 1); + assert.strictEqual(consoleWarnSpy.lastCall.args[0], `DEPRECATED: ${message}`); + }, + + 'name in options'(this: any) { + const name = 'foo'; + deprecated({ name }); + assert.isTrue(consoleWarnSpy.calledOnce); + assert.strictEqual(consoleWarnSpy.lastCall.args.length, 1); + assert.strictEqual( + consoleWarnSpy.lastCall.args[0], + `DEPRECATED: ${name}: This function will be removed in future versions.` + ); + }, + + 'url in options'(this: any) { + const url = 'foo'; + deprecated({ url }); + assert.isTrue(consoleWarnSpy.calledOnce); + assert.strictEqual(consoleWarnSpy.lastCall.args.length, 1); + assert.strictEqual( + consoleWarnSpy.lastCall.args[0], + `DEPRECATED: This function will be removed in future versions.\n\n See ${url} for more details.\n\n` + ); + }, + + 'warn in options'() { + const callStack: any[][] = []; + + function warn(...args: any[]): void { + callStack.push(args); + } + + deprecated({ warn }); + assert.isTrue(consoleWarnSpy.notCalled); + assert.strictEqual(callStack.length, 1); + assert.strictEqual(callStack[0].length, 1); + assert.strictEqual(callStack[0][0], 'DEPRECATED: This function will be removed in future versions.'); + } + }, + + 'deprecatedAdvice()': { + 'no options'(this: any) { + const advice = deprecatedAdvice(); + assert.isTrue(consoleWarnSpy.notCalled); + + const args: any[] = ['foo']; + const result = advice.apply(null, args); + assert.deepEqual(args, result); + assert.isTrue(consoleWarnSpy.calledOnce); + assert.strictEqual(consoleWarnSpy.lastCall.args.length, 1); + assert.strictEqual( + consoleWarnSpy.lastCall.args[0], + 'DEPRECATED: This function will be removed in future versions.' + ); + }, + + 'warn in options'() { + const callStack: any[][] = []; + + function warn(...args: any[]): void { + callStack.push(args); + } + + const advice = deprecatedAdvice({ warn }); + + const args: any[] = ['foo']; + const result = advice.apply(null, args); + assert.deepEqual(args, result); + assert.isTrue(consoleWarnSpy.notCalled); + assert.strictEqual(callStack.length, 1); + assert.strictEqual(callStack[0].length, 1); + assert.strictEqual(callStack[0][0], 'DEPRECATED: This function will be removed in future versions.'); + } + }, + + 'deprecatedDecorator()': { + 'no options'(this: any) { + const callStack: any[][] = []; + + class Foo { + @deprecatedDecorator() + method(...args: any[]) { + callStack.push(args); + } + } + + const foo = new Foo(); + assert.isTrue(consoleWarnSpy.notCalled); + foo.method('foo'); + assert.isTrue(consoleWarnSpy.calledOnce); + assert.strictEqual(consoleWarnSpy.lastCall.args.length, 1); + if (hasClassName()) { + assert.strictEqual( + consoleWarnSpy.lastCall.args[0], + 'DEPRECATED: Foo#method: This function will be removed in future versions.' + ); + } else { + assert.strictEqual( + consoleWarnSpy.lastCall.args[0], + 'DEPRECATED: method: This function will be removed in future versions.' + ); + } + assert.strictEqual(callStack[0].length, 1); + assert.strictEqual(callStack[0][0], 'foo'); + }, + + 'warn in options'() { + const callStack: any[][] = []; + + function warn(...args: any[]): void { + callStack.push(args); + } + + class Foo { + @deprecatedDecorator({ warn }) + method() {} + } + + const foo = new Foo(); + foo.method(); + assert.isTrue(consoleWarnSpy.notCalled); + assert.strictEqual(callStack.length, 1); + assert.strictEqual(callStack[0].length, 1); + if (hasClassName()) { + assert.strictEqual( + callStack[0][0], + 'DEPRECATED: Foo#method: This function will be removed in future versions.' + ); + } else { + assert.strictEqual( + callStack[0][0], + 'DEPRECATED: method: This function will be removed in future versions.' + ); + } + } + }, + + 'setWarn()'() { + const callStack: any[][] = []; + + function warn(...args: any[]): void { + callStack.push(args); + } + + setWarn(warn); + deprecated(); + assert.isTrue(consoleWarnSpy.notCalled); + assert.strictEqual(callStack.length, 1); + assert.strictEqual(callStack[0].length, 1); + assert.strictEqual(callStack[0][0], 'DEPRECATED: This function will be removed in future versions.'); + + setWarn(); + deprecated(); + assert.isTrue(consoleWarnSpy.calledOnce); + assert.strictEqual(callStack.length, 1); + assert.strictEqual(consoleWarnSpy.lastCall.args.length, 1); + assert.strictEqual( + consoleWarnSpy.lastCall.args[0], + 'DEPRECATED: This function will be removed in future versions.' + ); + } + } +}); diff --git a/src/lib/core/tests/unit/lang.ts b/src/lib/core/tests/unit/lang.ts new file mode 100644 index 0000000..131eedc --- /dev/null +++ b/src/lib/core/tests/unit/lang.ts @@ -0,0 +1,477 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import * as lang from '../../src/lang'; + +registerSuite('lang functions', { + '.assign()'() { + // this is a re-export from `@dojo/shim/object::assign` + assert.isFunction(lang.assign); + }, + + '.deepAssign()'() { + const source: { + a: number; + b: { + enumerable: boolean; + configurable: boolean; + writable: boolean; + value: number; + }; + c: { + d: number; + e: any[]; + }; + } = Object.create( + { a: 1 }, + { + b: { + enumerable: false, + configurable: true, + writable: true, + value: 2 + } + } + ); + + source.c = { + d: 3, + e: [4, [5], { f: 6 }] + }; + + const object: {} = Object.create(null); + const assignedObject: {} & typeof source = lang.deepAssign(object, source); + + assert.strictEqual(object, assignedObject, 'deepAssign should return the modified target object'); + assert.isUndefined(assignedObject.a, 'deepAssign should not copy inherited properties'); + assert.isUndefined(assignedObject.b, 'deepAssign should not copy non-enumerable properties'); + assert.strictEqual(assignedObject.c.d, 3); + assert.strictEqual(assignedObject.c.e.length, 3); + assert.notStrictEqual(assignedObject.c.e[1], source.c.e[1], 'deepAssign should perform a deep copy'); + assert.notStrictEqual(assignedObject.c.e[2], source.c.e[2], 'deepAssign should perform a deep copy'); + assert.notStrictEqual(assignedObject.c.e, source.c.e, 'deepAssign should perform a deep copy'); + }, + + '.deepAssign() merges nested object on to the target'() { + const target = { + apple: 0, + banana: { + weight: 52, + price: 100, + details: { + colour: 'brown', + texture: 'soft' + } + }, + cherry: 97 + }; + + const source = { + banana: { price: 200, details: { colour: 'yellow' } }, + durian: 100 + }; + + const assignedObject = lang.deepAssign(target, source); + assert.deepEqual(assignedObject, { + apple: 0, + banana: { weight: 52, price: 200, details: { colour: 'yellow', texture: 'soft' } }, + cherry: 97, + durian: 100 + }); + }, + + '.deepAssign() objects with circular references'() { + const target: any = { + nested: { + baz: 'foo', + qux: 'baz' + } + }; + + target.cyclical = target; + + const source: any = { + nested: { + foo: 'bar', + bar: 'baz', + baz: 'qux' + } + }; + source.cyclical = source; + + const assignedObject = lang.deepAssign(target, source); + assert.deepEqual(assignedObject.nested, { foo: 'bar', bar: 'baz', baz: 'qux', qux: 'baz' }); + }, + + '.deepAssign with a source with two properties holding the same reference'() { + const target: any = {}; + + const foo = { + foo: 'bar' + }; + + const source: any = { + bar: foo, + baz: foo, + qux: { + foo, + bar: { + foo + } + } + }; + + const assignedObject = lang.deepAssign(target, source); + assert.deepEqual(assignedObject, { + bar: { foo: 'bar' }, + baz: { foo: 'bar' }, + qux: { foo: { foo: 'bar' }, bar: { foo: { foo: 'bar' } } } + }); + }, + + '.mixin()'() { + const source: { + a: number; + c: number; + nested: { + a: number; + }; + b: number; + hidden: number; + } = Object.create({ + a: 1 + }); + source.c = 3; + source.nested = { a: 5 }; + Object.defineProperty(source, 'b', { + enumerable: true, + get: function() { + return 2; + } + }); + Object.defineProperty(source, 'hidden', { + enumerable: false, + value: 4 + }); + + const object: {} = Object.create(null); + const mixedObject = lang.mixin(object, source); + + assert.strictEqual(object, mixedObject, 'mixin should return the modified target object'); + assert.strictEqual(mixedObject.a, 1, 'mixin should copy inherited properties'); + assert.strictEqual(mixedObject.b, 2); + assert.strictEqual(mixedObject.c, 3); + assert.isUndefined(mixedObject.hidden, 'mixin should not copy non-enumerable properties'); + assert.strictEqual(mixedObject.nested, source.nested, 'mixin should perform a shallow copy'); + assert.strictEqual(mixedObject.nested.a, 5); + }, + + '.mixin() - multiple sources'() { + const source1 = { + a: 12, + b: false + }; + const source2 = { + c: 'string' + }; + const mixedObject = lang.mixin({}, source1, source2); + + assert.strictEqual(mixedObject.a, 12); + assert.strictEqual(mixedObject.b, false); + assert.strictEqual(mixedObject.c, 'string'); + }, + + '.deepMixin()'() { + const source: { + nested: { + a: number; + b: any[]; + }; + a: number; + b: number; + c: number; + d: Date; + e: RegExp; + hidden: number; + } = Object.create({ + nested: { + a: 1, + b: [2, [3], { f: 4 }] + } + }); + source.a = 1; + source.c = 3; + source.d = new Date(); + source.e = /abc/; + Object.defineProperty(source, 'b', { + enumerable: true, + get: function() { + return 2; + } + }); + Object.defineProperty(source, 'hidden', { + enumerable: false, + value: 4 + }); + + const object: {} = Object.create(null); + const mixedObject: {} & typeof source = lang.deepMixin(object, source); + + assert.strictEqual(object, mixedObject, 'deepMixin should return the modified target object'); + assert.strictEqual(mixedObject.a, 1); + assert.strictEqual(mixedObject.b, 2); + assert.strictEqual(mixedObject.c, 3); + assert.strictEqual(mixedObject.d, source.d, 'deepMixin should not deep copy Date object'); + assert.strictEqual(mixedObject.e, source.e, 'deepMixin should not deep copy RegExp object'); + assert.isUndefined(mixedObject.hidden, 'deepMixin should not copy non-enumerable properties'); + assert.strictEqual(mixedObject.nested.a, 1, 'deepMixin should copy inherited properties'); + assert.notStrictEqual(mixedObject.nested, source.nested, 'deepMixin should perform a deep copy'); + assert.notStrictEqual(mixedObject.nested.b, source.nested.b, 'deepMixin should perform a deep copy'); + assert.notStrictEqual(mixedObject.nested.b[1], source.nested.b[1], 'deepMixin should perform a deep copy'); + assert.notStrictEqual(mixedObject.nested.b[2], source.nested.b[2], 'deepMixin should perform a deep copy'); + }, + + '.deepMixin() merges nested object on to the target'() { + const target = Object.create({ + apple: 0, + banana: { + weight: 52, + price: 100, + details: { + colour: 'brown', + texture: 'soft' + } + }, + cherry: 97 + }); + + const source = Object.create({ + banana: { price: 200, details: { colour: 'yellow' } }, + durian: 100 + }); + + const assignedObject = lang.deepMixin(target, source); + assert.deepEqual(assignedObject, { + apple: 0, + banana: { weight: 52, price: 200, details: { colour: 'yellow', texture: 'soft' } }, + cherry: 97, + durian: 100 + }); + }, + + '.deepMixin() objects with circular references'() { + let target: any = { + nested: { + baz: 'foo', + qux: 'baz' + } + }; + + target.cyclical = target; + + target = Object.create(target); + + let source: any = { + nested: { + foo: 'bar', + bar: 'baz', + baz: 'qux' + } + }; + source.cyclical = source; + source = Object.create(source); + + const assignedObject = lang.deepMixin(target, source); + assert.deepEqual(assignedObject.nested, { foo: 'bar', bar: 'baz', baz: 'qux', qux: 'baz' }); + }, + + '.create()'() { + const prototype = { + a: 1 + }; + const mixin: { + lorem: string; + b: { + enumerable: boolean; + configurable: boolean; + writable: boolean; + value: { + c: number; + }; + }; + d: { + enumerable: boolean; + configurable: boolean; + writable: boolean; + value: number; + }; + e: { + value: number; + }; + } = Object.create( + { lorem: 'ipsum' }, + { + b: { + enumerable: true, + configurable: true, + writable: true, + value: { c: 2 } + }, + d: { + enumerable: true, + configurable: true, + writable: false, + value: 3 + }, + e: { + value: 4 + } + } + ); + const object: typeof prototype & typeof mixin = lang.create(prototype, mixin); + + assert.strictEqual(Object.getPrototypeOf(object), prototype); + assert.strictEqual(object.b, mixin.b); + assert.isTrue(Object.getOwnPropertyDescriptor(object, 'd')!.writable); + assert.isUndefined(object.e); + assert.isUndefined(object.lorem); + assert.throw(function() { + lang.create({}); + }); + }, + + '.duplicate()'() { + const prototype = { + a: 1 + }; + const source: { + a: number; + b: { + value: number; + }; + c: { + d: number; + }; + } = Object.create(prototype, { + b: { value: 2 } + }); + source.c = { d: 4 }; + + const copyOfObject: typeof source = lang.duplicate(source); + + assert.strictEqual(Object.getPrototypeOf(copyOfObject), prototype); + assert.strictEqual(copyOfObject.a, 1); + assert.isUndefined(copyOfObject.b); + assert.strictEqual(copyOfObject.c.d, 4); + assert.notStrictEqual(copyOfObject.c, source.c); + }, + + '.isIdentical()'() { + assert.isTrue(lang.isIdentical(2, 2)); + assert.isTrue(lang.isIdentical(NaN, NaN)); + assert.isFalse(lang.isIdentical(3, NaN)); + assert.isFalse(lang.isIdentical(3, '3')); + assert.isTrue(lang.isIdentical(Infinity, Infinity)); + }, + + '.lateBind() context'() { + const object: { + method?: (...args: string[]) => string; + } = {}; + const method = lang.lateBind(object, 'method'); + object.method = function(this: any): any { + return this; + }; + + assert.strictEqual(method(), object, "lateBind's context should be `object`."); + }, + + '.lateBind() arguments'() { + const object: { + method?: (...args: string[]) => string; + } = {}; + const method = lang.lateBind(object, 'method', 'The', 'quick', 'brown'); + const methodNoArgs = lang.lateBind(object, 'method'); + const suffix = 'fox jumped over the lazy dog'; + object.method = function(...parts: string[]): string { + return parts.join(' '); + }; + + assert.strictEqual( + method(suffix), + 'The quick brown ' + suffix, + "lateBind's additional arguments should be prepended to the wrapped function." + ); + assert.strictEqual( + methodNoArgs(suffix), + suffix, + "lateBind's additional arguments should be prepended to the wrapped function." + ); + assert.strictEqual( + method(), + 'The quick brown', + "lateBind's additional arguments should be prepended to the wrapped function." + ); + }, + + '.partial()'() { + const ending = 'jumps over the lazy dog'; + const finish = lang.partial( + function(this: any) { + const start = this && this.start ? [this.start] : []; + + return start.concat(Array.prototype.slice.call(arguments)).join(' '); + }, + 'jumps', + 'over' + ); + + function Sentence(this: any, start: string = '') { + this.start = start; + } + Sentence.prototype.finish = finish; + + assert.strictEqual( + finish('the lazy dog'), + ending, + 'The arguments supplied to `lang.partial` should be prepended to the arguments list of the ' + + 'original function.' + ); + assert.strictEqual( + finish(), + 'jumps over', + 'The arguments supplied to `lang.partial` should still be used even if no arguments are passed to the ' + + 'wrapped function.' + ); + assert.strictEqual( + new (Sentence)('The quick brown fox').finish('the lazy dog'), + 'The quick brown fox ' + ending, + 'A function passed to `lang.partial` should inherit its context.' + ); + }, + + '.createHandle'() { + let count = 0; + const handle = lang.createHandle(function(): void { + ++count; + }); + + handle.destroy(); + assert.strictEqual(count, 1); + + handle.destroy(); + assert.strictEqual(count, 1, 'destroy should be a no-op on subsequent calls'); + }, + + '.createCompositeHandle'() { + let count = 0; + function destructor(): void { + ++count; + } + const handle = lang.createCompositeHandle(lang.createHandle(destructor), lang.createHandle(destructor)); + + handle.destroy(); + assert.strictEqual(count, 2, 'both destructors in the composite handle should have been called'); + handle.destroy(); + assert.strictEqual(count, 2, 'destructors are not called after handle destruction'); + } +}); diff --git a/src/lib/core/tests/unit/load.ts b/src/lib/core/tests/unit/load.ts new file mode 100644 index 0000000..98b400c --- /dev/null +++ b/src/lib/core/tests/unit/load.ts @@ -0,0 +1,232 @@ +import Promise from '@dojo/shim/Promise'; +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { ObjectSuiteDescriptor } from 'intern/lib/interfaces/object'; +import * as sinon from 'sinon'; +import has from '../../src/has'; +import load, { isPlugin, useDefault } from '../../src/load'; +import { AmdRootRequire } from '../../src/interfaces'; +import { isPlugin as utilIsPlugin, useDefault as utilUseDefault } from '../../src/load/util'; +import mockPlugin from '../support/load/plugin-default'; + +declare const require: AmdRootRequire; + +const suite: ObjectSuiteDescriptor = { + before() { + return load(require, '../support/load/a', '../support/load/b', '../support/load/c') as Promise; + }, + + tests: { + api() { + assert.strictEqual(isPlugin, utilIsPlugin, 'isPlugin should be re-exported'); + assert.strictEqual(useDefault, utilUseDefault, 'useDefault should be re-exported'); + }, + + 'global load'(this: any) { + const def = this.async(5000); + + load('@dojo/shim/Promise').then( + def.callback(function([promiseModule]: [any, any]) { + assert.strictEqual(promiseModule.default, Promise); + }) + ); + }, + + 'contextual load'(this: any) { + const def = this.async(5000); + + load(require, '../support/load/a', '../support/load/b').then( + def.callback(function([a, b]: [any, any]) { + assert.deepEqual(a, { default: 'A', one: 1, two: 2 }); + assert.deepEqual(b, { default: 'B', three: 3, four: 4 }); + }) + ); + }, + + 'contextual load - all es 6 modules'() { + return load(require, '../support/load/a', '../support/load/b') + .then(useDefault) + .then(([a, b]: any[]) => { + assert.deepEqual(a, 'A'); + assert.deepEqual(b, 'B'); + }); + }, + + 'contextual load - single es 6 module'() { + return load(require, '../support/load/a', '../support/load/b') + .then(([a, b]) => [useDefault(a), b]) + .then(([a, b]: any[]) => { + assert.deepEqual(a, 'A'); + assert.deepEqual(b, { default: 'B', three: 3, four: 4 }); + }); + }, + + 'load plugin': { + 'without a resource id'(this: any) { + const dfd = this.async(5000); + + load(require, '../support/load/plugin').then( + dfd.callback(([plugin]: [any]) => { + assert.isFunction(plugin.load, 'No special behavior without a resource id.'); + }) + ); + }, + + 'with a resource id'(this: any) { + const dfd = this.async(5000); + const resourceId = require.toUrl + ? require.toUrl('@dojo/shim/Promise') + : (require as any).resolve('@dojo/shim/Promise'); + + load(require, '../support/load/plugin!@dojo/shim/Promise').then( + dfd.callback(([value]: [any]) => { + assert.strictEqual( + value, + resourceId, + 'The plugin `load` should receive the resolved resource id.' + ); + }) + ); + }, + + 'non-plugin with resource id'(this: any) { + const dfd = this.async(5000); + + load(require, '../support/load/a!some/resource').then( + dfd.callback(([a]: [any]) => { + assert.deepEqual(a, { one: 1, two: 2, default: 'A' }, 'The resource id should be ignored.'); + }) + ); + }, + + 'default export used'(this: any) { + const dfd = this.async(5000); + sinon.spy(mockPlugin, 'load'); + + load(require, '../support/load/plugin-default!some/resource').then( + dfd.callback(([value]: [any]) => { + assert.isTrue( + (mockPlugin.load).calledWith('some/resource', load), + 'Plugin `load` called with resource id and core `load`.' + ); + assert.strictEqual(value, 'some/resource', 'The `load` on the default export should be used.'); + + (mockPlugin.load).restore(); + }), + dfd.rejectOnError(() => { + (mockPlugin.load).restore(); + }) + ); + }, + + 'normalize method'(this: any) { + const dfd = this.async(5000); + sinon.spy(mockPlugin, 'normalize'); + + load(require, '../support/load/plugin-default!normalize').then( + dfd.callback(([value]: [any]) => { + assert.strictEqual( + value, + 'path/to/normalized', + 'The path should be passed to the `normalize` method.' + ); + assert.isTrue( + (mockPlugin.normalize).calledWith('normalize'), + '`normalize` called with resource id.' + ); + assert.isFunction( + (mockPlugin.normalize).firstCall.args[1], + '`normalize` called with resolver function.' + ); + + (mockPlugin.normalize).restore(); + }), + dfd.rejectOnError(() => { + (mockPlugin.normalize).restore(); + }) + ); + } + }, + + 'error handling'() { + return load('some/bogus/nonexistent/thing').then( + () => { + throw new Error('Should not resolve.'); + }, + (error: Error) => { + assert(error); + assert.isTrue( + error.message.indexOf('some/bogus/nonexistent/thing') > -1, + 'The error message should contain the module id.' + ); + } + ); + } + } +}; + +if (has('host-node')) { + const nodeRequire: any = (require).nodeRequire || require; + const path: any = nodeRequire('path'); + const buildDir: string = path.join(process.cwd(), '_build'); + + suite.tests.node = { + 'global load succeeds'(this: any) { + const def = this.async(5000); + + const result: () => Promise = nodeRequire(path.join(buildDir, 'tests', 'support', 'load', 'node')) + .globalSucceed; + result().then( + def.callback(function([fs, path]: [any, any]) { + assert.strictEqual(fs, nodeRequire('fs')); + assert.strictEqual(path, nodeRequire('path')); + }) + ); + }, + + 'global load with relative path fails'(this: any) { + const def = this.async(5000); + + const result: () => Promise = nodeRequire(path.join(buildDir, 'tests', 'support', 'load', 'node')) + .globalFail; + result().then( + function() { + def.reject(new Error('load should not have succeeded')); + }, + def.callback(function(error: Error) { + assert.instanceOf(error, Error); + }) + ); + }, + + 'contextual load succeeds'(this: any) { + const def = this.async(5000); + + const result: () => Promise = nodeRequire(path.join(buildDir, 'tests', 'support', 'load', 'node')) + .succeed; + result().then( + def.callback(function([a, b]: [any, any]) { + assert.deepEqual(a, { default: 'A', one: 1, two: 2 }); + assert.deepEqual(b, { default: 'B', three: 3, four: 4 }); + }) + ); + }, + + 'contextual load with non-existent module fails'(this: any) { + const def = this.async(5000); + + const result: () => Promise = nodeRequire(path.join(buildDir, 'tests', 'support', 'load', 'node')) + .fail; + result().then( + function() { + def.reject(new Error('load should not have succeeded')); + }, + def.callback(function(error: Error) { + assert.instanceOf(error, Error); + }) + ); + } + }; +} + +registerSuite('load', suite); diff --git a/src/lib/core/tests/unit/load/util.ts b/src/lib/core/tests/unit/load/util.ts new file mode 100644 index 0000000..03821b5 --- /dev/null +++ b/src/lib/core/tests/unit/load/util.ts @@ -0,0 +1,76 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { Tests } from 'intern/lib/interfaces/object'; +import has from '../../../src/has'; +import { isPlugin, useDefault } from '../../../src/load/util'; + +const suite: Tests = { + isPlugin() { + assert.isFalse(isPlugin(null)); + assert.isFalse(isPlugin(2)); + assert.isFalse(isPlugin([])); + assert.isFalse(isPlugin(/\s/)); + assert.isFalse(isPlugin({})); + assert.isTrue( + isPlugin({ + load() {} + }) + ); + }, + + useDefault: { + 'single es6 module'() { + assert.strictEqual( + useDefault({ + __esModule: true, + default: 42 + }), + 42, + 'The default export should be returned.' + ); + }, + + 'single non-es6 module'() { + const module = { value: 42 }; + assert.deepEqual(useDefault(module), module, 'The module itself should be returned.'); + }, + + 'all es6 modules'() { + const modules = [42, 43].map((value: number) => { + return { __esModule: true, default: value }; + }); + assert.sameMembers(useDefault(modules), [42, 43], 'The default export should be returned for all modules.'); + }, + + 'mixed module types'() { + const modules: any[] = [42, 43].map((value: number) => { + return { __esModule: true, default: value }; + }); + modules.push({ value: 44 }); + assert.sameDeepMembers(useDefault(modules), [42, 43, { value: 44 }]); + } + } +}; + +if (has('host-node')) { + const nodeRequire: any = (require).nodeRequire || require; + const path: any = nodeRequire('path'); + const buildDir: string = path.join(process.cwd(), '_build'); + + suite.node = { + 'useDefault resolves es modules'(this: any) { + const def = this.async(5000); + + const result: () => Promise = nodeRequire(path.join(buildDir, 'tests', 'support', 'load', 'node')) + .succeedDefault; + result().then( + def.callback(function([a, b]: [any, any]) { + assert.deepEqual(a, 'A'); + assert.deepEqual(b, 'B'); + }) + ); + } + }; +} + +registerSuite('load/util', suite); diff --git a/src/lib/core/tests/unit/load/webpack.ts b/src/lib/core/tests/unit/load/webpack.ts new file mode 100644 index 0000000..d40b57c --- /dev/null +++ b/src/lib/core/tests/unit/load/webpack.ts @@ -0,0 +1,250 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import * as sinon from 'sinon'; +import global from '@dojo/shim/global'; +import { isPlugin as utilIsPlugin, useDefault as utilUseDefault } from '../../../src/load/util'; +import load, { isPlugin, useDefault } from '../../../src/load/webpack'; + +interface WebpackModules { + [id: number]: any; +} + +let webpackModules: WebpackModules; +function setModules(modules?: { [mid: string]: any }) { + let nextId = 0; + webpackModules = Object.create(null) as WebpackModules; + + if (modules) { + const idMap = Object.create(null); + Object.keys(modules).forEach((mid: string) => { + const id = nextId++; + idMap[mid] = { id, lazy: mid.indexOf('bundle!') > -1 }; + webpackModules[id] = modules[mid]; + }); + global.__modules__ = idMap; + } else { + global.__modules__ = null; + } +} + +registerSuite('load/webpack', { + before() { + global.__webpack_require__ = function(id: number): any { + return webpackModules[id]; + }; + }, + + after() { + delete global.__webpack_require__; + }, + + beforeEach() { + setModules({ + '/path/to/first': { + foo: 'foo' + }, + '/path/to/second': { + foo: 'bar' + }, + '/path/bar': { + bar: 'baz' + }, + '/other': { + value: 'The quick brown fox jumped over the lazy dog.' + }, + 'bundle!lazy'(callback: (value: any) => any) { + callback({ value: 'lazy loaded' }); + }, + 'plugin!normalize': { + normalize: sinon.stub().returns('normalized/path/to/resource'), + load: sinon.spy() + }, + 'plugin!resource/id': { + load: sinon.spy() + }, + 'plugin!./resource/id': { + load: sinon.spy() + }, + 'parent/plugin!./resource/id': { + load: sinon.spy() + } + }); + }, + + afterEach() { + setModules(); + }, + + tests: { + api() { + assert.strictEqual(isPlugin, utilIsPlugin, '`isPlugin` should be re-exported.'); + assert.strictEqual(useDefault, utilUseDefault, '`useDefault` should be re-exported.'); + }, + + 'without __modules__'() { + setModules(); + return load('non-existent/module').then( + () => { + throw new Error('Should not resolve.'); + }, + (error: Error) => { + assert.instanceOf(error, Error); + assert.strictEqual(error.message, 'Missing module: non-existent/module'); + } + ); + }, + + 'contextual require': { + 'absolute path'() { + return load(() => '/path/to/first', '/path/to/second').then( + (results: any[]) => { + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].foo, 'bar'); + }, + (error: Error) => { + throw new Error(`Promise should not reject\n${error.message}`); + } + ); + }, + + 'relative path (same directory)'() { + return load(() => '/path/to/first', './second').then( + (results: any[]) => { + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].foo, 'bar'); + }, + (error: Error) => { + throw new Error(`Promise should not reject\n${error.message}`); + } + ); + }, + + 'relative path (up one directory)'() { + return load(() => '/path/to/first', '../bar').then((results: any[]) => { + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].bar, 'baz'); + }); + }, + + 'relative path (up two directories)'() { + return load(() => '/path/to/nested/module', '../../bar').then((results: any[]) => { + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].bar, 'baz'); + }); + }, + + 'relative path (beyond root directory)'() { + assert.throws( + () => { + load(() => '/path/to/first', '../../../../../../other'); + }, + Error, + 'Path cannot go beyond root directory.' + ); + } + }, + + 'normal require': { + 'absolute path'() { + return load('/path/to/second').then( + (results: any[]) => { + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].foo, 'bar'); + }, + (error: Error) => { + throw new Error(`Promise should not reject\n${error.message}`); + } + ); + }, + + 'relative path'() { + return load('./path/to/second').then( + (results: any[]) => { + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].foo, 'bar'); + }, + (error: Error) => { + throw new Error(`Promise should not reject\n${error.message}`); + } + ); + } + }, + + 'bundle loader modules'() { + return load('bundle!lazy').then( + (results: any[]) => { + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].value, 'lazy loaded'); + }, + (error: Error) => { + throw new Error(`Promise should not reject\n${error.message}`); + } + ); + }, + + 'plugin modules': { + 'with normalize method'() { + const mid = 'plugin!normalize'; + return load(mid).then( + () => { + const module = webpackModules[global.__modules__[mid].id]; + assert.isTrue(module.normalize.calledWith('normalize')); + assert.strictEqual( + module.normalize.args[0][1]('normalize'), + 'normalize', + '`normalize` should be passed an identity resolver.' + ); + assert.isTrue(module.load.calledWith('normalized/path/to/resource', load)); + }, + (error: Error) => { + throw new Error(`Promise should not reject\n${error.message}`); + } + ); + }, + + 'without normalize method': { + 'with a context method'() { + const mid = 'plugin!./resource/id'; + const context = () => 'parent/sibling'; + return load(context, mid).then( + () => { + const module = webpackModules[global.__modules__[mid].id]; + assert.isTrue(module.load.calledWith('parent/resource/id')); + }, + (error: Error) => { + throw new Error(`Promise should not reject\n${error.message}`); + } + ); + }, + + 'without a context method': { + 'with a relative ID'() { + const mid = 'plugin!./resource/id'; + return load(mid).then( + () => { + const module = webpackModules[global.__modules__[mid].id]; + assert.isTrue(module.load.calledWith('/resource/id')); + }, + (error: Error) => { + throw new Error(`Promise should not reject\n${error.message}`); + } + ); + }, + + 'without a relative ID'() { + const mid = 'plugin!resource/id'; + return load(mid).then( + () => { + const module = webpackModules[global.__modules__[mid].id]; + assert.isTrue(module.load.calledWith('resource/id')); + }, + (error: Error) => { + throw new Error(`Promise should not reject\n${error.message}`); + } + ); + } + } + } + } + } +}); diff --git a/src/lib/core/tests/unit/main.ts b/src/lib/core/tests/unit/main.ts new file mode 100644 index 0000000..cd6742d --- /dev/null +++ b/src/lib/core/tests/unit/main.ts @@ -0,0 +1,9 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import * as main from '../../src/main'; + +registerSuite('main', { + 'validate API'() { + assert.isObject(main.aspect); + } +}); diff --git a/src/lib/core/tests/unit/on/all.ts b/src/lib/core/tests/unit/on/all.ts new file mode 100644 index 0000000..dc77aef --- /dev/null +++ b/src/lib/core/tests/unit/on/all.ts @@ -0,0 +1,31 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); + +import common from './common'; +import on, { emit } from '../../../src/on'; +import Evented from '../../../src/Evented'; + +registerSuite('events - Evented', { + 'cannot target non-emitter': function() { + assert.throws(function() { + on({}, 'test', function() {}); + }); + }, + + 'common cases': common({ + eventName: 'test', + createTarget: function() { + return new Evented(); + } + }), + + 'emit return value'() { + const target = new Evented(); + assert.isFalse(emit(target, { type: 'test' })); + + const handle = on(target, 'test', function() {}); + assert.isFalse(emit(target, { type: 'test' })); + + handle.destroy(); + } +}); diff --git a/src/lib/core/tests/unit/on/browserOnly.ts b/src/lib/core/tests/unit/on/browserOnly.ts new file mode 100644 index 0000000..3e1e4e3 --- /dev/null +++ b/src/lib/core/tests/unit/on/browserOnly.ts @@ -0,0 +1,80 @@ +import common from './common'; +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import on, { emit } from '../../../src/on'; +import { EventObject } from '../../../src/interfaces'; + +function createTarget(): HTMLElement { + let element = document.createElement('div'); + document.body.appendChild(element); + return element; +} + +function destroyTarget(target: HTMLElement): void { + if (target.parentNode !== null) { + target.parentNode.removeChild(target); + } +} + +interface DOMEvent extends EventObject { + preventDefault: Function; +} + +function isDOMEvent(object: any): object is DOMEvent { + return Boolean(object.preventDefault); +} + +registerSuite('events - EventTarget', { + 'common cases': common({ + eventName: 'test', + createTarget: createTarget, + destroyTarget: destroyTarget + }), + + 'emit return value'() { + const target = createTarget(); + assert.isTrue(emit(target, { type: 'test' })); + + const handle = on(target, 'test', function(evt: EventObject) { + if (isDOMEvent(evt)) { + evt.preventDefault(); + } + }); + + assert.isTrue(emit(target, { type: 'test', cancelable: false })); + assert.isFalse(emit(target, { type: 'test', cancelable: true })); + + destroyTarget(target); + handle.destroy(); + }, + + 'emit on window'() { + const target = window; + + const handle = on(target, 'test', function(evt: EventObject) { + if (isDOMEvent(evt)) { + evt.preventDefault(); + } + }); + + assert.isTrue(emit(target, { type: 'test', cancelable: false })); + assert.isFalse(emit(target, { type: 'test', cancelable: true })); + + handle.destroy(); + }, + + 'emit on document'() { + const target = document; + + const handle = on(target, 'test', function(evt: EventObject) { + if (isDOMEvent(evt)) { + evt.preventDefault(); + } + }); + + assert.isTrue(emit(target, { type: 'test', cancelable: false })); + assert.isFalse(emit(target, { type: 'test', cancelable: true })); + + handle.destroy(); + } +}); diff --git a/src/lib/core/tests/unit/on/common.ts b/src/lib/core/tests/unit/on/common.ts new file mode 100644 index 0000000..b5c45d1 --- /dev/null +++ b/src/lib/core/tests/unit/on/common.ts @@ -0,0 +1,145 @@ +const { assert } = intern.getPlugin('chai'); +import { ObjectSuiteDescriptor } from 'intern/lib/interfaces/object'; +import on, { emit, once, pausable } from '../../../src/on'; +import { Handle } from '../../../src/interfaces'; + +let handles: Handle[] = []; +function testOn(...args: any[]) { + let handle = on.apply(null, arguments); + handles.push(handle); + return handle; +} + +function cleanUpListeners(): void { + while (handles.length > 0) { + const handle = handles.pop(); + if (handle) { + handle.destroy(); + } + } +} + +interface CustomEvent { + type: string | symbol; + value?: string; + cancelable?: boolean; + preventDefault?: () => void; +} + +export default function(args: any): ObjectSuiteDescriptor { + let target: any; + const testEventName: string = args.eventName; + + return { + beforeEach() { + target = args.createTarget(); + }, + + afterEach() { + cleanUpListeners(); + args.destroyTarget && args.destroyTarget(target); + }, + + tests: { + 'on and emit'() { + let listenerCallCount = 0; + let emittedEvent: CustomEvent; + + testOn(target, testEventName, function(actualEvent: CustomEvent) { + listenerCallCount++; + assert.strictEqual(actualEvent.value, emittedEvent.value); + }); + + emittedEvent = { value: 'foo', type: testEventName }; + emit(target, emittedEvent); + assert.strictEqual(listenerCallCount, 1); + + emittedEvent = { value: 'bar', type: testEventName }; + emit(target, emittedEvent); + assert.strictEqual(listenerCallCount, 2); + }, + + 'on - multiple event names'() { + let listenerCallCount = 0; + let emittedEventType: string; + let emittedEvent: CustomEvent; + + testOn(target, ['test1', 'test2'], function(actualEvent: CustomEvent) { + listenerCallCount++; + if (emittedEventType in actualEvent) { + assert.strictEqual(actualEvent.type, emittedEventType); + } + assert.strictEqual(actualEvent.value, emittedEvent.value); + }); + + emittedEventType = 'test1'; + emittedEvent = { type: emittedEventType, value: 'foo' }; + emit(target, emittedEvent); + assert.strictEqual(listenerCallCount, 1); + + emittedEventType = 'test2'; + emittedEvent = { type: emittedEventType, value: 'bar' }; + emit(target, emittedEvent); + assert.strictEqual(listenerCallCount, 2); + }, + + 'on - multiple handlers'() { + const order: any[] = []; + testOn(target, ['a', 'b'], function(event: CustomEvent) { + order.push(`1${event.type}`); + }); + testOn(target, ['a', 'c'], function(event: CustomEvent) { + order.push(`2${event.type}`); + }); + emit(target, { type: 'a' }); + emit(target, { type: 'b' }); + emit(target, { type: 'c' }); + assert.deepEqual(order, ['1a', '2a', '1b', '2c']); + }, + + once() { + let listenerCallCount = 0; + let emittedEvent: CustomEvent; + + handles.push( + once(target, testEventName, function(actualEvent: CustomEvent) { + listenerCallCount++; + assert.strictEqual(actualEvent.value, emittedEvent.value); + }) + ); + + emittedEvent = { value: 'foo', type: testEventName }; + + emit(target, emittedEvent); + assert.strictEqual(listenerCallCount, 1); + + emit(target, emittedEvent); + assert.strictEqual(listenerCallCount, 1); + }, + + pausable() { + let listenerCallCount = 0; + let emittedEvent: CustomEvent; + + let handle = pausable(target, testEventName, function(actualEvent: CustomEvent) { + listenerCallCount++; + assert.strictEqual(actualEvent.value, emittedEvent.value); + }); + handles.push(handle); + + emittedEvent = { value: 'foo', type: testEventName }; + + emit(target, emittedEvent); + assert.strictEqual(listenerCallCount, 1); + + handle.pause(); + emit(target, emittedEvent); + assert.strictEqual(listenerCallCount, 1); + + handle.resume(); + emit(target, emittedEvent); + assert.strictEqual(listenerCallCount, 2); + } + } + }; +} diff --git a/src/lib/core/tests/unit/on/nodeOnly.ts b/src/lib/core/tests/unit/on/nodeOnly.ts new file mode 100644 index 0000000..aa7d402 --- /dev/null +++ b/src/lib/core/tests/unit/on/nodeOnly.ts @@ -0,0 +1,26 @@ +import common from './common'; +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import on, { emit } from '../../../src/on'; +import * as events from 'events'; + +function createTarget() { + return new events.EventEmitter(); +} + +registerSuite('events - EventEmitter', { + 'common cases': common({ + eventName: 'test', + createTarget: createTarget + }), + + 'emit return value'() { + const target = createTarget(); + assert.isFalse(emit(target, { type: 'test' })); + + const handle = on(target, 'test', function() {}); + assert.isFalse(emit(target, { type: 'test' })); + + handle.destroy(); + } +}); diff --git a/src/lib/core/tests/unit/request.ts b/src/lib/core/tests/unit/request.ts new file mode 100644 index 0000000..a15c741 --- /dev/null +++ b/src/lib/core/tests/unit/request.ts @@ -0,0 +1,163 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import Task from '../../src/async/Task'; +import request, { providerRegistry, Response, Headers, RequestOptions, UploadObservableTask } from '../../src/request'; +import ResponseClass from '../../src/request/Response'; +import Observable from '../../src/Observable'; + +const mockData = '{ "foo": "bar" }'; +let handle: any; + +function mockProvider(url: string, options?: RequestOptions): UploadObservableTask { + const task: UploadObservableTask = Task.resolve( + new class extends ResponseClass { + bodyUsed = false; + headers: Headers = new Headers(); + ok = true; + status = 200; + statusText = 'OK'; + url: string = url; + requestOptions = options || {}; + + download = new Observable(() => {}); + data = new Observable(() => {}); + + arrayBuffer(): Task { + return Task.resolve(null); + } + + blob(): Task { + return Task.resolve(null); + } + + formData(): Task { + return Task.resolve(null); + } + + text(): Task { + return Task.resolve(mockData); + } + }() + ); + + task.upload = new Observable(() => {}); + + return task; +} + +registerSuite('request', { + afterEach() { + if (handle) { + handle.destroy(); + handle = null; + } + }, + + tests: { + 'helper methods': { + beforeEach() { + handle = providerRegistry.register('test.html', mockProvider); + }, + + tests: { + get() { + return request.get('test.html').then((response) => { + assert.equal(response.requestOptions.method, 'GET'); + }); + }, + delete() { + return request.delete('test.html').then((response) => { + assert.equal(response.requestOptions.method, 'DELETE'); + }); + }, + head() { + return request.head('test.html').then((response) => { + assert.equal(response.requestOptions.method, 'HEAD'); + }); + }, + options() { + return request.options('test.html').then((response) => { + assert.equal(response.requestOptions.method, 'OPTIONS'); + }); + }, + post() { + return request + .post('test.html', { + body: 'some body' + }) + .then((response) => { + assert.equal(response.requestOptions.method, 'POST'); + assert.equal(response.requestOptions.body, 'some body'); + }); + }, + put() { + return request.put('test.html').then((response) => { + assert.equal(response.requestOptions.method, 'PUT'); + }); + } + } + }, + + 'custom provider': { + 'String matching'() { + handle = providerRegistry.register('arbitrary.html', mockProvider); + + return request + .get('arbitrary.html') + .then(function(response) { + return response.text(); + }) + .then((data) => { + assert.equal(data, mockData); + }); + }, + + 'RegExp matching'() { + handle = providerRegistry.register(/arbitrary\.html$/, mockProvider); + + return request + .get('arbitrary.html') + .then(function(response) { + return response.text(); + }) + .then((text) => { + assert.equal(text, mockData); + }); + }, + + 'Default matching'() { + handle = providerRegistry.register(function(url: string): boolean { + return url === 'arbitrary.html'; + }, mockProvider); + + return request + .get('arbitrary.html') + .then(function(response) { + return response.text(); + }) + .then((text) => { + assert.equal(text, mockData); + }); + } + }, + + 'custom filters': { + beforeEach() { + handle = providerRegistry.register('arbitrary.html', mockProvider); + }, + + tests: { + 'JSON matching'() { + return request + .get('arbitrary.html') + .then(function(response) { + return response.json<{ foo: string }>(); + }) + .then((json) => { + assert.deepEqual(json, { foo: 'bar' }, 'JSON parsing should be automatically provided.'); + }); + } + } + } + } +}); diff --git a/src/lib/core/tests/unit/request/SubscriptionPool.ts b/src/lib/core/tests/unit/request/SubscriptionPool.ts new file mode 100644 index 0000000..d1b7e41 --- /dev/null +++ b/src/lib/core/tests/unit/request/SubscriptionPool.ts @@ -0,0 +1,49 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import SubscriptionPool from '../../../src/request/SubscriptionPool'; +import Observable from '../../../src/Observable'; + +registerSuite('SubscriptionPool', { + 'registers observers'(this: any) { + const dfd = this.async(); + + const pool = new SubscriptionPool(); + const obs = new Observable((observer) => pool.add(observer)); + + obs.subscribe((value) => { + assert.deepEqual(value, 1); + dfd.resolve(); + }); + + pool.next(1); + }, + + 'queues events when no observers are present'(this: any) { + const dfd = this.async(); + + const pool = new SubscriptionPool(); + const obs = new Observable((observer) => pool.add(observer)); + + pool.next(1); + + obs.subscribe((value) => { + assert.strictEqual(value, 1); + dfd.resolve(); + }); + }, + + 'queued events have a maximum count'(this: any) { + const dfd = this.async(); + + const pool = new SubscriptionPool(1); + const obs = new Observable((observer) => pool.add(observer)); + + pool.next(1); + pool.next(2); + + obs.subscribe((value) => { + assert.strictEqual(value, 2); + dfd.resolve(); + }); + } +}); diff --git a/src/lib/core/tests/unit/request/all.ts b/src/lib/core/tests/unit/request/all.ts new file mode 100644 index 0000000..759ec69 --- /dev/null +++ b/src/lib/core/tests/unit/request/all.ts @@ -0,0 +1 @@ +import './SubscriptionPool'; diff --git a/src/lib/core/tests/unit/request/node.ts b/src/lib/core/tests/unit/request/node.ts new file mode 100644 index 0000000..c7548be --- /dev/null +++ b/src/lib/core/tests/unit/request/node.ts @@ -0,0 +1,1185 @@ +import * as fs from 'fs'; +import { createServer } from 'http'; +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import { parse } from 'url'; +import * as zlib from 'zlib'; +import { Response } from '../../../src/request/interfaces'; +import { default as nodeRequest, NodeResponse } from '../../../src/request/providers/node'; +import TimeoutError from '../../../src/request/TimeoutError'; + +const serverPort = 8124; +const serverUrl = 'http://localhost:' + serverPort; +let server: any; +let proxy: any; +let requestData: string; + +const blobFileSize = fs.statSync('tests/support/data/blob.gif').size; + +interface DummyResponse { + body?: string | ((callback: Function) => void); + headers?: { [key: string]: string }; + statusCode?: number; +} + +interface RedirectTestData { + title?: string; + method?: string; + url: string; + expectedPage?: string; + expectedCount?: number; + expectedMethod?: string; + expectedData?: any; + expectedToError?: boolean; + followRedirects?: boolean; + callback?: (_: any) => void; + keepOriginalMethod?: boolean; +} + +const responseData: { [url: string]: DummyResponse } = { + 'foo.json': { + body: JSON.stringify({ foo: 'bar' }) + }, + cookies: { + body: JSON.stringify({ foo: 'bar' }), + headers: { + 'Set-cookie': 'one' + } + }, + invalidJson: { + body: 'JSON' + }, + 'redirect-success': { + body: JSON.stringify({ success: true }) + }, + '300-redirect': { + statusCode: 300, + body: JSON.stringify('beginning to redirect'), + headers: { + Location: getRequestUrl('redirect-success') + } + }, + '301-redirect': { + statusCode: 301, + body: JSON.stringify('beginning to redirect'), + headers: { + Location: getRequestUrl('redirect-success') + } + }, + '302-redirect': { + statusCode: 302, + body: JSON.stringify('beginning to redirect'), + headers: { + Location: getRequestUrl('redirect-success') + } + }, + '303-redirect': { + statusCode: 303, + body: JSON.stringify('beginning to redirect'), + headers: { + Location: getRequestUrl('redirect-success') + } + }, + '304-redirect': { + statusCode: 304, + body: JSON.stringify('beginning to redirect'), + headers: { + Location: getRequestUrl('redirect-success') + } + }, + '305-redirect': { + statusCode: 305, + body: JSON.stringify('beginning to redirect'), + headers: { + Location: 'http://localhost:1337' + } + }, + '305-redirect-broken': { + statusCode: 305, + body: JSON.stringify('beginning to redirect') + }, + '306-redirect': { + statusCode: 306, + body: JSON.stringify('beginning to redirect'), + headers: { + Location: getRequestUrl('redirect-success') + } + }, + '307-redirect': { + statusCode: 307, + body: JSON.stringify('beginning to redirect'), + headers: { + Location: getRequestUrl('redirect-success') + } + }, + 'infinite-redirect': { + statusCode: 301, + body: JSON.stringify('beginning to redirect'), + headers: { + Location: getRequestUrl('infinite-redirect') + } + }, + 'broken-redirect': { + statusCode: 301, + body: JSON.stringify('beginning to redirect'), + headers: {} + }, + 'relative-redirect': { + statusCode: 301, + body: JSON.stringify('beginning redirect'), + headers: { + Location: '/redirect-success' + } + }, + 'protocolless-redirect': { + statusCode: 301, + body: JSON.stringify('beginning redirect'), + headers: { + Location: getRequestUrl('redirect-success').replace('http:', '') + } + }, + 'gzip-compressed': { + statusCode: 200, + body: function(callback: any) { + zlib.gzip(new Buffer(JSON.stringify({ test: true }), 'utf8'), function(err: any, result: any) { + callback(result); + }); + }, + headers: { + 'Content-Encoding': 'gzip' + } + }, + 'deflate-compressed': { + statusCode: 200, + body: function(callback: any) { + zlib.deflate(new Buffer(JSON.stringify({ test: true }), 'utf8'), function(err: any, result: any) { + callback(result); + }); + }, + headers: { + 'Content-Encoding': 'deflate' + } + }, + 'gzip-deflate-compressed': { + statusCode: 200, + body: function(callback: any) { + zlib.gzip(new Buffer(JSON.stringify({ test: true }), 'utf8'), (err: any, result: any) => { + zlib.deflate(result, function(err: any, result: any) { + callback(result); + }); + }); + }, + headers: { + 'Content-Encoding': 'gzip, deflate' + } + }, + 'gzip-invalid': { + statusCode: 200, + body: 'hello', + headers: { + 'Content-Encoding': 'gzip' + } + }, + 'deflate-invalid': { + statusCode: 200, + body: 'hello', + headers: { + 'Content-Encoding': 'deflate' + } + }, + 'gzip-deflate-invalid': { + statusCode: 200, + body: 'hello', + headers: { + 'Content-Encoding': 'gzip, deflate' + } + }, + 'blob.gif': { + statusCode: 200, + body: function(callback: any) { + callback(fs.readFileSync('tests/support/data/blob.gif')); + } + } +}; + +function buildRedirectTests(methods: RedirectTestData[]) { + let tests: { [key: string]: () => void } = {}; + + methods.forEach((details) => { + const method = details.method; + const { keepOriginalMethod = false } = details; + const url = getRequestUrl(details.url); + const expectedMethod = details.expectedMethod || method; + const expectedPage = details.expectedPage ? getRequestUrl(details.expectedPage) : url; + const followRedirects = details.followRedirects === undefined ? true : details.followRedirects; + + let title = details.title || method + ' ' + (keepOriginalMethod ? 'w/' : 'w/o') + ' keepOriginalMethod'; + + tests[title] = () => { + let error: any = null; + + return nodeRequest(getRequestUrl(details.url), { + method: method, + followRedirects: followRedirects, + redirectOptions: { + keepOriginalMethod + } + }) + .then((response?: Response) => { + if (response) { + return response.text().then((text: string) => { + if (details.callback) { + details.callback(response); + } + + (assert as any).nestedPropertyVal(response, 'requestOptions.method', expectedMethod); + assert.equal(response.url, expectedPage); + + if (details.expectedCount !== undefined) { + const { + redirectOptions: { count: redirectCount = 0 } = {} + } = (response).requestOptions; + + assert.equal(redirectCount, details.expectedCount); + } + + if (details.expectedData !== undefined) { + if (text === null) { + assert.isNull(details.expectedData); + } else { + let data = JSON.parse(text); + assert.deepEqual(data, details.expectedData); + } + } + }); + } + }) + .catch((e: Error) => { + error = e; + }) + .finally(() => { + if (details.expectedToError) { + assert.isNotNull(error, 'Expected an error to occur but none did'); + } else if (error) { + throw error; + } + }); + }; + }); + + return tests; +} + +function getResponseData(request: any): DummyResponse { + const urlInfo = parse(request.url, true); + + if (urlInfo.query.dataKey === 'echo') { + return { + body: JSON.stringify({ + headers: request.headers + }) + }; + } + + return responseData[urlInfo.query.dataKey as string] || {}; +} + +function getRequestUrl(dataKey: string): string { + return serverUrl + '/?dataKey=' + dataKey; +} + +function getAuthRequestUrl(dataKey: string, user: string = 'user', password: string = 'password'): string { + const requestUrl = getRequestUrl(dataKey); + return requestUrl.slice(0, 7) + user + ':' + password + '@' + requestUrl.slice(7); +} + +function assertBasicAuthentication(options: { user?: string; password?: string }, expectedAuth: string, dfd: any) { + nodeRequest(getRequestUrl('foo.json'), options).then( + dfd.callback(function(response: any) { + const actual: string = response.nativeResponse.req._headers.authorization; + const expected = `Basic ${new Buffer(expectedAuth).toString('base64')}`; + + assert.strictEqual(actual, expected); + }), + dfd.reject.bind(dfd) + ); +} + +registerSuite('request/node', { + before(this: any) { + const dfd = this.async(); + + server = createServer(function(request, response) { + const { statusCode = 200, headers = {}, body = '{}' } = getResponseData(request); + + const data: string[] = []; + request.on('data', function(chunk: any) { + data.push(chunk.toString('utf8')); + }); + + request.on('end', function() { + requestData = data.length ? JSON.parse(data.join()) : null; + + if (!('Content-Type' in headers)) { + headers['Content-Type'] = 'application/json'; + } + + response.writeHead(statusCode, headers); + + if (typeof body === 'function') { + body(function(result: Buffer) { + response.write(result); + response.end(); + }); + } else { + response.write(new Buffer(body, 'utf8')); + response.end(); + } + }); + }); + + server.on('listening', dfd.resolve.bind(dfd)); + server.listen(serverPort); + + proxy = createServer((request, response) => { + const statusCode = 200, + headers: any = {}, + body = '{}'; + + requestData = ''; + + if (!('Content-Type' in headers)) { + headers['Content-Type'] = 'application/json'; + } + + headers['Proxy-agent'] = 'nodejs'; + + response.writeHead(statusCode, headers); + + response.write(new Buffer(body, 'utf8')); + + response.end(); + }); + + proxy.listen(1337); + + return dfd.promise; + }, + + after() { + server.close(); + proxy.close(); + }, + + tests: { + 'request options': { + body: { + string(this: any): void { + const dfd = this.async(); + nodeRequest(getRequestUrl('foo.json'), { + body: '{ "foo": "bar" }', + method: 'POST' + }).then( + dfd.callback(function() { + assert.deepEqual(requestData, { foo: 'bar' } as any); + }), + dfd.reject.bind(dfd) + ); + }, + buffer() { + return nodeRequest(getRequestUrl('foo.json'), { + body: Buffer.from('{ "foo": "bar" }', 'utf8'), + method: 'POST' + }).then(() => { + assert.deepEqual(requestData, { foo: 'bar' } as any); + }); + } + }, + + bodyStream: { + 'stream is read'(this: any) { + return nodeRequest(getRequestUrl('echo'), { + method: 'POST', + bodyStream: fs.createReadStream('tests/support/data/foo.json') + }) + .then((res) => res.json()) + .then((json) => { + assert.deepEqual(requestData, { foo: 'bar' } as any); + }); + } + }, + + 'content encoding': (function(compressionTypes) { + const suites: { [key: string]: any } = {}; + + compressionTypes.map((type) => { + suites[type] = { + 'gets decoded'() { + return nodeRequest(getRequestUrl(`${type}-compressed`)) + .then((response) => { + return response.json(); + }) + .then((obj) => { + assert.deepEqual(obj, { test: true }); + }); + }, + 'errors are caught'() { + return nodeRequest(getRequestUrl(`${type}-invalid`)) + .then((response) => { + return response.json(); + }) + .then( + () => { + assert.fail('Should not have succeeded'); + }, + (error) => { + assert.isNotNull(error); + } + ); + } + }; + }); + + return suites; + })(['gzip', 'deflate', 'gzip-deflate']), + + proxy(this: any): void { + const dfd = this.async(); + const url = getRequestUrl('foo.json'); + nodeRequest(url, { + proxy: url.slice(0, 7) + 'username:password@' + url.slice(7) + }).then( + dfd.callback(function(response: any) { + const request = response.nativeResponse.req; + + assert.strictEqual(request.path, url); + assert.strictEqual( + request._headers['proxy-authorization'], + 'Basic ' + new Buffer('username:password').toString('base64') + ); + assert.strictEqual(request._headers.host, serverUrl.slice(7)); + }), + dfd.reject.bind(dfd) + ); + }, + + 'user and password': { + both(this: any): void { + const user = 'user name'; + const password = 'pass word'; + assertBasicAuthentication( + { + user, + password + }, + `${user}:${password}`, + this.async() + ); + }, + + 'user only'(this: any): void { + const user = 'user name'; + assertBasicAuthentication( + { + user + }, + `${user}:`, + this.async() + ); + }, + + 'password only'(this: any): void { + const password = 'pass word'; + assertBasicAuthentication( + { + password + }, + `:${password}`, + this.async() + ); + }, + + 'special characters'(this: any): void { + const user = '$pecialUser'; + const password = '__!passW@rd'; + assertBasicAuthentication( + { + user, + password + }, + `${user}:${password}`, + this.async() + ); + }, + + error(this: any): void { + const dfd = this.async(); + nodeRequest(getAuthRequestUrl('foo.json'), { timeout: 1 }).then( + dfd.resolve.bind(dfd), + dfd.callback(function(error: TimeoutError): void { + assert.notInclude(error.message, 'user:password'); + assert.include(error.message, '(redacted)'); + }) + ); + } + }, + + socketOptions(this: any): void { + const dfd = this.async(); + nodeRequest(getRequestUrl('foo.json'), { + socketOptions: { + keepAlive: 100, + noDelay: true, + timeout: 100 + } + }).then( + dfd.callback(function(response: NodeResponse) { + // TODO: Is it even possible to test this? + const socketOptions = response.requestOptions.socketOptions || {}; + assert.strictEqual(socketOptions.keepAlive, 100); + assert.strictEqual(socketOptions.noDelay, true); + assert.strictEqual(socketOptions.timeout, 100); + }), + dfd.reject.bind(dfd) + ); + }, + + streamEncoding(this: any): void { + const dfd = this.async(); + nodeRequest(getRequestUrl('foo.json'), { + streamEncoding: 'utf8' + }).then((response: NodeResponse) => { + response.json().then( + dfd.callback(function(json: any) { + assert.deepEqual(json, { foo: 'bar' }); + }) + ); + }, dfd.reject.bind(dfd)); + }, + + '"timeout"'(this: any): void { + const dfd = this.async(); + nodeRequest(getRequestUrl('foo.json'), { timeout: 1 }).then( + dfd.resolve.bind(dfd), + dfd.callback(function(error: Error): void { + assert.strictEqual(error.name, 'TimeoutError'); + }) + ); + }, + 'upload monitoriting': { + 'with a stream'(this: any) { + let events: number[] = []; + + const req = nodeRequest(getRequestUrl('foo.json'), { + method: 'POST', + bodyStream: fs.createReadStream('tests/support/data/foo.json') + }); + + req.upload.subscribe((totalBytesUploaded) => { + events.push(totalBytesUploaded); + }); + + return req.then((res) => { + assert.isTrue(events.length > 0, 'was expecting at least one monitor event'); + assert.equal(events[events.length - 1], 17); + }); + }, + 'without a stream'(this: any) { + let events: number[] = []; + + const req = nodeRequest(getRequestUrl('foo.json'), { + method: 'POST', + body: '{ "foo": "bar" }\n' + }); + + req.upload.subscribe((totalBytesUploaded) => { + events.push(totalBytesUploaded); + }); + + return req.then((res) => { + assert.isTrue(events.length > 0, 'was expecting at least one monitor event'); + assert.equal(events[events.length - 1], 17); + }); + } + }, + 'download events'() { + let downloadEvents: number[] = []; + + return nodeRequest(getRequestUrl('foo.json')).then((response) => { + response.download.subscribe((totalBytesDownloaded) => { + downloadEvents.push(totalBytesDownloaded); + }); + + return response.text().then(() => { + assert.isTrue(downloadEvents.length > 0); + }); + }); + }, + + 'data events'() { + let data: number[] = []; + + return nodeRequest(getRequestUrl('foo.json')).then((response) => { + response.data.subscribe((chunk) => { + data.push(chunk); + }); + + return response.text().then(() => { + assert.isTrue(data.length > 0); + }); + }); + } + }, + + headers: { + 'request headers should not be normalized'(this: any): void { + const dfd = this.async(); + nodeRequest(getRequestUrl('foo.json'), { + headers: { + someThingCrAzY: 'some-arbitrary-value' + } + }).then( + dfd.callback(function(response: NodeResponse) { + const header: any = (response.nativeResponse).req._header; + + assert.notInclude(header, 'somethingcrazy: some-arbitrary-value'); + assert.include(header, 'someThingCrAzY: some-arbitrary-value'); + assert.match(header, /dojo\/[^\s]+ Node\.js/); + }), + dfd.reject.bind(dfd) + ); + }, + + 'user agent should be added if its not there'(this: any): any { + return nodeRequest(getRequestUrl('foo.json'), {}) + .then((response: any) => { + const header: any = response.nativeResponse.req._header; + + assert.include(header, 'user-agent:'); + + return nodeRequest(getRequestUrl('food.json'), { + headers: { + 'user-agent': 'already exists' + } + }); + }) + .then((response: any) => { + const header: any = response.nativeResponse.req._header; + + assert.include(header, 'user-agent: already exists'); + + return nodeRequest(getRequestUrl('food.json'), { + headers: { + 'uSeR-AgEnT': 'mIxEd CaSe' + } + }); + }) + .then((response: any) => { + const header: any = response.nativeResponse.req._header; + + assert.include(header, 'uSeR-AgEnT: mIxEd CaSe'); + }); + }, + + 'compression headers are present by default'() { + return nodeRequest(getRequestUrl('foo.json')).then((response: any) => { + const header: any = response.nativeResponse.req._header; + assert.include(header, 'Accept-Encoding: gzip, deflate'); + }); + }, + + 'compression headers can be turned off'() { + return nodeRequest(getRequestUrl('foo.json'), { + acceptCompression: false + }).then((response: any) => { + const header: any = response.nativeResponse.req._header; + assert.notInclude(header, 'Accept-Encoding:'); + }); + }, + + 'response headers': { + 'after response'(this: any): void { + const dfd = this.async(); + nodeRequest(getRequestUrl('foo.json')).then( + dfd.callback(function(response: Response): void { + assert.strictEqual(response.headers.get('content-type'), 'application/json'); + }), + dfd.reject.bind(dfd) + ); + } + }, + + 'set cookie makes separate headers'() { + return nodeRequest(getRequestUrl('cookies')).then((response: any) => { + assert.deepEqual(response.headers.getAll('set-cookie'), ['one']); + }); + } + }, + + 'response object': { + properties(this: any): void { + const dfd = this.async(); + nodeRequest(getRequestUrl('foo.json')).then( + dfd.callback(function(response: Response): void { + assert.strictEqual(response.status, 200); + }), + dfd.reject.bind(dfd) + ); + }, + + 'data cannot be used twice'() { + return nodeRequest(getRequestUrl('foo.json')).then((response) => { + assert.isFalse(response.bodyUsed); + + return response.json().then(() => { + assert.isTrue(response.bodyUsed); + + return response.json().then( + () => { + throw new Error('should not have succeeded'); + }, + () => { + return true; + } + ); + }); + }); + }, + + 'response types': { + 'arrayBuffer with binary content'() { + return nodeRequest(getRequestUrl('blob.gif')).then((response: any) => { + return response.arrayBuffer().then((arrayBuffer: any) => { + assert.strictEqual(arrayBuffer.byteLength, blobFileSize); + }); + }); + }, + + 'arrayBuffer with text content'() { + return nodeRequest(getRequestUrl('foo.json')).then((response: any) => { + return response.arrayBuffer().then((arrayBuffer: any) => { + assert.strictEqual(arrayBuffer.byteLength, JSON.stringify({ foo: 'bar' }).length); + }); + }); + }, + + blob() { + return nodeRequest(getRequestUrl('foo.json')).then((response: any) => { + return response.blob().then( + (blob: any) => { + assert.fail('should not have succeeded'); + }, + () => { + return true; + } + ); + }); + } + } + }, + + 'status codes': { + Redirects: { + '300 Multiple Choices': buildRedirectTests([ + { + method: 'GET', + url: '300-redirect', + expectedCount: 0 + }, + { + method: 'POST', + url: '300-redirect', + expectedCount: 0 + }, + { + method: 'PUT', + url: '300-redirect', + expectedCount: 0 + }, + { + method: 'DELETE', + url: '300-redirect', + expectedCount: 0 + }, + { + method: 'HEAD', + url: '300-redirect', + expectedCount: 0 + } + ]), + '301 Moved Permanently': buildRedirectTests([ + { + method: 'GET', + url: '301-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedData: { success: true } + }, + { + method: 'HEAD', + url: '301-redirect', + expectedPage: 'redirect-success', + expectedCount: 1 + }, + { + method: 'POST', + url: '301-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'POST', + url: '301-redirect', + keepOriginalMethod: true, + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'POST', + expectedData: { success: true } + }, + { + method: 'DELETE', + url: '301-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'DELETE', + url: '301-redirect', + keepOriginalMethod: true, + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'DELETE', + expectedData: { success: true } + }, + { + method: 'PUT', + url: '301-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'PUT', + url: '301-redirect', + keepOriginalMethod: true, + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'PUT', + expectedData: { success: true } + } + ]), + + '302 Found': buildRedirectTests([ + { + method: 'GET', + url: '302-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedData: { success: true } + }, + { + method: 'HEAD', + url: '302-redirect', + expectedPage: 'redirect-success', + expectedCount: 1 + }, + { + method: 'POST', + url: '302-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'POST', + url: '302-redirect', + keepOriginalMethod: true, + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'POST', + expectedData: { success: true } + }, + { + method: 'DELETE', + url: '302-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'DELETE', + url: '302-redirect', + keepOriginalMethod: true, + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'DELETE', + expectedData: { success: true } + }, + { + method: 'PUT', + url: '302-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'PUT', + url: '302-redirect', + keepOriginalMethod: true, + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'PUT', + expectedData: { success: true } + } + ]), + + '303 See Other': buildRedirectTests([ + { + method: 'GET', + url: '303-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedData: { success: true } + }, + { + method: 'HEAD', + url: '303-redirect', + expectedPage: 'redirect-success', + expectedMethod: 'GET', + expectedCount: 1 + }, + { + method: 'POST', + url: '303-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'POST', + url: '303-redirect', + keepOriginalMethod: true, + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'DELETE', + url: '303-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'DELETE', + url: '303-redirect', + keepOriginalMethod: true, + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'PUT', + url: '303-redirect', + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'PUT', + url: '303-redirect', + keepOriginalMethod: true, + expectedPage: 'redirect-success', + expectedCount: 1, + expectedMethod: 'GET', + expectedData: { success: true } + }, + { + method: 'GET', + title: 'Without redirect following', + url: '303-redirect', + expectedPage: '303-redirect', + expectedCount: 0, + expectedMethod: 'GET', + followRedirects: false + } + ]), + + '304 Not Modified': buildRedirectTests([ + { + method: 'GET', + url: '304-redirect', + expectedPage: '304-redirect', + expectedCount: 0 + }, + { + method: 'HEAD', + url: '304-redirect', + expectedPage: '304-redirect', + expectedCount: 0 + }, + { + method: 'POST', + url: '304-redirect', + expectedPage: '304-redirect', + expectedCount: 0 + }, + { + method: 'PUT', + url: '304-redirect', + expectedPage: '304-redirect', + expectedCount: 0 + }, + { + method: 'DELETE', + url: '304-redirect', + expectedPage: '304-redirect', + expectedCount: 0 + } + ]), + + '305 Use Proxy': buildRedirectTests([ + { + method: 'GET', + url: '305-redirect', + expectedCount: 1, + callback: (response) => { + assert.equal(response.nativeResponse.headers['proxy-agent'], 'nodejs'); + } + }, + { + title: 'Without a location header', + method: 'GET', + url: '305-redirect-broken', + expectedToError: true + }, + { + method: 'GET', + title: 'Without redirect following', + url: '305-redirect', + expectedPage: '305-redirect', + expectedCount: 0, + expectedMethod: 'GET', + followRedirects: false + } + ]), + + '306 Unused': buildRedirectTests([ + { + method: 'GET', + url: '306-redirect', + expectedToError: true + } + ]), + + '307 Temporary Redirect': buildRedirectTests([ + { + method: 'GET', + url: '307-redirect', + expectedPage: 'redirect-success', + expectedCount: 1 + }, + { + method: 'HEAD', + url: '307-redirect', + expectedPage: 'redirect-success', + expectedCount: 1 + }, + { + method: 'POST', + url: '307-redirect', + expectedPage: 'redirect-success', + expectedCount: 1 + }, + { + method: 'PUT', + url: '307-redirect', + expectedPage: 'redirect-success', + expectedCount: 1 + }, + { + method: 'DELETE', + url: '307-redirect', + expectedPage: 'redirect-success', + expectedCount: 1 + }, + { + method: 'GET', + title: 'Without redirect following', + url: '307-redirect', + expectedPage: '307-redirect', + expectedCount: 0, + expectedMethod: 'GET', + followRedirects: false + } + ]), + + 'Infinite Redirects': function() { + let didError = false; + + return nodeRequest(getRequestUrl('infinite-redirect'), { + redirectOptions: { + limit: 10 + } + }) + .then((response) => {}) + .catch(() => { + didError = true; + }) + .finally(() => { + assert.isTrue(didError, 'Expected an error to occur but none did'); + }); + }, + + 'Sensible Defaults': function() { + return nodeRequest(getRequestUrl('301-redirect'), {}).then((response: any) => { + assert.equal(response.url, getRequestUrl('redirect-success')); + }); + }, + + 'Redirect with no header': buildRedirectTests([ + { + method: 'GET', + url: 'broken-redirect', + expectedToError: true + } + ]), + + 'Can turn off follow redirects': buildRedirectTests([ + { + method: 'GET', + url: '301-redirect', + expectedCount: 0, + followRedirects: false + } + ]), + + 'Relative redirect urls': buildRedirectTests([ + { + method: 'GET', + url: 'relative-redirect', + expectedPage: 'redirect-success' + }, + { + method: 'GET', + url: 'protocolless-redirect', + expectedPage: 'redirect-success' + } + ]) + } + } + } +}); diff --git a/src/lib/core/tests/unit/request/xhr.ts b/src/lib/core/tests/unit/request/xhr.ts new file mode 100644 index 0000000..0ca6265 --- /dev/null +++ b/src/lib/core/tests/unit/request/xhr.ts @@ -0,0 +1,639 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); + +import xhrRequest, { XhrResponse } from '../../../src/request/providers/xhr'; +import { Response } from '../../../src/request/interfaces'; +import UrlSearchParams from '../../../src/UrlSearchParams'; +import has from '../../../src/has'; +import Promise from '@dojo/shim/Promise'; + +let echoServerAvailable = false; +registerSuite('request/providers/xhr', { + before(this: any) { + return xhrRequest('/__echo/', { + method: 'GET', + timeout: 10000 + }).then((response) => { + if (response && response.status === 200) { + echoServerAvailable = true; + return; + } + }); + }, + + tests: { + 'HTTP methods': { + specified(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/foo.json', { method: 'get' }).then(function(response: any) { + assert.strictEqual(response.requestOptions.method, 'get'); + }); + }, + + default(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/foo.json').then(function(response: any) { + assert.strictEqual(response.requestOptions.method, 'GET'); + }); + }, + + '.get with URL query'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/xhr?color=blue&numbers=one&numbers=two').then(function(response: any) { + return response.json().then((data: any) => { + const query = data.query; + assert.deepEqual(query, { + color: 'blue', + numbers: ['one', 'two'] + }); + assert.strictEqual(response.url, '/__echo/xhr?color=blue&numbers=one&numbers=two'); + }); + }); + }, + + '.post': function(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/post', { + method: 'POST', + body: new UrlSearchParams({ color: 'blue' }).toString(), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }).then(function(response: any) { + return response.json().then((data: any) => { + assert.strictEqual(data.method, 'POST'); + const payload = data.payload; + + assert.ok(payload && payload.color); + assert.strictEqual(payload.color, 'blue'); + }); + }); + } + }, + + 'request options': { + '"timeout"'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/xhr?delay=5000', { timeout: 10 }).then( + function() { + assert(false, 'Should have timed out'); + }, + function(error: Error) { + assert.strictEqual(error.name, 'TimeoutError'); + } + ); + }, + + 'user and password'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/foo.json', { + user: 'user', + password: 'password' + }).then(function(response: any) { + assert.strictEqual(response.requestOptions.user, 'user'); + assert.strictEqual(response.requestOptions.password, 'password'); + }); + }, + + 'upload monitoring'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + + let events: number[] = []; + + const req = xhrRequest('/__echo/post', { + method: 'POST', + body: '12345' + }); + + req.upload.subscribe((totalBytesUploaded) => { + events.push(totalBytesUploaded); + }); + + return req.then((res) => { + assert.isTrue(events.length > 0, 'was expecting at least one monitor event'); + assert.equal(events[events.length - 1], 5); + }); + }, + + 'includeUploadProgress=false'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + + const req = xhrRequest('/__echo/post', { + method: 'POST', + body: '12345', + includeUploadProgress: false + }); + + assert.isUndefined(req.upload); + }, + + query: { + '.get with query URL and query option string'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/xhr?color=blue&numbers=one&numbers=two', { + query: new UrlSearchParams({ + foo: ['bar', 'baz'], + thud: 'thonk', + xyzzy: '3' + }).toString() + }).then(function(response: any) { + return response.json().then((data: any) => { + const query = data.query; + assert.deepEqual(query, { + color: 'blue', + numbers: ['one', 'two'], + thud: 'thonk', + foo: ['bar', 'baz'], + xyzzy: '3' + }); + assert.strictEqual( + response.url, + '/__echo/xhr?color=blue&numbers=one&numbers=two&foo=bar&foo=baz&thud=thonk&xyzzy=3' + ); + }); + }); + }, + + '.get with query option string'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/xhr', { + query: new UrlSearchParams({ + foo: ['bar', 'baz'], + thud: 'thonk', + xyzzy: '3' + }).toString() + }).then(function(response: any) { + return response.json().then((data: any) => { + const query = data.query; + assert.deepEqual(query, { + foo: ['bar', 'baz'], + thud: 'thonk', + xyzzy: '3' + }); + assert.strictEqual(response.url, '/__echo/xhr?foo=bar&foo=baz&thud=thonk&xyzzy=3'); + }); + }); + }, + + '.get with query option object'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/xhr', { + query: { + foo: ['bar', 'baz'], + thud: 'thonk', + xyzzy: '3' + } + }).then(function(response: any) { + return response.json().then((data: any) => { + const query = data.query; + assert.deepEqual(query, { + foo: ['bar', 'baz'], + thud: 'thonk', + xyzzy: '3' + }); + assert.strictEqual(response.url, '/__echo/xhr?foo=bar&foo=baz&thud=thonk&xyzzy=3'); + }); + }); + }, + + '.get with cacheBust w/query string w/o/query option'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + let cacheBustStringA: string; + let cacheBustStringB: string; + return xhrRequest('/__echo/xhr?foo=bar', { + cacheBust: true + }) + .then(function(response: any) { + assert.strictEqual(response.url.indexOf('/__echo/xhr?foo=bar'), 0); + cacheBustStringA = response.url.split('&')[1]; + assert.isFalse(isNaN(Number(cacheBustStringA))); + return new Promise(function(resolve, reject) { + setTimeout(function() { + xhrRequest('/__echo/xhr?foo=bar', { + cacheBust: true + }).then(resolve, reject); + }, 5); + }); + }) + .then(function(response: any) { + assert.strictEqual(response.url.indexOf('/__echo/xhr?foo=bar'), 0); + cacheBustStringB = response.url.split('&')[1]; + assert.isFalse(isNaN(Number(cacheBustStringB))); + + assert.notEqual(cacheBustStringA, cacheBustStringB); + }); + }, + + '.get with cacheBust w/query string w/query option'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + let cacheBustStringA: string; + let cacheBustStringB: string; + return xhrRequest('/__echo/xhr?foo=bar', { + cacheBust: true, + query: { + bar: 'baz' + } + }) + .then(function(response: any) { + assert.strictEqual(response.url.indexOf('/__echo/xhr?foo=bar&bar=baz'), 0); + cacheBustStringA = response.url.split('&')[2]; + assert.isFalse(isNaN(Number(cacheBustStringA))); + + return new Promise(function(resolve, reject) { + setTimeout(function() { + xhrRequest('/__echo/xhr?foo=bar', { + cacheBust: true, + query: { + bar: 'baz' + } + }).then(resolve, reject); + }, 5); + }); + }) + .then(function(response: any) { + assert.strictEqual(response.url.indexOf('/__echo/xhr?foo=bar&bar=baz'), 0); + cacheBustStringB = response.url.split('&')[2]; + assert.isFalse(isNaN(Number(cacheBustStringB))); + + assert.notEqual(cacheBustStringA, cacheBustStringB); + }); + }, + + '.get with cacheBust w/o/query string w/query option'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + let cacheBustStringA: string; + let cacheBustStringB: string; + return xhrRequest('/__echo/xhr', { + cacheBust: true, + query: { + foo: 'bar' + } + }) + .then(function(response: any) { + assert.strictEqual(response.url.indexOf('/__echo/xhr?foo=bar'), 0); + cacheBustStringA = response.url.split('&')[1]; + assert.isFalse(isNaN(Number(cacheBustStringA))); + + return new Promise(function(resolve, reject) { + setTimeout(function() { + xhrRequest('/__echo/xhr', { + cacheBust: true, + query: { + foo: 'bar' + } + }).then(resolve, reject); + }, 5); + }); + }) + .then(function(response: any) { + assert.strictEqual(response.url.indexOf('/__echo/xhr?foo=bar'), 0); + cacheBustStringB = response.url.split('&')[1]; + assert.isFalse(isNaN(Number(cacheBustStringB))); + + assert.notEqual(cacheBustStringA, cacheBustStringB); + }); + }, + + '.get with cacheBust and no query'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + let cacheBustStringA: string; + let cacheBustStringB: string; + return xhrRequest('/__echo/xhr', { + cacheBust: true + }) + .then(function(response: any) { + cacheBustStringA = response.url.split('?')[1]; + assert.ok(cacheBustStringA); + assert.isFalse(isNaN(Number(cacheBustStringA))); + + return xhrRequest('/__echo/xhr', { + cacheBust: true + }); + }) + .then(function(response: any) { + cacheBustStringB = response.url.split('?')[1]; + assert.ok(cacheBustStringB); + assert.isFalse(isNaN(Number(cacheBustStringB))); + assert.notEqual(cacheBustStringA, cacheBustStringB); + }); + } + }, + + headers: { + 'normalize header names'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/normalize', { + headers: { + 'CONTENT-TYPE': 'arbitrary-value', + 'X-REQUESTED-WITH': 'test' + } + }).then(function(response: any) { + return response.json().then((data: any) => { + assert.isUndefined(data.headers['CONTENT-TYPE']); + assert.propertyVal(data.headers, 'content-type', 'arbitrary-value'); + + assert.isUndefined(data.headers['X-REQUESTED-WITH']); + assert.propertyVal(data.headers, 'x-requested-with', 'test'); + }); + }); + }, + + 'custom headers'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/custom', { + headers: { + 'Content-Type': 'application/arbitrary-value' + } + }) + .then(function(response: any) { + return response.json().then((data: any) => { + assert.propertyVal(data.headers, 'content-type', 'application/arbitrary-value'); + + return xhrRequest('/__echo/custom', { + headers: { + Range: 'bytes=0-1024' + } + }); + }); + }) + .then((response: any) => { + return response.json().then((data: any) => { + assert.isDefined(data.headers, 'range'); + }); + }); + }, + + 'default headers'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + const options = has('formdata') ? { body: new FormData() } : {}; + return xhrRequest('/__echo/default', options).then(function(response: any) { + return response.json().then((data: any) => { + assert.strictEqual(data.headers['x-requested-with'], 'XMLHttpRequest'); + if (has('formdata')) { + assert.include(data.headers['content-type'], 'application/x-www-form-urlencoded'); + } + }); + }); + }, + + 'X-Requested-With headers can be disabled'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + const options = { includeRequestedWithHeader: false }; + return xhrRequest('/__echo/default?norequestedwith', options).then(function(response: any) { + return response.json().then((data: any) => { + assert.isUndefined(data.headers['x-requested-with']); + }); + }); + } + } + }, + + 'response object': { + properties(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/foo.json').then(function(response: XhrResponse) { + assert.strictEqual(response.status, 200); + assert.strictEqual(response.statusText, 'OK'); + assert.isTrue(response.nativeResponse instanceof XMLHttpRequest); + assert.strictEqual(response.url, '/__echo/foo.json'); + assert.deepEqual(response.requestOptions, { method: 'GET' }); + }); + }, + + '.header'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + return xhrRequest('/__echo/foo.json').then(function(response: any) { + return response.text().then((data: any) => { + const length: number = Number(response.headers.get('content-length')); + assert.strictEqual(length, data.length); + }); + }); + }, + + 'body cannot be used twice'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + + return xhrRequest('/__echo/foo.json').then((response: any) => { + assert.isFalse(response.bodyUsed); + + return response.text().then(() => { + assert.isTrue(response.bodyUsed); + + return response.text().then( + () => { + throw new Error('should not have succeeded'); + }, + () => { + return 'success'; + } + ); + }); + }); + }, + + 'response types': { + arrayBuffer(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + + if (!has('blob') || !has('arraybuffer')) { + this.skip('ArrayBuffer not available'); + } + + return xhrRequest('/__echo/foo.json').then((response: any) => { + return response.arrayBuffer().then((arrayBuffer: any) => { + assert.isTrue(arrayBuffer instanceof ArrayBuffer); + }); + }); + }, + + blob(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + + if (!has('blob')) { + this.skip('Blob not available'); + } + + return xhrRequest('/__echo/foo.json').then((response: any) => { + return response.blob().then((blob: any) => { + assert.isTrue(blob instanceof Blob); + }); + }); + }, + + formData(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + + if (!has('formdata')) { + this.skip('FormData is not available'); + } + + return xhrRequest('/__echo/foo.json').then((response: any) => { + return response.formData().then((formData: any) => { + assert.isTrue(formData instanceof FormData); + }); + }); + }, + + xml(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + + return xhrRequest('/__echo/xhr?responseType=xml').then((response: any) => { + return response.xml().then((xml: any) => { + assert.isTrue(xml instanceof Document); + }); + }); + } + }, + + 'response progress': { + 'data event'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + + let timesCalled = 0; + + return xhrRequest('/__echo/foo.json').then((response) => { + response.data.subscribe((chunk) => { + assert.isNotNull(chunk); + timesCalled++; + }); + + return response.text().then(() => { + assert.equal(timesCalled, 1); + }); + }); + }, + + 'download event'(this: any) { + if (!echoServerAvailable) { + this.skip('No echo server available'); + } + + let downloadEvents: number[] = []; + + return xhrRequest('/__echo/foo.json').then((response) => { + response.download.subscribe((totalBytesDownloaded) => { + downloadEvents.push(totalBytesDownloaded); + }); + + return response.text().then(() => { + assert.isTrue(downloadEvents.length > 0); + }); + }); + } + } + }, + + 'Web Workers': { + 'from blob'(this: any) { + if (!has('web-worker-xhr-upload')) { + this.skip('No web worker upload support'); + } + + const testUrl = location.origin + '/__echo/foo.json'; + const baseUrl = location.origin; + const dfd = this.async(); + + const blob = new Blob( + [ + `(function() { +self.addEventListener('message', function (event) { + testXhr(event.data.baseUrl, event.data.testUrl); +}); + +function testXhr(baseUrl, testUrl) { + importScripts(baseUrl + '/node_modules/@dojo/loader/loader.js', baseUrl + '/node_modules/@dojo/shim/util/amd.js'); + + require.config(shimAmdDependencies({ + baseUrl: baseUrl + })); + + require(['@dojo/shim/main', '_build/src/request/providers/xhr'], function (_, xhr) { + xhr.default(testUrl).then(function (response) { + return response.json(); + }).then(function (json) { + self.postMessage({ status: 'success' }); + }).catch(function (e) { + self.postMessage({ status: 'error', message: e.message }); + }); + }); +} + })()` + ], + { type: 'application/javascript' } + ); + const worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('error', (error) => { + dfd.reject(error.message); + }); + worker.addEventListener('message', ({ data: result }) => { + const { status } = result; + + if (status === 'success') { + dfd.resolve(); + } else if (status === 'error') { + dfd.reject(result.message); + } + }); + + worker.postMessage({ + baseUrl, + testUrl + }); + } + } + } +}); diff --git a/src/lib/core/tests/unit/request_browser.ts b/src/lib/core/tests/unit/request_browser.ts new file mode 100644 index 0000000..c057000 --- /dev/null +++ b/src/lib/core/tests/unit/request_browser.ts @@ -0,0 +1,23 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import request from '../../src/request'; +import { AmdRequire } from '../../src/interfaces'; + +declare const require: AmdRequire; + +const getRequestUrl = function(dataKey: string): string { + return require.toUrl('../support/data/' + dataKey); +}; + +registerSuite('request_browser', { + '.get'() { + return request + .get(getRequestUrl('foo.json')) + .then((response) => { + return response.json(); + }) + .then((json) => { + assert.deepEqual(json, { foo: 'bar' }); + }); + } +}); diff --git a/src/lib/core/tests/unit/request_node.ts b/src/lib/core/tests/unit/request_node.ts new file mode 100644 index 0000000..bf26f2b --- /dev/null +++ b/src/lib/core/tests/unit/request_node.ts @@ -0,0 +1,96 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import request from '../../src/request'; +import node from '../../src/request/providers/node'; +import { createServer } from 'http'; +import { parse } from 'url'; + +request.setDefaultProvider(node); + +let handle: any; + +const serverPort = 8124; +const serverUrl = 'http://localhost:' + serverPort; +let server: any; + +let getRequestUrl = function(dataKey: string): string { + return serverUrl + '?dataKey=' + dataKey; +}; + +registerSuite('request node', { + before(this: any) { + const dfd = this.async(); + const responseData: { [name: string]: any } = { + 'foo.json': new Buffer(JSON.stringify({ foo: 'bar' }), 'utf8'), + invalidJson: new Buffer('JSON', 'utf8') + }; + + function getResponseData(request: any) { + const urlInfo = parse(request.url, true); + return responseData[urlInfo.query.dataKey as string]; + } + + server = createServer(function(request, response) { + const body = getResponseData(request); + + response.writeHead(200, { + 'Content-Type': 'application/json' + }); + response.write(body); + + response.end(); + }); + + server.on('listening', dfd.resolve.bind(dfd)); + server.listen(serverPort); + + return dfd.promise; + }, + + after() { + server.close(); + }, + + afterEach() { + if (handle) { + handle.destroy(); + handle = null; + } + }, + + tests: { + '.get': { + 'simple request'(this: any) { + return request + .get(getRequestUrl('foo.json')) + .then((response) => { + return response.text(); + }) + .then((text) => { + assert.equal(String(text), JSON.stringify({ foo: 'bar' })); + }); + }, + + 'custom headers'(this: any) { + const options = { headers: { 'Content-Type': 'application/json' } }; + return request.get(getRequestUrl('foo.json'), options).then((response) => { + return response.text().then((text) => { + assert.equal(String(text), JSON.stringify({ foo: 'bar' })); + assert.equal(response.headers.get('content-type'), 'application/json'); + }); + }); + } + }, + + 'JSON responseType filter'() { + return request + .get(getRequestUrl('foo.json')) + .then((response) => { + return response.json(); + }) + .then((json) => { + assert.deepEqual(json, { foo: 'bar' }); + }); + } + } +}); diff --git a/src/lib/core/tests/unit/stringExtras.ts b/src/lib/core/tests/unit/stringExtras.ts new file mode 100644 index 0000000..c0aca62 --- /dev/null +++ b/src/lib/core/tests/unit/stringExtras.ts @@ -0,0 +1,24 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import * as stringExtras from '../../src/stringExtras'; + +registerSuite('string functions', { + '.escapeRegExp()'() { + assert.strictEqual(stringExtras.escapeRegExp(''), ''); + assert.strictEqual( + stringExtras.escapeRegExp('[]{}()|/\\^$.*+?'), + '\\[\\]\\{\\}\\(\\)\\|\\/\\\\\\^\\$\\.\\*\\+\\?' + ); + }, + + '.escapeXml()'() { + let html = '

Fox & Hound\'s

'; + + assert.strictEqual(stringExtras.escapeXml(''), ''); + assert.strictEqual(stringExtras.escapeXml(html, false), '<p class="text">Fox & Hound\'s</p>'); + assert.strictEqual( + stringExtras.escapeXml(html), + '<p class="text">Fox & Hound's</p>' + ); + } +}); diff --git a/src/lib/core/tests/unit/text.ts b/src/lib/core/tests/unit/text.ts new file mode 100644 index 0000000..be7e5d9 --- /dev/null +++ b/src/lib/core/tests/unit/text.ts @@ -0,0 +1,74 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import has from '../../src/has'; +import * as text from '../../src/text'; +import { stub } from 'sinon'; +import { AmdRootRequire } from '../../src/interfaces'; + +declare const require: AmdRootRequire; + +// The exported get function from the text module +// uses fs.readFile on node systems, which resolves +// paths differently than request, which can and +// should be used internally for browser environments. +// As such, this determines the appropriate base path +// for get tests. +const basePath = (function() { + if (has('host-browser')) { + return '../../_build/tests/support/data/'; + } else if (has('host-node')) { + return './_build/tests/support/data/'; + } +})(); +const absPathMock = (val: string) => val; + +registerSuite('text', { + get(this: any) { + text.get(basePath + 'correctText.txt').then( + this.async().callback(function(text: string) { + assert.strictEqual(text, 'abc'); + }) + ); + }, + + normalize: { + 'calls absMid function for relative path'() { + const absMidStub = stub().returns('test'); + text.normalize('./test', absMidStub); + assert.isTrue(absMidStub.calledOnce, 'Abs mid function should be called'); + }, + 'does not call absMid function for abs path'() { + const absMidStub = stub().returns('test'); + text.normalize('test', absMidStub); + assert.isFalse(absMidStub.called, 'Abs mid function should not be called'); + }, + 'should return passed strip flag for relative path'() { + const normalized = text.normalize('./test!strip', absPathMock); + assert.include(normalized, '!strip', 'Strip flag should be present'); + }, + 'should return passed strip flag for abs path'() { + const normalized = text.normalize('test!strip', absPathMock); + assert.include(normalized, '!strip', 'Strip flag should be present'); + } + }, + load: { + 'should strip xml'(this: any) { + text.load( + '../support/data/strip.xml!strip', + require, + this.async().callback((val: string) => { + assert.strictEqual(val, 'abc', 'Should have stripped the XML'); + }) + ); + }, + 'should strip html'(this: any) { + text.load( + '../support/data/strip.html!strip', + require, + this.async().callback((val: string) => { + assert.strictEqual(val, 'abc', 'Should have stripped the XML'); + }) + ); + } + } +}); diff --git a/src/lib/core/tests/unit/text_browser.ts b/src/lib/core/tests/unit/text_browser.ts new file mode 100644 index 0000000..4ae2e54 --- /dev/null +++ b/src/lib/core/tests/unit/text_browser.ts @@ -0,0 +1,20 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import * as text from '../../src/text'; +import { AmdRootRequire } from '../../src/interfaces'; + +declare const require: AmdRootRequire; + +registerSuite('text - browser', { + load: { + 'should return text'(this: any) { + text.load( + '../support/data/textLoad.txt', + require, + this.async().callback((val: string) => { + assert.strictEqual(val, 'test', 'Correct text should be returned'); + }) + ); + } + } +}); diff --git a/src/lib/core/tests/unit/text_node.ts b/src/lib/core/tests/unit/text_node.ts new file mode 100644 index 0000000..480a6ab --- /dev/null +++ b/src/lib/core/tests/unit/text_node.ts @@ -0,0 +1,46 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import * as text from '../../src/text'; +import { spy, SinonSpy } from 'sinon'; +import * as fs from 'fs'; +import { AmdRootRequire } from '../../src/interfaces'; + +declare const require: AmdRootRequire; + +const basePath = '_build/tests/support/data/'; +let fsSpy: SinonSpy; + +registerSuite('text - node', { + load: { + beforeEach() { + fsSpy = spy(fs, 'readFile'); + }, + + afterEach() { + fsSpy.restore && fsSpy.restore(); + }, + + tests: { + 'should return text and call fs'(this: any) { + text.load( + basePath + 'textLoad.txt', + require, + this.async().callback((val: string) => { + assert.isTrue(fsSpy.calledOnce, 'Read file should be called once'); + assert.strictEqual(val, 'test', 'Correct text should be returned'); + }) + ); + }, + 'should return text from cache'(this: any) { + text.load( + basePath + 'textLoad.txt', + require, + this.async().callback((val: string) => { + assert.isTrue(fsSpy.notCalled, 'Read file should not be called'); + assert.strictEqual(val, 'test', 'Correct text should be returned'); + }) + ); + } + } + } +}); diff --git a/src/lib/core/tests/unit/util.ts b/src/lib/core/tests/unit/util.ts new file mode 100644 index 0000000..b03c03a --- /dev/null +++ b/src/lib/core/tests/unit/util.ts @@ -0,0 +1,333 @@ +/* tslint:disable:no-var-keyword */ + +/* + * While setTimeout and setInterval work well enough for typical application demands on reasonably modern computers, + * JavaScript runtimes make no guarantee of timely execution. The delay passed to these functions only guarantees + * that the callback will not be executed before the specified delay has elapsed. There is no guarantee of how promptly + * the callback will be executed after the delay. + * + * Given this situation it is best to avoid automated tests that assume timely execution of delayed callbacks. This + * is especially relevant in cloud testing services where the resources allocated for the test machine may be + * severely limited, causing unexpected test failures. + * + * Additionally, while it is very convenient in test code to use setTimeout to schedule something at a certain time + * or to see if something has transpired after a certain interval, it should be avoided when possible due to its + * unreliability. + * + * Further discussion: https://github.com/dojo/core/issues/107 + */ + +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); +import * as sinon from 'sinon'; +import { Handle } from '../../src/interfaces'; +import * as util from '../../src/util'; + +const TIMEOUT = 3000; +let timerHandle: Handle | null; + +function destroyTimerHandle() { + if (timerHandle) { + timerHandle.destroy(); + timerHandle = null; + } +} + +registerSuite('utility functions', { + afterEach() { + destroyTimerHandle(); + }, + + tests: { + createTimer: { + destroy(this: any) { + const dfd = this.async(1000); + const spy = sinon.spy(); + timerHandle = util.createTimer(spy, 100); + + setTimeout(function() { + destroyTimerHandle(); + }, 50); + + setTimeout( + dfd.callback(function() { + assert.strictEqual(spy.callCount, 0); + }), + 110 + ); + }, + + timeout(this: any) { + const dfd = this.async(1000); + const spy = sinon.spy(); + timerHandle = util.createTimer(spy, 100); + + setTimeout( + dfd.callback(function() { + assert.strictEqual(spy.callCount, 1); + }), + 110 + ); + } + }, + + guaranteeMinimumTimeout: { + destroy(this: any) { + const dfd = this.async(1000); + const spy = sinon.spy(); + timerHandle = util.guaranteeMinimumTimeout(spy, 100); + + setTimeout(function() { + destroyTimerHandle(); + }, 50); + + setTimeout( + dfd.callback(function() { + assert.strictEqual(spy.callCount, 0); + }), + 110 + ); + }, + + timeout(this: any) { + const dfd = this.async(1000); + const startTime = Date.now(); + timerHandle = util.guaranteeMinimumTimeout( + dfd.callback(function() { + const dif = Date.now() - startTime; + assert.isTrue(dif >= 100, 'Delay was ' + dif + 'ms.'); + }), + 100 + ); + }, + + 'timeout no delay'(this: any) { + const dfd = this.async(1000); + timerHandle = util.guaranteeMinimumTimeout( + dfd.callback(function() { + // test will timeout if not called + }) + ); + }, + + 'timeout zero delay'(this: any) { + const dfd = this.async(1000); + timerHandle = util.guaranteeMinimumTimeout( + dfd.callback(function() { + // test will timeout if not called + }), + 0 + ); + } + }, + + debounce: { + 'preserves context'(this: any) { + const dfd = this.async(TIMEOUT); + // FIXME + let foo = { + bar: util.debounce( + dfd.callback(function(this: any) { + assert.strictEqual(this, foo, 'Function should be executed with correct context'); + }), + 0 + ) + }; + + foo.bar(); + }, + + 'receives arguments'(this: any) { + const dfd = this.async(TIMEOUT); + const testArg1 = 5; + const testArg2 = 'a'; + const debouncedFunction = util.debounce( + dfd.callback(function(a: number, b: string) { + assert.strictEqual(a, testArg1, 'Function should receive correct arguments'); + assert.strictEqual(b, testArg2, 'Function should receive correct arguments'); + }), + 0 + ); + + debouncedFunction(testArg1, testArg2); + }, + + 'debounces callback'(this: any) { + const dfd = this.async(TIMEOUT); + const debouncedFunction = util.debounce( + dfd.callback(function() { + assert.isAbove( + Date.now() - lastCallTick, + 10, + 'Function should not be called until period has elapsed without further calls' + ); + + // Typically, we expect the 3rd invocation to be the one that is executed. + // Although the setTimeout in 'run' specifies a delay of 5ms, a very slow test environment may + // take longer. If 25+ ms has actually elapsed, then the first or second invocation may end up + // being eligible for execution. + }), + 25 + ); + + let runCount = 1; + let lastCallTick: number; + + function run() { + lastCallTick = Date.now(); + debouncedFunction(); + runCount += 1; + + if (runCount < 4) { + setTimeout(run, 5); + } + } + + run(); + } + }, + + throttle: { + 'preserves context'(this: any) { + const dfd = this.async(TIMEOUT); + // FIXME + const foo = { + bar: util.throttle( + dfd.callback(function(this: any) { + assert.strictEqual(this, foo, 'Function should be executed with correct context'); + }), + 0 + ) + }; + + foo.bar(); + }, + + 'receives arguments'(this: any) { + const dfd = this.async(TIMEOUT); + const testArg1 = 5; + const testArg2 = 'a'; + const throttledFunction = util.throttle( + dfd.callback(function(a: number, b: string) { + assert.strictEqual(a, testArg1, 'Function should receive correct arguments'); + assert.strictEqual(b, testArg2, 'Function should receive correct arguments'); + }), + 0 + ); + + throttledFunction(testArg1, testArg2); + }, + + 'throttles callback'(this: any) { + const dfd = this.async(TIMEOUT); + let callCount = 0; + let cleared = false; + const throttledFunction = util.throttle( + dfd.rejectOnError(function(a: string) { + callCount++; + assert.notStrictEqual(a, 'b', 'Second invocation should be throttled'); + // Rounding errors? + // Technically, the time diff should be greater than 24ms, but in some cases + // it is equal to 24ms. + assert.isAbove( + Date.now() - lastRunTick, + 23, + 'Function should not be called until throttle delay has elapsed' + ); + + lastRunTick = Date.now(); + if (callCount > 1) { + destroyTimerHandle(); + cleared = true; + dfd.resolve(); + } + }), + 25 + ); + + let runCount = 1; + let lastRunTick = 0; + + function run() { + throttledFunction('a'); + throttledFunction('b'); + runCount += 1; + + if (runCount < 10 && !cleared) { + timerHandle = util.guaranteeMinimumTimeout(run, 5); + } + } + + run(); + assert.strictEqual(callCount, 1, 'Function should be called as soon as it is first invoked'); + } + }, + + throttleAfter: { + 'preserves context'(this: any) { + const dfd = this.async(TIMEOUT); + // FIXME + const foo = { + bar: util.throttleAfter( + dfd.callback(function(this: any) { + assert.strictEqual(this, foo, 'Function should be executed with correct context'); + }), + 0 + ) + }; + + foo.bar(); + }, + + 'receives arguments'(this: any) { + const dfd = this.async(TIMEOUT); + const testArg1 = 5; + const testArg2 = 'a'; + const throttledFunction = util.throttleAfter( + dfd.callback(function(a: number, b: string) { + assert.strictEqual(a, testArg1, 'Function should receive correct arguments'); + assert.strictEqual(b, testArg2, 'Function should receive correct arguments'); + }), + 0 + ); + + throttledFunction(testArg1, testArg2); + }, + + 'throttles callback'(this: any) { + const dfd = this.async(TIMEOUT); + + let callCount = 0; + let lastRunTick = 0; + const throttledFunction = util.throttleAfter( + dfd.rejectOnError(function(a: string) { + callCount++; + assert.notStrictEqual(a, 'b', 'Second invocation should be throttled'); + assert.isAbove( + Date.now() - lastRunTick, + 23, + 'Function should not be called until throttle delay has elapsed' + ); + + lastRunTick = Date.now(); + if (callCount > 2) { + destroyTimerHandle(); + dfd.resolve(); + } + }), + 25 + ); + + function run() { + throttledFunction('a'); + throttledFunction('b'); + + timerHandle = util.guaranteeMinimumTimeout(dfd.rejectOnError(run), 5); + } + + run(); + assert.strictEqual(callCount, 0, 'Function should not be called as soon as it is first invoked'); + } + } + } +}); diff --git a/src/lib/core/tests/unit/uuid.ts b/src/lib/core/tests/unit/uuid.ts new file mode 100644 index 0000000..2ff665b --- /dev/null +++ b/src/lib/core/tests/unit/uuid.ts @@ -0,0 +1,24 @@ +const { registerSuite } = intern.getInterface('object'); +const { assert } = intern.getPlugin('chai'); + +import uuid from '../../src/uuid'; + +registerSuite('uuid functions', { + 'v4 uuid'() { + const firstId = uuid(); + + assert.isDefined(firstId); + assert.match( + firstId, + new RegExp('^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$', 'ig') + ); + + const secondId = uuid(); + + assert.match( + secondId, + new RegExp('^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$', 'ig') + ); + assert.notEqual(firstId, secondId); + } +}); diff --git a/src/lib/core/tsconfig.json b/src/lib/core/tsconfig.json new file mode 100644 index 0000000..0e5869d --- /dev/null +++ b/src/lib/core/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "declaration": true, + "downlevelIteration": true, + "experimentalDecorators": true, + "importHelpers": true, + "lib": [ + "dom", + "es5", + "es2015.iterable", + "es2015.promise", + "es2015.symbol", + "es2015.symbol.wellknown" + ], + "module": "umd", + "moduleResolution": "node", + "noUnusedLocals": true, + "outDir": "_build/", + "removeComments": false, + "sourceMap": true, + "strict": true, + "target": "es5", + "types": [ "intern" ] + }, + "include": [ + "./src/**/*.ts", + "./tests/**/*.ts" + ] +} + diff --git a/src/lib/core/tslint.json b/src/lib/core/tslint.json new file mode 100644 index 0000000..0c51601 --- /dev/null +++ b/src/lib/core/tslint.json @@ -0,0 +1,60 @@ +{ + "rules": { + "align": false, + "ban": [], + "class-name": true, + "comment-format": [ true, "check-space" ], + "curly": true, + "eofline": true, + "forin": false, + "indent": [ true, "tabs" ], + "interface-name": [ true, "never-prefix" ], + "jsdoc-format": true, + "label-position": true, + "max-line-length": 120, + "member-access": false, + "member-ordering": false, + "no-any": false, + "no-arg": true, + "no-bitwise": false, + "no-consecutive-blank-lines": true, + "no-console": false, + "no-construct": false, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-inferrable-types": [ true, "ignore-params" ], + "no-shadowed-variable": false, + "no-string-literal": false, + "no-switch-case-fall-through": false, + "no-trailing-whitespace": true, + "no-unused-expression": false, + "no-use-before-declare": false, + "no-var-keyword": true, + "no-var-requires": false, + "object-literal-sort-keys": false, + "one-line": [ true, "check-open-brace", "check-whitespace" ], + "radix": true, + "trailing-comma": [ true, { + "multiline": "never", + "singleline": "never" + } ], + "triple-equals": [ true, "allow-null-check" ], + "typedef": false, + "typedef-whitespace": [ true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + } ], + "variable-name": [ true, "check-format", "allow-leading-underscore", "ban-keywords" ] + } +} diff --git a/src/lib/fs/index.ts b/src/lib/fs/index.ts new file mode 100644 index 0000000..93126e8 --- /dev/null +++ b/src/lib/fs/index.ts @@ -0,0 +1,99 @@ +const fg = require('fast-glob'); + +import * as path from 'path'; +import * as bluebird from 'bluebird'; +import { Converter } from 'showdown'; +import { sync as read } from '@plastichub/fs/read'; +import { sync as exists } from '@plastichub/fs/exists'; +import { html_beautify } from 'js-beautify'; + +export { sync as read } from '@plastichub/fs/read'; +export { sync as exists } from '@plastichub/fs/exists'; +export { sync as dir } from '@plastichub/fs/dir'; +export { sync as write } from '@plastichub/fs/write'; + +import { sync as write } from '@plastichub/fs/write'; + +import { Helper } from '../process/index'; +import { firstOf, lastOf } from '../common/array'; +import { img } from '../content/html'; + +const IMAGES_GLOB = '*.+(JPG|jpg|png|PNG|gif)'; + +export const files = (dir, glob) => fg.sync(glob, { dot: true, cwd: dir, absolute: true }) as []; +export const images = (source) => files(source, IMAGES_GLOB) as any[]; +export const head_image = (_images) => firstOf(_images); +export const tail_image = (_images) => lastOf(_images); + +export const forward_slash = (path) => { + const isExtendedLengthPath = /^\\\\\?\\/.test(path); + const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex + + if (isExtendedLengthPath || hasNonAscii) { + return path; + } + + return path.replace(/\\/g, '/'); +}; + +export async function resize_images(files) { + return bluebird.mapSeries(files, (file: string) => { + const inParts = path.parse(file); + const promise = Helper.run(inParts.dir, 'convert', + [ + `"${inParts.base}"`, + '-quality 70', + '-resize 1980', + '-sharpen 0x1.0', + `"${inParts.name}${inParts.ext}"` + ]); + return promise; + }); +} + +export const md2html = (content) => { + let converter = new Converter({ tables: true }); + converter.setOption('literalMidWordUnderscores', 'true'); + return converter.makeHtml(content); +} + + +export const toHTML = (path, markdown) => { + const content = read(path, 'string') as string; + if (!markdown) { + let converter = new Converter({ tables: true }); + converter.setOption('literalMidWordUnderscores', 'true'); + return converter.makeHtml(content); + } else { + return content; + } +} + +const jekyllNop = "---\n#jekyll\n---\n"; +const frontMatter = /^---[.\r\n]*---/; + +export const thumbs = (source: string, meta: boolean = true, sep: string = "
") => { + let pictures = images(source); + let content = ""; + pictures.forEach((f, i) => { + if (meta) { + let picMD = path.resolve(path.join(path.parse(f).dir, path.sep, path.parse(f).name + '.md')); + if (exists(picMD)) { + const picMDContent = read(picMD, "string") as string; + if (picMDContent.length > 3 && picMDContent !== jekyllNop) { + content += picMDContent.substr(picMDContent.lastIndexOf('---') + 3, picMDContent.length) + content += "\n"; + } else { + write(picMD, jekyllNop); + } + } else { + write(picMD, jekyllNop); + } + } + + content += img(`./${path.parse(f).base}`, `${i + 1}. `, path.parse(f).base); + content += "\n"; + content += sep; + }); + return html_beautify(content); +} \ No newline at end of file diff --git a/src/lib/git/log.ts b/src/lib/git/log.ts new file mode 100644 index 0000000..4290f23 --- /dev/null +++ b/src/lib/git/log.ts @@ -0,0 +1,40 @@ +import { write, exists, read, thumbs, images, resize_images, tail_image, howto_header, substitute, toHTML, parse_config, read_fragments } from '../../lib/'; +import * as debug from '../..'; +import { GIT_CHANGELOG_MESSAGE_PREFIX } from '../../constants'; +import * as path from 'path'; + +import * as simpleGit from 'simple-git/promise'; +import { SimpleGit } from 'simple-git'; +import * as moment from 'moment'; + +export async function git_status(cwd, dir) { + + const git: SimpleGit = simpleGit(cwd); + let statusSummary:any = null; + try { + statusSummary = await git.log(['--stat', path.resolve(dir)]); + } + catch (e) { + debug.error('Error Git', e); + } + return statusSummary; +} + +export async function git_log(cwd, dir) { + const stats = await git_status(cwd, dir); + debug.info(`Reading Git log at ${cwd}/${dir}`); + let changelogs = stats.all.filter((e) => e.message.trim().toLowerCase().startsWith(GIT_CHANGELOG_MESSAGE_PREFIX.toLowerCase())); + if (!changelogs.length) { + return { files: [], last:stats.latest } + } + let pretty = changelogs.map((e) => { + return { + files: e.diff.files.map((f) => { return { path: f.file } }), + msg: e.message.toLowerCase().replace(GIT_CHANGELOG_MESSAGE_PREFIX.toLowerCase(), '').trim(), + hash: e.hash, + date: moment(e.date).format('LLLL') + } + }); + + return { files: pretty, last: stats.latest }; +}; \ No newline at end of file diff --git a/src/lib/index.ts b/src/lib/index.ts new file mode 100644 index 0000000..dff7983 --- /dev/null +++ b/src/lib/index.ts @@ -0,0 +1,9 @@ +export * from './fs'; +export * from './content/html'; +export * from './content/front'; + +export * from './content/md'; +export * from './common/strings'; +export * from './content/tables'; +export * from './common/array'; +export * from './git/log'; diff --git a/src/lib/lang/README.md b/src/lib/lang/README.md new file mode 100644 index 0000000..49509a7 --- /dev/null +++ b/src/lib/lang/README.md @@ -0,0 +1,48 @@ +### Simple interface for *filtrex*, a bison and Javascript based expression parser + + +This is packaged as AMD module. + + +```js + + /1. Simple version, just evaluate one expression two times with different variables + + // Input from user (e.g. search filter) + var expression = 'transactions <= 5 and abs(profit) > 20.5'; + + var parser = new Expression(); + + var aResult = parser.parse(expression,null,{ + variables:{ + transactions: 3, + profit:-40.5 + } + }); //returns 1 + + var aResult = parser.parse(expression,null,{ + variables :{ + transactions: 3, + profit:-14.5 + } + }); //returns 1 + + 2. more advanced example, thing of a console input with real time feedback and autocompletion + + var expression = 'send{{Volume+4}} my garbage string {{transactions*2/Volume}}'; + + var parser = new Expression(); + + + var aResult = parser.parse(expression, null, { + variables: { + Volume: 2, + transactions: 3 + }, + delimiters: { + begin: '{{', + end: '}}' + } + });//returns 'send6 my garbage string 3' neat ? + +``` diff --git a/src/lib/net/crawler.ts b/src/lib/net/crawler.ts new file mode 100644 index 0000000..fd1b3a0 --- /dev/null +++ b/src/lib/net/crawler.ts @@ -0,0 +1,302 @@ +import * as debug from "../../log"; +import * as path from 'path'; + +import { sync as write } from '@plastichub/fs/write'; +import { sync as dir } from '@plastichub/fs/dir'; +import { sync as exists } from '@plastichub/fs/exists'; +import slugify from "slugify"; +import * as download from 'download'; +var sanitize = require("sanitize-filename"); +import * as URL from 'url'; +const normalizeUrl = require('normalize-url'); + +const topicFolder = (title, cli, prefix) => { + const dst = path.resolve('' + cli.output || './' + '/topics/'); + if (!exists(dst)) { + dir(dst); + } + + const folder = path.resolve(dst + '/' + prefix + '/' + sanitize(slugify(title))); + if (!exists(folder)) { + dir(folder); + } + + return folder; +} + +async function downloadFiles(dst, urls) { + await Promise.all(urls.map((i) => { + if(!i || !i.substring){ + return false; + } + const f = i.substring(i.lastIndexOf('/') + 1); + const image = path.resolve(`${dst}/${f}`); + if (!exists(image)) { + try { + console.log(`download file ` + normalizeUrl(i)); + return download(normalizeUrl(i), dst); + } catch (e) { + debug.error('error download step image', e); + } + } + })); +} + +const Apify = require('apify'); + +export async function crawler(url: string = 'https://davehakkens.nl/community/forums/forum/precious-plastic/general/', cli, prefix) { + // Apify.openRequestQueue() is a factory to get a preconfigured RequestQueue instance. + // We add our first request to it - the initial page the crawler will visit. + const requestQueue = await Apify.openRequestQueue(); + await requestQueue.addRequest({ url: url }); + + // Create an instance of the PuppeteerCrawler class - a crawler + // that automatically loads the URLs in headless Chrome / Puppeteer. + const crawler = new Apify.PuppeteerCrawler({ + requestQueue, + + // Here you can set options that are passed to the Apify.launchPuppeteer() function. + launchPuppeteerOptions: { + // For example, by adding "slowMo" you'll slow down Puppeteer operations to simplify debugging + //slowMo: 500, + headless: true, + devtools: false + + }, + + // Stop crawling after several pages + maxRequestsPerCrawl: 50000, + maxConcurrency: 5, + // This function will be called for each URL to crawl. + // Here you can write the Puppeteer scripts you are familiar with, + // with the exception that browsers and pages are automatically managed by the Apify SDK. + // The function accepts a single parameter, which is an object with the following fields: + // - request: an instance of the Request class with information such as URL and HTTP method + // - page: Puppeteer's Page object (see https://pptr.dev/#show=api-class-page) + handlePageTimeoutSecs: 300, + gotoTimeoutSecs: 300, + handlePageFunction: async ({ request, page }) => { + + console.log(`Processing ${request.url}...`); + + let isIndex = request.url.indexOf('forums/forum') !== -1; + + // A function to be evaluated by Puppeteer within the browser context. + + const pageFunctionTopic = () => { + + let nextPages = []; + let data = {}; + const $ = window['jQuery']; + const jQuery = $; + let title; + let authorLink; + let postDate; + let postBody; + let authorName; + try { + title = $('#bbpress-forums > div.topic-lead > div.author > h1')[0].innerText; + } catch (e) { + debugger; + } + try { + + authorLink = $('#bbpress-forums > div.topic-lead > div.author > a:nth-child(5)').attr('href'); + authorName = $('#bbpress-forums > div.topic-lead > div.author > a:nth-child(5)')[0].innerText; + } catch (e) { + authorName = "anon"; + authorLink = "ban G" + + } + + postDate = $('#bbpress-forums > div.topic-lead > div.author > div.date')[0].innerText.split(' at')[0]; + postBody = $('#bbpress-forums > div.topic-lead > div.content').html(); + const likes = parseInt(jQuery('#bbpress-forums > div.topic-lead > div.actions > div > div.dav_topic_like')[0].innerText.split(' ')[0]); + const saved = parseInt(jQuery('#bbpress-forums > div.topic-lead > div.actions > div > div.dav_topic_favorit > span')[0].innerText.split(' ')[0]); + const nbReplies = parseInt(jQuery('#bbpress-forums > div.topic-lead > div.actions > div > div.dav_reply_topic > span')[0].innerText.split(' ')[0]); + const pics = []; + jQuery('.d4p-bbp-attachment > a').each((i, a) => { + pics.push(jQuery(a).attr('href').replace('?ssl=1', '')); + }); + const replies = []; + + + jQuery('#bbpress-forums > div.list-replies-container > div.list-replies > div.topic-reply').each((i, e) => { + try { + let replyDate; + let nbLikes + let avatar = jQuery('.author > a > img', e).attr('src').replace(' 2x', ''); + let user = jQuery('.content .replyheader .smallusername', e)[0].innerText || 'anonymous'; + replyDate = jQuery('.content .replyheader .reply-date', e)[0].innerText; + nbLikes = parseInt(jQuery('.content > div.wpulike.wpulike-heart > div > span', e)[0].innerText) || 0; + let authorUrl = jQuery('div.content > div.replyheader > div.smallusername > a', e).attr('href'); + jQuery('.content > div.wpulike.wpulike-heart', e).remove(); + jQuery('.content .replyheader', e).remove(); + + let replyBody = jQuery('.content', e).html(); + const replyPics = []; + jQuery('.d4p-bbp-attachment > a', e).each((i, a) => { + replyPics.push(jQuery(a).attr('href').replace('?ssl=1', '')); + }); + jQuery('.content .bbp-attachments', e).remove(); + replyBody = jQuery('.content', e).html(); + replies.push({ + authorUrl, + avatar, + user, + replyDate, + nbLikes, + replyBody, + replyPics + }); + + } catch (e) { + console.error('meah', e); + debugger; + } + }) + + let pagination = jQuery('#bbpress-forums > div.list-replies-container > div.bbp-pagination > div.bbp-pagination-links'); + if (pagination && pagination.children()) { + let c = pagination.children(); + for (let i = 0; i < c.length; i++) { + let b = $(c[i]); + if (b.attr("href")) { + nextPages.push(encodeURI(b.attr("href"))); + } + } + } + + const authorImage = jQuery("#bbpress-forums > div.topic-lead > div.author > a.bbp-author-avatar > img").attr("src"); + + data = { + url: window.location.href, + authorImage: authorImage, + // next pages to crawl, ('Set' removes duplicates) + nextPages: [...new Set(nextPages)], + body: postBody, + postDate, + likes, + saved, + nbReplies, + pics, + replies, + authorLink, + authorName, + title, + content: jQuery('body').html() + } + return data; + }; + + const pageFunctionIndex = () => { + let data = {}; + const $ = window['jQuery']; + const jQuery = $; + let nextPages = []; + jQuery('.bbp-topic-permalink').each((i, e) => { + nextPages.push(jQuery(e).attr("href")); + }); + let pagination = jQuery('.bbp-pagination-links'); + if (pagination && pagination.children()) { + let c = pagination.children(); + for (let i = 0; i < c.length; i++) { + let b = $(c[i]); + if (b.attr("href") && b.attr("href").length) { + nextPages.push(b.attr("href")); + } + } + } + data = { + nextPages: [...new Set(nextPages)] + } + return data; + }; + + if (!isIndex) { + + const data = await page.$$eval('return window', pageFunctionTopic); + + console.log('Process Topic : ', data.title); + + if (data.nextPages && data.nextPages.length) { + let q = []; + data.nextPages.forEach(element => { + if (element !== url) { + q.push(requestQueue.addRequest({ url: element })); + } + }); + await Promise.all(q); + } + + const dst = path.resolve('' + cli.output || './' + '/topics/'); + if (!exists(dst)) { + dir(dst); + } + + const folder = topicFolder(data.title, cli, prefix); + + let fileName = 'data'; + if (request.url.split('page').length == 2) { + fileName = fileName + "-" + parseInt(request.url.split('page')[1].replace('/', '')); + } + + fileName = fileName + ".json"; + + let dataPath = path.resolve(`${folder}/${fileName}`); + debug.info("write to ", dataPath); + + const content = data.content; + data.content = null; + write(dataPath, data, { jsonIndent: 1 }); + write(dataPath.replace('.json', '.html'), content); + + await downloadFiles(topicFolder(data.title, cli, prefix), data.pics); + + let pics = []; + data.replies.forEach(r => { + if (r.replyPics.length) { + pics = pics.concat(r.replyPics); + } + }); + await downloadFiles(topicFolder(data.title, cli, prefix), pics); + if (data.authorImage) { + await downloadFiles(path.resolve(cli.output + '/authors'), [data.authorImage]); + if (data.replies) { + await Promise.all(data.replies.map((i) => downloadFiles(path.resolve(cli.output + '/authors'), [i.authorLogo]))); + } + } + + + } else { + const data = await page.$$eval('return window', pageFunctionIndex); + if (data.nextPages && data.nextPages.length) { + let q = []; + data.nextPages.forEach(element => { + if (element !== url) { + q.push(requestQueue.addRequest({ url: element })); + } + }); + await Promise.all(q); + } + console.log('got forum index : ', data); + } + }, + + // This function is called if the page processing failed more than maxRequestRetries+1 times. + handleFailedRequestFunction: async ({ request }) => { + console.log(`Request ${request.url} failed too many times`); + await Apify.pushData({ + '#debug': Apify.utils.createRequestDebugInfo(request), + }); + }, + gotoFunction: async ({ page, request }) => { + return page.goto(request.url, { + waitUntil: 'domcontentloaded' + }); + } + }); + + // Run the crawler and wait for it to finish. + await crawler.run(); +}; diff --git a/src/lib/net/download.ts b/src/lib/net/download.ts new file mode 100644 index 0000000..b54ff66 --- /dev/null +++ b/src/lib/net/download.ts @@ -0,0 +1,104 @@ +'use strict'; +const fs = require('fs'); +const path = require('path'); +import { URL } from 'url'; +const contentDisposition = require('content-disposition'); +const archiveType = require('archive-type'); +const decompress = require('decompress'); +const filenamify = require('filenamify'); +const getStream = require('get-stream'); +const got = require('got'); +const makeDir = require('make-dir'); +const pify = require('pify'); +const pEvent = require('p-event'); +const fileType = require('file-type'); +const extName = require('ext-name'); + +const fsP = pify(fs); +const filenameFromPath = res => path.basename(new URL(res.requestUrl).pathname); + +const getExtFromMime = res => { + const header = res.headers['content-type']; + + if (!header) { + return null; + } + + const exts = extName.mime(header); + + if (exts.length !== 1) { + return null; + } + + return exts[0].ext; +}; + +const getFilename = (res, data) => { + const header = res.headers['content-disposition']; + + if (header) { + const parsed = contentDisposition.parse(header); + + if (parsed.parameters && parsed.parameters.filename) { + return parsed.parameters.filename; + } + } + + let filename = filenameFromPath(res); + + if (!path.extname(filename)) { + const ext = (fileType(data) || {}).ext || getExtFromMime(res); + + if (ext) { + filename = `${filename}.${ext}`; + } + } + + return filename; +}; + +export const download = (uri, output, opts?) => { + // console.log('download ' + uri, output); + if (typeof output === 'object') { + opts = output; + output = null; + } + + opts = Object.assign({ + encoding: null, + rejectUnauthorized: process.env.npm_config_strict_ssl !== 'false' + }, opts); + + const stream = got.stream(uri, opts); + + const promise = pEvent(stream, 'response').then(res => { + try { + const encoding = opts.encoding === null ? 'buffer' : opts.encoding; + return Promise.all([getStream(stream, { encoding }), res]); + } catch (e) { + console.error('error', e); + } + }).then(result => { + const [data, res] = result; + + if (!output) { + return opts.extract && archiveType(data) ? decompress(data, opts) : data; + } + + const filename = opts.filename || filenamify(getFilename(res, data)); + const outputFilepath = path.join(output, filename); + + if (opts.extract && archiveType(data)) { + return decompress(data, path.dirname(outputFilepath), opts); + } + + return makeDir(path.dirname(outputFilepath)) + .then(() => fsP.writeFile(outputFilepath, data)) + .then(() => data); + }); + + stream.then = promise.then.bind(promise); + stream.catch = promise.catch.bind(promise); + + return stream; +}; \ No newline at end of file diff --git a/src/lib/net/github.ts b/src/lib/net/github.ts new file mode 100644 index 0000000..3291e90 --- /dev/null +++ b/src/lib/net/github.ts @@ -0,0 +1,10 @@ +const jsdeliver = 'https://cdn.jsdelivr.net/' + +const user = 'plastichub'; +const repo = 'products'; +const branch = 'master'; + +const _gh_raw = (path) => `${jsdeliver}/gh/${user}/${repo}@${branch}/${path}`; + +export const gh_raw = (path) => _gh_raw(path); + diff --git a/src/lib/net/sheets.ts b/src/lib/net/sheets.ts new file mode 100644 index 0000000..22f6fec --- /dev/null +++ b/src/lib/net/sheets.ts @@ -0,0 +1,77 @@ +import * as readline from 'readline'; +import { google } from 'googleapis'; +import * as path from 'path'; +import { sync as readFile } from '@plastichub/fs/read'; +import { sync as writeFile } from '@plastichub/fs/write'; + +// https://developers.google.com/sheets/api/quickstart/nodejs +// If modifying these scopes, delete token.json. + +const SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']; +// The file token.json stores the user's access and refresh tokens, and is +// created automatically when the authorization flow completes for the first +// time. +const TOKEN_PATH = 'token.json'; + +/** + * Get and store new token after prompting for user authorization, and then + * execute the given callback with the authorized OAuth2 client. + * @param {google.auth.OAuth2} oAuth2Client The OAuth2 client to get token for. + * @param {getEventsCallback} callback The callback for the authorized client. + */ +const getNewToken = async (oAuth2Client) => { + const authUrl = oAuth2Client.generateAuthUrl({ + access_type: 'offline', + scope: SCOPES, + }); + console.log('Authorize this app by visiting this url:', authUrl); + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + rl.question('Enter the code from that page here: ', (code) => { + rl.close(); + oAuth2Client.getToken(code, (err, token: string) => { + if (err) return console.error('Error while trying to retrieve access token', err); + oAuth2Client.setCredentials(token); + // Store the token to disk for later program executions + writeFile(TOKEN_PATH, JSON.stringify(token, null, 2)); + return oAuth2Client; + }); + }); +} + +const readSheet = async (auth, sheet, range) => { + const sheets = google.sheets({ version: 'v4', auth }); + + const res = await sheets.spreadsheets.values.get({ + spreadsheetId: sheet, + range: range, + }); + return res.data.values; +} + +/** + * Create an OAuth2 client with the given credentials, and then execute the + * given callback function. + * @param {Object} credentials The authorization client credentials. + * @param {function} callback The callback to call with the authorized client. + */ +const authorize = async (credentials: any) => { + const { client_secret, client_id, redirect_uris } = credentials.installed; + const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]); + + const token = readFile(TOKEN_PATH, 'string') as string; + if (!token) { + return getNewToken(oAuth2Client); + } + + oAuth2Client.setCredentials(JSON.parse(token)); + return oAuth2Client; +} + +export const read = async (sheet: string, range: string) => { + const creds = readFile(path.resolve('credentials.json'), 'json'); + const client = await authorize(creds); + return await readSheet(client, sheet, range); +} \ No newline at end of file diff --git a/src/lib/process/index.ts b/src/lib/process/index.ts new file mode 100644 index 0000000..afe4983 --- /dev/null +++ b/src/lib/process/index.ts @@ -0,0 +1,136 @@ +import * as debug from '../../log'; +import * as stream from 'stream'; +import { ChildProcess, exec, spawn, spawnSync } from 'child_process'; +import { sync as which } from 'which'; +import * as path from 'path'; +import { os } from '../common/platform'; + +export enum STATUS { + OK, + ERROR, + PENDING +} + +const fatalHandler = (message: string, fn: (msg: string) => void): boolean => { + if (message.startsWith('fatal:')) { + fn('\t\ ' + message); + return true; + } + return false; +}; + +// tslint:disable-next-line:no-empty +const subscribe = (signal: stream.Readable, collector: (data: any) => void = () => { }) => { + const buffer: string[] = []; + signal.on('message', (message) => debug.debug('message', message)); + signal.on('error', (error) => debug.error('std-error', error)); + signal.on('data', (data) => { + const message = data.toString(); + buffer.push(message); // .replace(/[\x00-\x1F\x7F-\x9F]/g, "") + collector(buffer); + }); +}; +const merge = (buffer: string[], data: any): string[] => buffer.concat(data); +const hook = (process: ChildProcess, resolve: any, reject: any, cmd: string) => { + let buffer: string[] = []; + const collector = (data: any) => { buffer = buffer.concat(data); }; + const stdout = subscribe(process.stdout, collector); + const stderr = subscribe(process.stderr, collector); + process.on('exit', (code, signal) => { + if (code) { + resolve({ + code: STATUS.ERROR, + command: cmd, + error: code, + messages: buffer + }); + } else { + resolve({ + code: STATUS.OK, + command: cmd, + messages: buffer + }); + } + }); + return process; +}; + +export class Process { + public binary = 'magick'; + public cwd: string = ''; + public args: string = ''; + constructor(options: any = {}) { + this.binary = options.binary || this.binary; + //this.binary = path.resolve(which(this.binary)); + this.cwd = options.cwd || process.cwd(); + } + public optionsToString(options: any): string { + const args: any[] = []; + // tslint:disable-next-line:forin + for (const k in options) { + const val = options[k]; + if (k.length === 1) { + // val is true, add '-k' + if (val === true) { + args.push('-' + k); + } else if (val !== false) { + // if val is not false, add '-k val' + args.push('-' + k + ' ' + val); + } + } else { + if (val === true) { + args.push('--' + k); + } else if (val !== false) { + args.push('--' + k + '=' + val); + } + } + } + return args.join(' '); + } + public optionsToArray(options: any): string[] { + const args: any[] = []; + // tslint:disable-next-line:forin + for (const k in options) { + const val = options[k]; + if (k.length === 1) { + // val is true, add '-k' + if (val === true) { + args.push('-' + k); + } else if (val !== false) { + // if val is not false, add '-k val' + args.push('-' + k + ' ' + val); + } + } else { + if (val === true) { + args.push('--' + k); + } else if (val !== false) { + args.push('--' + k + '=' + val); + } + } + } + return args; + } + public async exec(command: string, options: any = {}, args: any[] = []): Promise { + args = [command].concat(args); + return new Promise((resolve, reject) => { + const p = exec(this.binary + ' ' + args.join(' '), { + cwd: this.cwd + }); + return hook(p, resolve, reject, this.binary + ' ' + args.join(' ')); + }); + } +} + +export class Helper { + public static async run(cwd, command: string, gitArgs: string[]): Promise { + const gitProcess = new Process({ + cwd: cwd, + binary: os() == 'windows' ? 'magick' : '' + }); + const p = gitProcess.exec(command, {}, gitArgs); + const spinner = debug.spinner('Run ' + command + ' with ' + gitArgs.join(' ')).start(); + p.then(() => spinner.stopAndPersist()); + p.catch((e) => debug.error('Error git command : ' + command)); + return p; + } +} \ No newline at end of file diff --git a/src/log.ts b/src/log.ts new file mode 100644 index 0000000..cec65c3 --- /dev/null +++ b/src/log.ts @@ -0,0 +1,18 @@ +import { default as chalk } from 'chalk'; +import * as util from 'util'; +import * as _ora from 'ora'; +// tslint:disable-next-line:no-var-requires +const jsome = require('jsome'); +jsome.level.show = true; +const glog = console.log; +export const log = (msg: string, ...rest: any[]) => glog(chalk.magenta(msg), ...rest); +export const info = (msg: string, ...rest) => glog(chalk.green(msg), ...rest); +export const error = (msg: string, ...rest: any[]) => glog(chalk.red(msg), ...rest); +export const warn = (msg: string, ...rest) => glog(chalk.yellow(msg), ...rest); +export const debug = (msg: string, ...rest) => glog(chalk.blue(msg), ...rest); +export const stack = (msg: string, ...rest) => glog(chalk.red(msg), new Error().stack); +export const inspect = (msg: string, d: any = null) => { + glog(chalk.blue(msg)); + d && jsome(d); +}; +export const spinner = (msg: string): any => _ora(msg); diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..1b3ed58 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,36 @@ +#!/usr/bin/env node +import { defaults } from './_cli'; defaults(); + +import * as cli from 'yargs'; +import { register as registerMarkdown } from './commands/markdown'; registerMarkdown(cli); +import { register as registerPDF2JPG } from './commands/pdf2jpg'; registerPDF2JPG(cli); +import { register as registerSVG2JPG } from './commands/svg2jpg'; registerSVG2JPG(cli); +import { register as registerWatch } from './commands/watch'; registerWatch(cli); +import { register as registerAcademy } from './commands/academy'; registerAcademy(cli); +import { register as registerOneArmy } from './commands/forumDownloader'; registerOneArmy(cli); +import { register as registerTest } from './commands/tests'; registerTest(cli); +import { register as registerV4Bom } from './commands/v4/bom'; registerV4Bom(cli); +import { register as registerBazarProduct } from './commands/bazar/product'; registerBazarProduct(cli); +import { register as registerBazarVendor } from './commands/bazar/vendor'; registerBazarVendor(cli); +import { register as registerLibrary } from './commands/library'; registerLibrary(cli); +import { register as registerSanitize } from './commands/common/sanitize-filename'; registerSanitize(cli); +import { register as registerGHPIndex } from './commands/github/jekyll_machine'; registerGHPIndex(cli); +import { register as registerGHProduct } from './commands/github/jekyll_product'; registerGHProduct(cli); +import { register as registerProductDataSheet } from './commands/github/jekyll_product_datasheet'; registerProductDataSheet(cli); +import { register as registerGHProjectIndex } from './commands/github/project_index'; registerGHProjectIndex(cli); +import { register as registerMD_Thumbs } from './commands/github/md_thumbs'; registerMD_Thumbs(cli); +import { register as registerMD_Page } from './commands/github/page'; registerMD_Page(cli); +import { register as registerHowtoBackup } from './commands/howto'; registerHowtoBackup(cli); +import { register as registerOADownload } from './commands/onearmy/download'; registerOADownload(cli); +import { register as registerDiscourse } from './commands/forum/discourse'; registerDiscourse(cli); + +const argv = cli.argv; + +if (argv.h || argv.help) { + cli.showHelp(); + process.exit(); +} else if (argv.v || argv.version) { + // tslint:disable-next-line:no-var-requires + const pkginfo = require('../package.json'); + process.exit(); +} diff --git a/src/os/context_menu/register_cli.ts b/src/os/context_menu/register_cli.ts new file mode 100644 index 0000000..0ddcc45 --- /dev/null +++ b/src/os/context_menu/register_cli.ts @@ -0,0 +1,106 @@ +const Registry = require('rage-edit').Registry; + +const SOFTWARE_CLASSES = 'HKCU\\Software\\Classes\\'; + +export const registerCommand = async options => { + if (!options) throw new Error('options are empty'); + + const { name, icon, command, menu } = options; + if (!name) throw new Error('name is not specified'); + if (!command) throw new Error('command is not specified'); + if (!menu) throw new Error('menuName is not specified'); + + try { + await Registry.set(`${SOFTWARE_CLASSES}*\\shell\\${name}`); + await Registry.set(`${SOFTWARE_CLASSES}*\\shell\\${name}`, '', menu); + if (icon) await Registry.set(`${SOFTWARE_CLASSES}*\\shell\\${name}`, 'Icon', (icon.endsWith('.exe') ? `${icon},0` : icon)); + await Registry.set(`${SOFTWARE_CLASSES}*\\shell\\${name}\\command`, '', `"${command}" "%1"`); + } catch (e) { + return Promise.reject(e); + } + + return Promise.resolve(); +}; + +export const registerDirectoryCommand = async options => { + if (!options) throw new Error('options are empty'); + + const { name, icon, command, menu } = options; + if (!name) throw new Error('name is not specified'); + if (!command) throw new Error('command is not specified'); + if (!menu) throw new Error('menu is not specified'); + + try { + await Registry.set(`${SOFTWARE_CLASSES}Directory\\shell\\${name}`); + await Registry.set(`${SOFTWARE_CLASSES}Directory\\shell\\${name}`, '', menu); + if (icon) await Registry.set(`${SOFTWARE_CLASSES}Directory\\shell\\${name}`, 'Icon', (icon.endsWith('.exe') ? `${icon},0` : icon)); + await Registry.set(`${SOFTWARE_CLASSES}Directory\\shell\\${name}\\command`, '', `"${command}" "%1"`); + } catch (e) { + return Promise.reject(e); + } + + return Promise.resolve(); +}; + +export const registerOpenWithCommand = async (extensions, options) => { + if (!extensions || !extensions.length) throw new Error('extensions is not specified'); + if (!options) throw new Error('options are empty'); + + const { name, command } = options; + if (!name) throw new Error('name is not specified'); + if (!command) throw new Error('command is not specified'); + + try { + await Promise.all((await findExtensionNames(extensions)).map(async n => { + await Registry.set(`${SOFTWARE_CLASSES}${n}`); + await Registry.set(`${SOFTWARE_CLASSES}${n}\\shell\\${name}`); + await Registry.set(`${SOFTWARE_CLASSES}${n}\\shell\\${name}\\command`, '', `"${command}" "%1"`); + })); + } catch (e) { + return Promise.reject(e); + } + + return Promise.resolve(); +}; + +export const removeCommand = async name => { + if (!name) throw new Error('name is not specified'); + + try { + await Registry.delete(`${SOFTWARE_CLASSES}*\\shell\\${name}`); + } catch (e) { + return Promise.reject(e); + } + + return Promise.resolve(); +}; + +export const removeDirectoryCommand = async name => { + if (!name) throw new Error('name is not specified'); + + try { + await Registry.delete(`${SOFTWARE_CLASSES}Directory\\shell\\${name}`); + } catch (e) { + return Promise.reject(e); + } + + return Promise.resolve(); +}; + +export const removeOpenWithCommand = async (extensions, name) => { + if (!extensions) throw new Error('extensions is not specified'); + if (!name) throw new Error('name is not specified'); + + try { + await Promise.all((await findExtensionNames(extensions)).map(async n => await Registry.delete(`${SOFTWARE_CLASSES}${n}\\shell\\${name}`))); + } catch (e) { + return Promise.reject(e); + } + + return Promise.resolve(); +}; + +async function findExtensionNames (exts) { + const { ses_root } = await Registry.get('HKCR'); + return Promise.all(Object.keys(ses_root).filter(e => exts.includes(e)).map(async k => (await Registry.get(`HKCR\\${k}`)).$values[''])); +} \ No newline at end of file diff --git a/src/output.ts b/src/output.ts new file mode 100644 index 0000000..16c5511 --- /dev/null +++ b/src/output.ts @@ -0,0 +1,27 @@ +import { sync } from '@plastichub/fs/write'; +import { OutputTarget, Options, OutputResult, OutputFormat } from './types'; +import { error } from './log'; +import { render as format } from './format'; + +export const stdout = (result: any) => console.log(result); + +export const file = (result: string, path: string) => sync(path, result); + +export const render = (result: any, options: Options): OutputResult => { + const report = format(result, options); + switch (options.target) { + case OutputTarget.STDOUT: { + stdout(report); + return true; + } + case OutputTarget.FILE: { + file(report, options.path); + return true; + } + default: { + //private, should never happen since options had to be sanitized + error('output::render Invalid value in options.target'); + return false; + } + } +} \ No newline at end of file diff --git a/src/paths.ts b/src/paths.ts new file mode 100644 index 0000000..11e309e --- /dev/null +++ b/src/paths.ts @@ -0,0 +1,27 @@ +import * as path from 'path'; +import { URL } from 'url'; +export const STATS_SUFFIX = '_stats.json'; +export const TRACE_SUFFIX = '_trace.json'; +export const HOWTO_SUFFIX = '_howto.json'; +export const HTML_SUFFIX = '_dump.html'; +// utils to create output file name for url, format : hostname_time.json +const _url_short = (url: string) => + new URL(url).hostname; + +const _date_suffix = () => + new Date().toLocaleTimeString().replace(/:/g, '_'); + +const _default_filename = (url: string) => + `${_url_short(url)}`; + +export const default_path = (cwd: string, url: string) => + `${path.join(cwd, _default_filename(url))}${STATS_SUFFIX}`; + +export const default_path_crawler = (cwd: string, url: string) => + `${path.join(cwd, _default_filename(url))}${HTML_SUFFIX}`; + +export const default_path_howto = (cwd: string, url: string) => + `${path.join(cwd, _default_filename(url))}${HOWTO_SUFFIX}`; + +export const default_trace_path = (cwd: string, url: string) => + `${path.join(cwd, _default_filename(url))}${TRACE_SUFFIX}`; \ No newline at end of file diff --git a/src/renderer/puppeteer/Scope.ts b/src/renderer/puppeteer/Scope.ts new file mode 100644 index 0000000..3852e95 --- /dev/null +++ b/src/renderer/puppeteer/Scope.ts @@ -0,0 +1,95 @@ +import { Browser, launch, Page, Response } from 'puppeteer'; +import { inspect, error, debug } from '../../log'; +import { capture_requests, capture_responses } from './network'; +let instance: Scope; +import * as path from 'path'; +import { URL } from 'url'; +export const STATS_SUFFIX = '_stats.json'; +export const SESSION_EVENTS_SUFFIX = '_session.json'; +export const TRACE_SUFFIX = '_trace.json'; +const included_categories = ['devtools.timeline']; +const _url_short = (url: string) => + new URL(url).hostname; + +const _date_suffix = () => + new Date().toLocaleTimeString().replace(/:/g, '_'); + +const _random_suffix = () => + Math.random() * 100; + +const _default_filename = (url: string) => + `${_url_short(url)}_${_random_suffix()}`; + +export const default_path = (cwd: string, url: string) => + `${path.join(cwd, _default_filename(url))}${STATS_SUFFIX}`; + +export const default_session_events_path = (cwd: string, url: string) => + `${path.join(cwd || process.cwd(), 'sessions', _default_filename(url))}${SESSION_EVENTS_SUFFIX}`; + +export const default_trace_path = (cwd: string, url: string) => + `${path.join(cwd, _default_filename(url))}${TRACE_SUFFIX}`; + +export class Scope { + browser!: Browser; + context!: any; + page!: Page; + args!: any; + requests: any[] = []; + responses: Response[] = []; + eventBeacons: any[] = []; + mutationBeacons: any[] = []; + sessionSuffix: string = ''; + onResponse; + onRequest; + async init() { + this.sessionSuffix = ' - ' + new Date().getTime(); + const args = [ + '--no-sandbox', + '--disable-setuid-sandbox', + '--disable-infobars', + '--window-position=0,0', + '--ignore-certifcate-errors', + '--ignore-certifcate-errors-spki-list', + '--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3312.0 Safari/537.36"' + ]; + this.browser = await launch({ headless: this.args.headless === 'true', devtools: true,args:args}); + // const context = await this.browser.createIncognitoBrowserContext(); + this.page = await this.browser.newPage(); + // this.page = await context.newPage(); + + this.page.on('console', msg => { + // error('Browser error:', msg); + }); + this.page.on('error', msg => error('Browser Error:', msg)); + // this.page.on('pageerror', msg => error('Browser Page Error:', msg)); + // this.page.on('requestfailed', msg => error('Browser Page Request Error:', msg)); + + //capture_requests(this, this.page); + //capture_responses(this, this.page); + + // this.args.disableRequests !== 'true' && capture_requests(this, this.page); + // this.args.disableResponses !== 'true' && capture_requests(this, this.page); + // capture_responses(this, this.page); + const page2 = this.page as any; + //page2.setCacheEnabled(false); + /* + await page2._client.send('Security.setOverrideCertificateErrors', { + override: true + }); + */ + await page2._client.on('Security.certificateError', (event: any) => { + page2._client.send('Security.handleCertificateError', { + eventId: event.eventId, + action: 'continue' // ignore error and continue request + }) + }) + } +} + +export const getScope = (cliArgs?: any) => { + if (!instance) { + instance = new Scope(); + instance.args = cliArgs; + } + return instance; +} diff --git a/src/renderer/puppeteer/constants.ts b/src/renderer/puppeteer/constants.ts new file mode 100644 index 0000000..d1883ee --- /dev/null +++ b/src/renderer/puppeteer/constants.ts @@ -0,0 +1,25 @@ +import { NavigationOptions } from 'puppeteer'; +export const defaultTenant = 1; +export const userSessionsTab = (base: string) => `${base}/e/${defaultTenant}/#usersearchoverview;gtf=l_2_HOURS`; +export const loginUrl = (base: string) => `${base}/login`; +export const loginUrlDemoDev = () => `https://proxy-dev.dynatracelabs.com/sso/ProxyLocator.jsp`; +export const defaultPageOptions = (): NavigationOptions => { + return { + timeout: 5000, + waitUntil: 'networkidle2' + } +} + +export const replay_api_overview = 'uemshareddetails/rumoverviewdata/usersearchoverview'; +const ts = () => { + const d = new Date(); + return d.getHours() + '_' + d.getMinutes() + '_' + d.getSeconds(); +} +export const sessionName = (url?: string) => `Pupeteer :${ts()}`; + +export const maxSessionWaitingTime = 1000 * 60 * 3; +export const responseRetryTime = 1000 * 8; +export const defaultMutationRoot = '#mutationsRoot'; +export const defaultMutationTag = 'div'; +export const defaultHeavyMutations = 2000; +export const defaultMediumMutations = 500; diff --git a/src/renderer/puppeteer/index.ts b/src/renderer/puppeteer/index.ts new file mode 100644 index 0000000..ab7dd08 --- /dev/null +++ b/src/renderer/puppeteer/index.ts @@ -0,0 +1,186 @@ +import { launch, Page } from 'puppeteer' +import { readFileSync } from 'fs'; +import * as moment from 'moment'; +import { sync as unlink } from '@plastichub/fs/remove'; +import { async as iterator } from '@plastichub/fs/iterator'; +import { + debug, inspect, + Options, TraceEntry, TraceTiming, + default_trace_path, + ReportEntry, + NetworkReportEntry, + sizeToString, + log, + spinner, + STATS_SUFFIX, + TRACE_SUFFIX +} from '../../'; +import { end_time } from './times'; +import { find_time } from './trace'; +import { rl } from './stdin'; +import { report, find_report, get_report } from './report'; +import { IProcessingNode } from '@plastichub/fs/interfaces'; + +const included_categories = ['devtools.timeline']; + +export class Puppeteer { + + static clean(url: string, options: Options) { + iterator(options.cwd, { + matching: [`*${STATS_SUFFIX}`, `*${TRACE_SUFFIX}`] + }).then((it) => { + let node: IProcessingNode = null; + while (node = it.next()) { + unlink(node.path); + } + }) + } + + static async begin(url: string, options: Options) { + + const browser = await launch({ + headless: options.headless, + devtools: false + }); + return await browser.newPage(); + } + static async crawler(url: string, options?: Options) { + + const page = await this.begin(url, options); + + } + static async repl(url: string, options?: Options) { + + const page = await this.begin(url, options); + page.on('console', msg => inspect('Console Message:', msg.text())); + + await page.goto(url, { + timeout: 600000, + waitUntil: 'networkidle0' + }); + + const readline = rl(`${url}#`, (line: string) => { + page.evaluate(line).then((results) => { + inspect(`Did evaluate ${line} to `, results); + }) + }, () => this.end(page)); + } + + + static async end(page: Page) { + + const browser = await page.browser(); + await page.close(); + await browser.close(); + } + + static async summary(url: string, options?: Options) { + + const browser = await launch({ + headless: options.headless, + devtools: true + }); + const page = await browser.newPage(); + await page.goto(url, { + timeout: 600000, + waitUntil: 'networkidle0' + }); + const metrics = await page.metrics(); + await this.end(page); + return metrics; + } + + static async detail(url: string, options?: Options) { + + const network_stats = report(); + const ReceivedTotal = get_report(network_stats, 'Received Total'); + const ReceivedStyleSheets = get_report(network_stats, 'Received Stylesheets'); + const ReceivedScripts = get_report(network_stats, 'Received Scripts'); + const ReceivedHTML = get_report(network_stats, 'Received HTML'); + const ReceivedImages = get_report(network_stats, 'Received Images'); + const ReceivedJSON = get_report(network_stats, 'Received JSON'); + const ReceivedFonts = get_report(network_stats, 'Received Fonts'); + const ReceivedBinary = get_report(network_stats, 'Received Binary'); + const MimeMap = { + 'application/javascript': ReceivedScripts, + 'text/javascript': ReceivedScripts, + 'text/css': ReceivedStyleSheets, + 'text/html': ReceivedHTML, + 'image/png': ReceivedImages, + 'image/gif': ReceivedImages, + 'image/svg+xml': ReceivedImages, + 'application/json': ReceivedJSON, + 'application/octet-stream': ReceivedBinary, + 'font/woff2': ReceivedFonts, + 'application/font-woff2': ReceivedFonts + } + + const traceFile = default_trace_path(options.cwd, url); + + const page = await this.begin(url, options); + await page.tracing.start({ + path: traceFile, + categories: included_categories + }); + await page.goto(url, { + timeout: 600000, + waitUntil: 'networkidle0' + }); + const metrics = await (page as any)._client.send('Performance.getMetrics'); + const nowTs = new Date().getTime(); + // const navigationStart = getTimeFromMetrics(metrics, 'NavigationStart'); + const navigationStart = find_time(metrics, 'Timestamp') + nowTs; + await page.tracing.stop(); + + // --- extracting data from trace.json --- + const tracing = JSON.parse(readFileSync(traceFile, 'utf8')); + + const dataReceivedEvents = tracing.traceEvents.filter(x => x.name === 'ResourceReceivedData'); + const dataResponseEvents = tracing.traceEvents.filter(x => x.name === 'ResourceReceiveResponse'); + + // find resource in responses or return default empty + const content_response = (requestId: string): TraceEntry => dataResponseEvents.find((x) => + x.args.data.requestId === requestId) + || { args: { data: { encodedDataLength: 0 } } }; + + const report_per_mime = (mime: string): NetworkReportEntry => MimeMap[mime] || get_report(network_stats, mime); + + // our iteration over the trace + // @TODO: convert to a better tree structure to avoid O(n) lookups + // @TODO: emit to extensions: events & aspects + // @TODO: calculate times + // @TODO: filter + // @TODO: options.mask + // @TODO: this iterator might get async + ReceivedTotal.value = dataReceivedEvents.reduce((first, x) => { + const content = content_response(x.args.data.requestId); + const data = content.args.data; + const report = report_per_mime(data.mimeType); + if (data.fromCache === false) { + report.value += x.args.data.encodedDataLength + report.count++; + } else { + report.cached_count++; + } + ReceivedTotal.count++; + return first + x.args.data.encodedDataLength; + }, ReceivedTotal.value); + + // calulate finals + [ReceivedTotal, ReceivedHTML, ReceivedImages, ReceivedJSON, + ReceivedScripts, ReceivedFonts, ReceivedBinary + ].forEach((r) => r.formatted = sizeToString(r.value)) + + // --- end extracting data from trace.json --- + + let results = []; + + // lights off + await this.end(page); + + return { + times: [], + network: network_stats + } + } +} diff --git a/src/renderer/puppeteer/network.ts b/src/renderer/puppeteer/network.ts new file mode 100644 index 0000000..2e42164 --- /dev/null +++ b/src/renderer/puppeteer/network.ts @@ -0,0 +1,176 @@ +import { Page, Request, Response } from 'puppeteer'; +import { sessionName, maxSessionWaitingTime, defaultPageOptions, userSessionsTab } from './constants'; +import * as debug from '../../log'; +import { Scope } from './Scope'; +import { parse } from 'url'; +import { navigateToUserSessions } from './processes'; + +const debugRequests = true; +const debugResponses = false; +export const default_postdata = (request: Request): any => request.postData && request.postData() || {}; +export type ResponseMatch = (request: any) => boolean; +export const HasUserSessions = (request: Request) => (default_postdata(request).users) +export const MyUserSessions = (url: string, request: Request) => SessionWithName(request, sessionName(url)); +export const SessionWithName = (request: Request, name: string) => { + const data = default_postdata(request).users || []; + return data.find((user: any) => user.id === name) +} +export type ResponseResolve = Response & { + data: any; +} +const default_prepare = (requests: Request[]): Request[] => { + return requests; +}; + +const default_filter_json = (r: Request) => ((r.headers()['content-type'] || '').startsWith('application/json;')) === true; +const responses = async function (requests: Request[]) { return Promise.all(requests.map(r => r.response()!.json())) }; + +export const findRequest = (url: string, requests: Request[], match?: ResponseMatch): Request[] => { + url = decodeURIComponent(url); + if (!match) { + return requests.filter((request) => request.url().indexOf(url) !== -1); + } else { + const results = requests.filter((request) => request.url().indexOf(url) !== -1); + return results.filter((r) => match!(r)); + } +} + +export function waitForResponse(url: string, scope: Scope, match: ResponseMatch, timeout: number = 5000): Promise { + return new Promise((resolve, reject) => { + setTimeout(() => { + try { + + let requests = default_prepare(scope.requests).filter(default_filter_json).filter(r => r.response() != null); + requests = requests.filter((request) => request.url().indexOf(url) !== -1); + responses(requests).then((responses) => { + const ret = responses.filter(match); + if (ret.length) { + resolve(ret); + } else { + reject('cant find anything yet'); + } + }); + } catch (error) { + debug.error('waitForResponse Error ', error); + } + }, timeout); + }) +} +export function waitForResponseNTimes(url: string, scope: Scope, match: ResponseMatch, timeout: number = 5000) { + return new Promise((resolve, reject) => { + const maxTime = maxSessionWaitingTime; + const retryTime = 8000; + let reachedTimeOut = false; + let interval: any = null; + interval = setInterval(() => { + if (reachedTimeOut) { + clearInterval(interval); + debug.error('reached max'); + reject('reached maximum timeout'); + return; + } + onReload(scope).then(() => { + scope.page.reload().then(() => { + debug.info('retry '); + waitForResponse(url, scope, match, retryTime).then((session) => { + debug.inspect('got my session', session); + clearInterval(interval); + resolve(session); + }).catch((e) => { + debug.error('found nothing'); + }) + }).catch((e) => { + console.error('error loading page : ', e); + }); + }); + }, retryTime); + + + setTimeout(() => { + reachedTimeOut = true; + clearInterval(interval); + reject('max timeout reached'); + }, maxTime); + }); +}; + +export async function capture_request(where: any[], request: Request) { + debugRequests && debug.inspect('Request', { url: request.url(), data: request.postData() }); + where.push({ url: request.url(), data: await request.postData(), request: request }); + debugRequests && debug.inspect('requests', where.map(r => r.url)); +} + +export async function capture_response(where: any[], response: Response) { + debugResponses && debug.inspect('Response', { url: response.url(), data: await response.json() }); + where.push(response); +} + +export async function capture_requests(scope: Scope, page: Page) { + + await page.setRequestInterception(true); + + scope.requests = []; + page.on('request', (interceptedRequest: Request) => { + + if(scope.onRequest){ + scope.onRequest(interceptedRequest, scope); + return; + } + + try { + const url = decodeURIComponent(interceptedRequest.url()); + const parsed = parse(url, true); + if (url.includes('.css') || url.includes('.svg')) { + interceptedRequest.abort(); + return; + + } + const query = parsed.query; + const isJson = (interceptedRequest.headers()['content-type'] || '').startsWith('application/json') === true; + if (isJson) { + // capture_request(scope.requests, interceptedRequest); + //debugRequests && debug.inspect('q ' + query['contentType'] + ' ' + url); + } + interceptedRequest.continue(); + } catch (e) { + debug.error('error parsing request ', e); + } + }); +} + +export async function capture_responses(scope: Scope, page: Page) { + try { + // await page.setRequestInterception(true); + } catch (e) { + debug.error('error intercepting responses', e); + } + scope.responses = []; + page.on('response', response => { + try { + const isJson = (response.headers()['content-type'] || '').startsWith('application/json;') === true; + const url = response.url(); + + if (response.status() === 200) { + if (isJson) { + capture_response(scope.responses, response); + } + if (scope.onResponse) { + scope.onResponse(response, scope); + } + } else { + debugResponses && debug.error(`Error loading ${url} : ${response.status()}`); + } + } catch (e) { + debugResponses && debug.error('Error parsing response'); + } + }); +} +export async function onReload(scope: Scope) { + scope.requests = []; + try { + await scope.page.setRequestInterception(false); + } catch (e) { + + } + await scope.page.setRequestInterception(true); +} \ No newline at end of file diff --git a/src/renderer/puppeteer/page.ts b/src/renderer/puppeteer/page.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/renderer/puppeteer/processes.ts b/src/renderer/puppeteer/processes.ts new file mode 100644 index 0000000..a0cecb4 --- /dev/null +++ b/src/renderer/puppeteer/processes.ts @@ -0,0 +1,78 @@ +import { Page, Request } from 'puppeteer'; +import { Options } from './types'; +import { loginUrl, defaultPageOptions, userSessionsTab, loginUrlDemoDev } from './constants'; + +export async function loginFrontEnd(page: Page, options: Options) { + // await page.goto(loginUrl(options.dynatraceUrl), defaultPageOptions()); + await page.type('#user', 'admin'); + await page.type('#password', 'admin'); + await page.click('#login-form > .maindiv > .logindiv > .submitdiv > .button'); + await page.waitForSelector('.tenant-selector'); + await page.click('.textboxdiv > .tenant-selector:nth-child(2)'); +} + +export async function loginDemoDev(page: Page, options: Options) { + await page.goto(loginUrlDemoDev(), defaultPageOptions()); + await page.type('#IDToken1', 'guenter.baumgart@ruxit.com'); + await page.click('.maindiv > .logindiv > form > div > #formsubmit'); + + return new Promise((resolve) => { + setTimeout(() => { + resolve(1); + console.log('time out'); + }, 20 * 1000) + }); + + console.log('logged in 1/2!'); + + + /* + const puppeteer = require('puppeteer'); + + (async () => { + const browser = await puppeteer.launch() + const page = await browser.newPage() + + await page.waitForSelector('.logindiv > form > .textboxdiv > .emailLoginIcon > #IDToken1') + await page.click('.logindiv > form > .textboxdiv > .emailLoginIcon > #IDToken1') + + await page.waitForSelector('.maindiv > .logindiv > form > div > #formsubmit') + await page.click('.maindiv > .logindiv > form > div > #formsubmit') + + const navigationPromise = page.waitForNavigation() + await navigationPromise + + await page.waitForSelector('.logindiv > form > .margin-bottom\3A > .passwordIcon > #IDToken2') + await page.click('.logindiv > form > .margin-bottom\3A > .passwordIcon > #IDToken2') + + await page.waitForSelector('.logindiv > form > fieldset > div > #IDToken3') + await page.click('.logindiv > form > fieldset > div > #IDToken3') + + await page.waitForSelector('form > fieldset > #button-base > div > #loginButton_0') + await page.click('form > fieldset > #button-base > div > #loginButton_0') + + await navigationPromise + + await navigationPromise + + await navigationPromise + + await browser.close() + })() + */ + + //await page.type('#password', 'admin'); + //await page.click('#login-form > .maindiv > .logindiv > .submitdiv > .button'); + //await page.waitForSelector('.tenant-selector'); + //await page.click('.textboxdiv > .tenant-selector:nth-child(2)'); +} + +export async function navigateToUserSessions(page: Page, options: Options) { + // await page.goto(userSessionsTab(options.dynatraceUrl), defaultPageOptions()); +} + + +export async function navigateToUserLocalhost(page: Page, options?: Options) { + // await page.goto('http://localhost/', defaultPageOptions()); +} + diff --git a/src/renderer/puppeteer/report.ts b/src/renderer/puppeteer/report.ts new file mode 100644 index 0000000..7e96a63 --- /dev/null +++ b/src/renderer/puppeteer/report.ts @@ -0,0 +1,40 @@ +import { NetworkReportEntry } from './types'; +const report_item = (name: string): NetworkReportEntry => { + return { + name: name, + value: 0, + formatted: '', + count: 0, + cached_count: 0, + external_count: 0, + local_count: 0, + times: { + end: 0, + formatted: '' + } + } +} + +export const report = () => { + return [ + report_item('Received Total'), + report_item('Received Stylesheets'), + report_item('Received Scripts'), + report_item('Received HTML'), + report_item('Received JSON'), + report_item('Received Images'), + report_item('Received Fonts'), + report_item('Received Binary') + ] +} + +export const find_report = (where: any[], name: string) => where.find((media) => media.name === name); + +export const get_report = (where: any[], type: string) => { + let record = find_report(where, type); + if (!record) { + record = report_item(type); + where.push(record); + } + return record; +} \ No newline at end of file diff --git a/src/renderer/puppeteer/stdin.ts b/src/renderer/puppeteer/stdin.ts new file mode 100644 index 0000000..f05fb7f --- /dev/null +++ b/src/renderer/puppeteer/stdin.ts @@ -0,0 +1,31 @@ +import { createInterface, ReadLine } from 'readline'; +import { Page } from 'puppeteer'; +import chalk from 'chalk'; + + + +export const rl = (prompt: string, onLine?: (line: string) => void, onClose?: () => {}) => { + const rl = createInterface({ + input: process.stdin, + output: process.stdout, + prompt: chalk.green(prompt) + }) + console.log('start stdin: ' + prompt); + rl.prompt() + rl.on('line', (line) => { + if(!line){ + return; + } + try { + onLine(line); + } catch (e) { + console.error(e) + rl.prompt() + } + }) + rl.on('close', () => { + rl.close() + onClose(); + }); + return rl; +} \ No newline at end of file diff --git a/src/renderer/puppeteer/times.ts b/src/renderer/puppeteer/times.ts new file mode 100644 index 0000000..17645d9 --- /dev/null +++ b/src/renderer/puppeteer/times.ts @@ -0,0 +1,12 @@ +import { TraceEntry } from './types' +export const end_time = (entry: TraceEntry): number => { + const timing = entry.args.data.timing; + const start = timing.requestTime; + const received = entry.ts; + //it might be more accurate to calc this with the header times + const headersReceived = start + timing.receiveHeadersEnd / 1000; + let responseReceived = headersReceived; + responseReceived = Math.min(responseReceived, headersReceived); + responseReceived = Math.max(responseReceived, start); + return Math.max(-1, responseReceived); +} diff --git a/src/renderer/puppeteer/trace.ts b/src/renderer/puppeteer/trace.ts new file mode 100644 index 0000000..d98a3f6 --- /dev/null +++ b/src/renderer/puppeteer/trace.ts @@ -0,0 +1,57 @@ +import { NetworkReportEntry, TraceEntry } from "./types"; + +export const find_time = (metrics, name) => + metrics.metrics.find(x => x.name === name).value; + +export const all_with_name = (where: NetworkReportEntry[], name: string) => + where.filter((entry) => entry.name === name); + +/* +export const tree = (entries: TraceEntry[]) => { + const tasks = []; + let currentTask; + + for (const event of entries) { + // Only look at X (Complete), B (Begin), and E (End) events as they have most data + if (event.ph !== 'X' && event.ph !== 'B' && event.ph !== 'E') continue; + + // Update currentTask based on the elapsed time. + // The next event may be after currentTask has ended. + while ( + currentTask && + Number.isFinite(currentTask.endTime) && + currentTask.endTime <= event.ts + ) { + currentTask = currentTask.parent; + } + + if (!currentTask) { + // We can't start a task with an end event + if (event.ph === 'E') { + throw new Error('Fatal trace logic error'); + } + + currentTask = entries._createNewTaskNode(event); + tasks.push(currentTask); + + continue; + } + + if (event.ph === 'X' || event.ph === 'B') { + // We're starting a nested event, create it as a child and make it the currentTask + const newTask = entries._createNewTaskNode(event, currentTask); + tasks.push(newTask); + currentTask = newTask; + } else { + if (currentTask.event.ph !== 'B') { + throw new Error('Fatal trace logic error'); + } + + // We're ending an event, update the end time and the currentTask to its parent + currentTask.endTime = event.ts; + currentTask = currentTask.parent; + } + } + return tasks; +} +*/ \ No newline at end of file diff --git a/src/renderer/puppeteer/types.ts b/src/renderer/puppeteer/types.ts new file mode 100644 index 0000000..e746e42 --- /dev/null +++ b/src/renderer/puppeteer/types.ts @@ -0,0 +1,124 @@ +///////////////////////////////////////////////////// +// +// Application types +// +export enum OutputTarget { + STDOUT = 'console', + FILE = 'file' +} + +export enum OutputFormat { + text = 'text', + json = 'json' +} + +export interface Options { + // @TODO: support many + url?: string; + format?: OutputFormat; + // @TODO: support many + target?: OutputTarget; + headless?: boolean; + // output path + path?: string; + // @TODO: required to pick profile/config files + cwd?: string; + // @TODO: time of sesssion, mapped to Puppeteer waitUntil, if it's a number, the session will be opened for that + // time window, time=-1 means infinity, useful for repl. sessions + time?: number; + // @TODO: reload interval + reload?: number; + // @TODO: repl. --repl=true=interactive or repl=path to specify script + repl?: string | boolean; + // TODO: colored ouput + colors?: boolean; +} + +// options for certain categories as network, rendering,... +export interface OptionEx { + include?: string | string[]; + exclude?: string | string[]; + query?: string | string[]; +} + +export type OptionsEx = Options & { + launchOptions?: { + // puppeteer launch options + } + waitOptions?: { + // puppeteer wait options: wait for selector,... + } + replOptions?: { + script?: string; + } +} + +export type OutputResult = boolean; + +export interface ReportEntry { + name: string; +} + +export type NetworkReportEntry = ReportEntry & { + value: number; + formatted: string; + count: number; + cached_count: number; + external_count: number; + local_count: number; + times?: { + end: number, + formatted: string; + } +} + +///////////////////////////////////////////////////// +// +// Foreign data types (trace data) +// + +// type for a network resource's timing +export interface TraceTiming { + requestTime: number; + proxyStart: number; + proxyEnd: number; + dnsStart: number; + dnsEnd: number; + connectStart: number; + connectEnd: number; + sslStart: number; + sslEnd: number; + workerStart: number; + workerReady: number; + sendStart: number; + sendEnd: number; + receiveHeadersEnd: number; + pushStart: number; + pushEnd: number; +} + +export interface TraceData { + requestId: string; + frame: string; + statusCode: number; + mimeType: string; + encodedDataLength: number; + fromCache: boolean; + fromServiceWorker: boolean; + timing: TraceTiming; +} +export interface TraceArgs { + data: TraceData; +} + +export interface TraceEntry { + pid: number; + tid: number; + ts: number; + ph: string; // B: begin, | E: end; For async events: S: start, F: finish + cat: string; + name: string; + args: TraceArgs; + tts: number; + s: string; +} diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..e746e42 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,124 @@ +///////////////////////////////////////////////////// +// +// Application types +// +export enum OutputTarget { + STDOUT = 'console', + FILE = 'file' +} + +export enum OutputFormat { + text = 'text', + json = 'json' +} + +export interface Options { + // @TODO: support many + url?: string; + format?: OutputFormat; + // @TODO: support many + target?: OutputTarget; + headless?: boolean; + // output path + path?: string; + // @TODO: required to pick profile/config files + cwd?: string; + // @TODO: time of sesssion, mapped to Puppeteer waitUntil, if it's a number, the session will be opened for that + // time window, time=-1 means infinity, useful for repl. sessions + time?: number; + // @TODO: reload interval + reload?: number; + // @TODO: repl. --repl=true=interactive or repl=path to specify script + repl?: string | boolean; + // TODO: colored ouput + colors?: boolean; +} + +// options for certain categories as network, rendering,... +export interface OptionEx { + include?: string | string[]; + exclude?: string | string[]; + query?: string | string[]; +} + +export type OptionsEx = Options & { + launchOptions?: { + // puppeteer launch options + } + waitOptions?: { + // puppeteer wait options: wait for selector,... + } + replOptions?: { + script?: string; + } +} + +export type OutputResult = boolean; + +export interface ReportEntry { + name: string; +} + +export type NetworkReportEntry = ReportEntry & { + value: number; + formatted: string; + count: number; + cached_count: number; + external_count: number; + local_count: number; + times?: { + end: number, + formatted: string; + } +} + +///////////////////////////////////////////////////// +// +// Foreign data types (trace data) +// + +// type for a network resource's timing +export interface TraceTiming { + requestTime: number; + proxyStart: number; + proxyEnd: number; + dnsStart: number; + dnsEnd: number; + connectStart: number; + connectEnd: number; + sslStart: number; + sslEnd: number; + workerStart: number; + workerReady: number; + sendStart: number; + sendEnd: number; + receiveHeadersEnd: number; + pushStart: number; + pushEnd: number; +} + +export interface TraceData { + requestId: string; + frame: string; + statusCode: number; + mimeType: string; + encodedDataLength: number; + fromCache: boolean; + fromServiceWorker: boolean; + timing: TraceTiming; +} +export interface TraceArgs { + data: TraceData; +} + +export interface TraceEntry { + pid: number; + tid: number; + ts: number; + ph: string; // B: begin, | E: end; For async events: S: start, F: finish + cat: string; + name: string; + args: TraceArgs; + tts: number; + s: string; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..31a3ebe --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "allowJs": false, + "noImplicitAny": false, + "noImplicitThis": false, + "alwaysStrict": true, + "sourceMap": true, + "outDir": "./build", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "pretty": true, + "baseUrl": "./src", + "rootDir": "./src", + "watch": false, + "allowSyntheticDefaultImports": true + }, + "compileOnSave": false, + "filesGlob": [ + "./src/**/*.ts" + ], + "atom": { + "rewriteTsconfig": true + }, + "files": [ + "./src/index.ts" + ] +} \ No newline at end of file diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..6455bf7 --- /dev/null +++ b/tslint.json @@ -0,0 +1,101 @@ +{ + "extends": [ + "tslint:latest", + "tslint-react" + ], + "rules": { + "triple-equals": false, + "no-bitwise": false, + "jsx-self-close": false, + "comment-format": false, + "jsx-alignment": false, + "no-debugger": false, + "no-empty": false, + "arrow-parens": false, + "eofline": false, + "only-arrow-functions": false, + "no-unused-expression": false, + "no-unused-variable": true, + "prefer-for-of": false, + "prefer-const": false, + "no-this-assignment": false, + "member-access": false, + "member-ordering": false, + "no-empty-interface": false, + "no-string-literal": false, + "no-trailing-whitespace": false, + "no-shadowed-variable": false, + "object-literal-shorthand": false, + "no-var-requires": true, + "interface-name": false, + "interface-over-type-literal": false, + "no-duplicate-imports": false, + "array-type": false, + "jsx-no-lambda": false, + "jsdoc-format": false, + "typedef-whitespace": false, + "ban": [ + true, + [ + "Object", + "assign", + "use TS2.1 object spread { ...a, ...b }" + ], + [ + "describe", + "only" + ], + [ + "it", + "only" + ] + ], + "no-console": false, + "linebreak-style": [ + true, + "LF" + ], + "no-invalid-this": [ + true, + "check-function-in-method" + ], + "jsx-wrap-multiline": false, + "space-before-function-paren": false, + "variable-name": [ + "ban-keywords", + "check-format", + "allow-leading-underscore", + "allow-pascal-case" + ], + "no-submodule-imports": false, + "no-implicit-dependencies": false, + "trailing-comma": [ + false + ], + "max-line-length": [ + 180 + ], + "max-classes-per-file": [ + false, + 5 + ], + "object-literal-sort-keys": false, + "jsx-no-multiline-js": false, + "ordered-imports": [ + false + ], + "semicolon": [ + false + ], + "quotemark": [ + true, + "single" + ] + }, + "jsRules": { + "object-literal-shorthand": true, + "trailing-comma": [ + false + ] + } +}