diff --git a/__tests__/checks.test.ts b/__tests__/checks.test.ts index fe97448..35febc5 100644 --- a/__tests__/checks.test.ts +++ b/__tests__/checks.test.ts @@ -6,17 +6,19 @@ import * as fs from 'fs'; import { checks, is, StatusCheck } from '../src/checks'; const client: InstanceType = { - repos: { - // @ts-ignore - getContent(params) { - if (params?.path) { - return { - data: { - content: fs.readFileSync(params.path, 'utf8'), - encoding: 'utf-8', - }, - }; - } + rest: { + repos: { + // @ts-ignore + getContent(params) { + if (params?.path) { + return { + data: { + content: fs.readFileSync(params.path, 'utf8'), + encoding: 'utf-8', + }, + }; + } + }, }, }, }; diff --git a/__tests__/labeler.test.ts b/__tests__/labeler.test.ts index 6969fee..7f47bc2 100644 --- a/__tests__/labeler.test.ts +++ b/__tests__/labeler.test.ts @@ -6,33 +6,35 @@ import { Config, getConfig } from '../src/config'; import * as fs from 'fs'; const client: InstanceType = { - repos: { - // @ts-ignore - getContent(params) { - if (params?.path) { - return { - data: { - content: fs.readFileSync(params.path, 'utf8'), - encoding: 'utf-8', - }, - }; - } + rest: { + repos: { + // @ts-ignore + getContent(params) { + if (params?.path) { + return { + data: { + content: fs.readFileSync(params.path, 'utf8'), + encoding: 'utf-8', + }, + }; + } + }, }, - }, - pulls: { - listCommits: { - endpoint: { - // @ts-ignore - merge() { - return {}; + pulls: { + listCommits: { + endpoint: { + // @ts-ignore + merge() { + return {}; + }, }, }, - }, - listFiles: { - endpoint: { - // @ts-ignore - merge() { - return {}; + listFiles: { + endpoint: { + // @ts-ignore + merge() { + return {}; + }, }, }, }, diff --git a/__tests__/matcher/commits.test.ts b/__tests__/matcher/commits.test.ts index 3480a65..50f98fa 100644 --- a/__tests__/matcher/commits.test.ts +++ b/__tests__/matcher/commits.test.ts @@ -5,12 +5,14 @@ import { Config } from '../../src/config'; async function getMatchedLabels(config: Config): Promise { return match( { - pulls: { - listCommits: { - endpoint: { - // @ts-ignore - merge(params) { - return { pull_number: params.pull_number }; + rest: { + pulls: { + listCommits: { + endpoint: { + // @ts-ignore + merge(params) { + return { pull_number: params.pull_number }; + }, }, }, }, diff --git a/__tests__/matcher/files.test.ts b/__tests__/matcher/files.test.ts index 5e7d893..6a82014 100644 --- a/__tests__/matcher/files.test.ts +++ b/__tests__/matcher/files.test.ts @@ -5,12 +5,14 @@ import { Config } from '../../src/config'; async function getMatchedLabels(config: Config): Promise { return match( { - pulls: { - listFiles: { - endpoint: { - // @ts-ignore - merge(params) { - return { pull_number: params.pull_number }; + rest: { + pulls: { + listFiles: { + endpoint: { + // @ts-ignore + merge(params) { + return { pull_number: params.pull_number }; + }, }, }, }, diff --git a/dist/index.js b/dist/index.js index 506329a..c49fc1b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8,7 +8,11 @@ require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -99,7 +103,11 @@ exports.checks = checks; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -199,7 +207,7 @@ const Config = t.intersection([ function parse(content) { const config = yaml.load(content); const decoded = Config.decode(config); - if (Either_1.isRight(decoded)) { + if ((0, Either_1.isRight)(decoded)) { return decoded.right; } else { @@ -211,7 +219,7 @@ function getConfig(client, configPath, configRepo) { var _a; return __awaiter(this, void 0, void 0, function* () { const [owner, repo] = configRepo.split('/'); - const response = yield client.repos.getContent({ + const response = yield client.rest.repos.getContent({ owner, repo, ref: configRepo === ((_a = github.context.payload.repository) === null || _a === void 0 ? void 0 : _a.full_name) ? github.context.sha : undefined, @@ -233,7 +241,11 @@ exports.getConfig = getConfig; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -289,7 +301,7 @@ function mergeLabels(labels, config) { return label.sync && !labels.includes(label.label) && currents.includes(label.label); }) .map((value) => value.label); - return lodash_1.difference(lodash_1.uniq(lodash_1.concat(labels, currents)), removals); + return (0, lodash_1.difference)((0, lodash_1.uniq)((0, lodash_1.concat)(labels, currents)), removals); } exports.mergeLabels = mergeLabels; function labels(client, config) { @@ -299,16 +311,16 @@ function labels(client, config) { return []; } const labels = yield Promise.all([ - title_1.default(client, config), - body_1.default(client, config), - comment_1.default(client, config), - branch_1.default(client, config), - base_branch_1.default(client, config), - commits_1.default(client, config), - files_1.default(client, config), - author_1.default(client, config), + (0, title_1.default)(client, config), + (0, body_1.default)(client, config), + (0, comment_1.default)(client, config), + (0, branch_1.default)(client, config), + (0, base_branch_1.default)(client, config), + (0, commits_1.default)(client, config), + (0, files_1.default)(client, config), + (0, author_1.default)(client, config), ]).then((value) => { - return lodash_1.uniq(lodash_1.concat(...value)); + return (0, lodash_1.uniq)((0, lodash_1.concat)(...value)); }); return mergeLabels(labels, config); }); @@ -325,7 +337,11 @@ exports.labels = labels; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -371,7 +387,7 @@ function addLabels(labels) { if (!labels.length) { return; } - yield client.issues.addLabels({ + yield client.rest.issues.addLabels({ owner: github.context.repo.owner, repo: github.context.repo.repo, issue_number: payload.number, @@ -391,7 +407,7 @@ function removeLabels(labels, config) { return label.sync && !labels.includes(label.label); }) .map((label) => { - return client.issues + return client.rest.issues .removeLabel({ owner: github.context.repo.owner, repo: github.context.repo.repo, @@ -416,7 +432,7 @@ function addChecks(checks) { const sha = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head.sha; yield Promise.all([ checks.map((check) => { - client.repos.createCommitStatus({ + client.rest.repos.createCommitStatus({ owner: github.context.repo.owner, repo: github.context.repo.repo, sha: sha, @@ -429,14 +445,14 @@ function addChecks(checks) { ]); }); } -config_1.getConfig(client, configPath, configRepo) +(0, config_1.getConfig)(client, configPath, configRepo) .then((config) => __awaiter(void 0, void 0, void 0, function* () { - const labeled = yield labeler_1.labels(client, config); - const finalLabels = labeler_1.mergeLabels(labeled, config); + const labeled = yield (0, labeler_1.labels)(client, config); + const finalLabels = (0, labeler_1.mergeLabels)(labeled, config); return Promise.all([ addLabels(finalLabels), removeLabels(finalLabels, config), - checks_1.checks(client, config, finalLabels).then((checks) => addChecks(checks)), + (0, checks_1.checks)(client, config, finalLabels).then((checks) => addChecks(checks)), ]); })) .catch((error) => { @@ -454,7 +470,11 @@ config_1.getConfig(client, configPath, configRepo) var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -513,7 +533,11 @@ exports["default"] = match; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -543,7 +567,7 @@ function match(client, config) { return config .labels.filter((value) => { var _a; - return utils_1.matcherRegex({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.baseBranch, text: ref }); + return (0, utils_1.matcherRegex)({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.baseBranch, text: ref }); }) .map((value) => value.label); } @@ -559,7 +583,11 @@ exports["default"] = match; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -588,7 +616,7 @@ function match(client, config) { return config .labels.filter((value) => { var _a; - return utils_1.matcherRegex({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.body, text: body }); + return (0, utils_1.matcherRegex)({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.body, text: body }); }) .map((value) => value.label); } @@ -604,7 +632,11 @@ exports["default"] = match; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -634,7 +666,7 @@ function match(client, config) { return config .labels.filter((value) => { var _a; - return utils_1.matcherRegex({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.branch, text: ref }); + return (0, utils_1.matcherRegex)({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.branch, text: ref }); }) .map((value) => value.label); } @@ -650,7 +682,11 @@ exports["default"] = match; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -679,7 +715,7 @@ function match(client, config) { return config .labels.filter((value) => { var _a; - return utils_1.matcherRegex({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.comment, text: body }); + return (0, utils_1.matcherRegex)({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.comment, text: body }); }) .map((value) => value.label); } @@ -695,7 +731,11 @@ exports["default"] = match; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -738,7 +778,7 @@ function match(client, config) { if (!matchers.length) { return []; } - const responses = yield client.paginate(client.pulls.listCommits.endpoint.merge({ + const responses = yield client.paginate(client.rest.pulls.listCommits.endpoint.merge({ owner: github.context.repo.owner, repo: github.context.repo.repo, pull_number: number, @@ -747,7 +787,7 @@ function match(client, config) { const messages = responses.map((c) => c.commit.message); return matchers .filter((value) => { - return utils_1.matcherRegexAny(value.matcher.commits, messages); + return (0, utils_1.matcherRegexAny)(value.matcher.commits, messages); }) .map((value) => value.label); }); @@ -764,7 +804,11 @@ exports["default"] = match; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -792,7 +836,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); const github = __importStar(__nccwpck_require__(5438)); -const minimatch_1 = __nccwpck_require__(3973); +const minimatch_1 = __nccwpck_require__(1953); /** * Get a type-safe FileMatcher */ @@ -840,7 +884,7 @@ function getMatchers(config) { } function getFiles(client, pr_number) { return __awaiter(this, void 0, void 0, function* () { - const responses = yield client.paginate(client.pulls.listFiles.endpoint.merge({ + const responses = yield client.paginate(client.rest.pulls.listFiles.endpoint.merge({ owner: github.context.repo.owner, repo: github.context.repo.repo, pull_number: pr_number, @@ -927,7 +971,11 @@ exports["default"] = match; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -956,7 +1004,7 @@ function match(client, config) { return config .labels.filter((value) => { var _a; - return utils_1.matcherRegex({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.title, text: title }); + return (0, utils_1.matcherRegex)({ regex: (_a = value.matcher) === null || _a === void 0 ? void 0 : _a.title, text: title }); }) .map((value) => value.label); } @@ -1513,8 +1561,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(1404); -const auth_1 = __nccwpck_require__(6758); +const http_client_1 = __nccwpck_require__(6255); +const auth_1 = __nccwpck_require__(5526); const core_1 = __nccwpck_require__(2186); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { @@ -1547,7 +1595,7 @@ class OidcClient { .catch(error => { throw new Error(`Failed to get ID Token. \n Error Code : ${error.statusCode}\n - Error Message: ${error.result.message}`); + Error Message: ${error.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; if (!id_token) { @@ -1983,7 +2031,260 @@ exports.toCommandProperties = toCommandProperties; /***/ }), -/***/ 6758: +/***/ 4087: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Context = void 0; +const fs_1 = __nccwpck_require__(7147); +const os_1 = __nccwpck_require__(2037); +class Context { + /** + * Hydrate the context from the environment + */ + constructor() { + var _a, _b, _c; + this.payload = {}; + if (process.env.GITHUB_EVENT_PATH) { + if ((0, fs_1.existsSync)(process.env.GITHUB_EVENT_PATH)) { + this.payload = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' })); + } + else { + const path = process.env.GITHUB_EVENT_PATH; + process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${os_1.EOL}`); + } + } + this.eventName = process.env.GITHUB_EVENT_NAME; + this.sha = process.env.GITHUB_SHA; + this.ref = process.env.GITHUB_REF; + this.workflow = process.env.GITHUB_WORKFLOW; + this.action = process.env.GITHUB_ACTION; + this.actor = process.env.GITHUB_ACTOR; + this.job = process.env.GITHUB_JOB; + this.runNumber = parseInt(process.env.GITHUB_RUN_NUMBER, 10); + this.runId = parseInt(process.env.GITHUB_RUN_ID, 10); + this.apiUrl = (_a = process.env.GITHUB_API_URL) !== null && _a !== void 0 ? _a : `https://api.github.com`; + this.serverUrl = (_b = process.env.GITHUB_SERVER_URL) !== null && _b !== void 0 ? _b : `https://github.com`; + this.graphqlUrl = + (_c = process.env.GITHUB_GRAPHQL_URL) !== null && _c !== void 0 ? _c : `https://api.github.com/graphql`; + } + get issue() { + const payload = this.payload; + return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pull_request || payload).number }); + } + get repo() { + if (process.env.GITHUB_REPOSITORY) { + const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); + return { owner, repo }; + } + if (this.payload.repository) { + return { + owner: this.payload.repository.owner.login, + repo: this.payload.repository.name + }; + } + throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'"); + } +} +exports.Context = Context; +//# sourceMappingURL=context.js.map + +/***/ }), + +/***/ 5438: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getOctokit = exports.context = void 0; +const Context = __importStar(__nccwpck_require__(4087)); +const utils_1 = __nccwpck_require__(3030); +exports.context = new Context.Context(); +/** + * Returns a hydrated octokit ready to use for GitHub Actions + * + * @param token the repo PAT or GITHUB_TOKEN + * @param options other options to set + */ +function getOctokit(token, options, ...additionalPlugins) { + const GitHubWithPlugins = utils_1.GitHub.plugin(...additionalPlugins); + return new GitHubWithPlugins((0, utils_1.getOctokitOptions)(token, options)); +} +exports.getOctokit = getOctokit; +//# sourceMappingURL=github.js.map + +/***/ }), + +/***/ 7914: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getApiBaseUrl = exports.getProxyFetch = exports.getProxyAgentDispatcher = exports.getProxyAgent = exports.getAuthString = void 0; +const httpClient = __importStar(__nccwpck_require__(6255)); +const undici_1 = __nccwpck_require__(1773); +function getAuthString(token, options) { + if (!token && !options.auth) { + throw new Error('Parameter token or opts.auth is required'); + } + else if (token && options.auth) { + throw new Error('Parameters token and opts.auth may not both be specified'); + } + return typeof options.auth === 'string' ? options.auth : `token ${token}`; +} +exports.getAuthString = getAuthString; +function getProxyAgent(destinationUrl) { + const hc = new httpClient.HttpClient(); + return hc.getAgent(destinationUrl); +} +exports.getProxyAgent = getProxyAgent; +function getProxyAgentDispatcher(destinationUrl) { + const hc = new httpClient.HttpClient(); + return hc.getAgentDispatcher(destinationUrl); +} +exports.getProxyAgentDispatcher = getProxyAgentDispatcher; +function getProxyFetch(destinationUrl) { + const httpDispatcher = getProxyAgentDispatcher(destinationUrl); + const proxyFetch = (url, opts) => __awaiter(this, void 0, void 0, function* () { + return (0, undici_1.fetch)(url, Object.assign(Object.assign({}, opts), { dispatcher: httpDispatcher })); + }); + return proxyFetch; +} +exports.getProxyFetch = getProxyFetch; +function getApiBaseUrl() { + return process.env['GITHUB_API_URL'] || 'https://api.github.com'; +} +exports.getApiBaseUrl = getApiBaseUrl; +//# sourceMappingURL=utils.js.map + +/***/ }), + +/***/ 3030: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getOctokitOptions = exports.GitHub = exports.defaults = exports.context = void 0; +const Context = __importStar(__nccwpck_require__(4087)); +const Utils = __importStar(__nccwpck_require__(7914)); +// octokit + plugins +const core_1 = __nccwpck_require__(6762); +const plugin_rest_endpoint_methods_1 = __nccwpck_require__(3044); +const plugin_paginate_rest_1 = __nccwpck_require__(4193); +exports.context = new Context.Context(); +const baseUrl = Utils.getApiBaseUrl(); +exports.defaults = { + baseUrl, + request: { + agent: Utils.getProxyAgent(baseUrl), + fetch: Utils.getProxyFetch(baseUrl) + } +}; +exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(exports.defaults); +/** + * Convience function to correctly format Octokit Options to pass into the constructor. + * + * @param token the repo PAT or GITHUB_TOKEN + * @param options other options to set + */ +function getOctokitOptions(token, options) { + const opts = Object.assign({}, options || {}); // Shallow clone - don't mutate the object provided by the caller + // Auth + const auth = Utils.getAuthString(token, opts); + if (auth) { + opts.auth = auth; + } + return opts; +} +exports.getOctokitOptions = getOctokitOptions; +//# sourceMappingURL=utils.js.map + +/***/ }), + +/***/ 5526: /***/ (function(__unused_webpack_module, exports) { "use strict"; @@ -2071,7 +2372,7 @@ exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHand /***/ }), -/***/ 1404: +/***/ 6255: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -2079,7 +2380,11 @@ exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHand /* eslint-disable @typescript-eslint/no-explicit-any */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -2092,7 +2397,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -2109,8 +2414,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0; const http = __importStar(__nccwpck_require__(3685)); const https = __importStar(__nccwpck_require__(5687)); -const pm = __importStar(__nccwpck_require__(2843)); +const pm = __importStar(__nccwpck_require__(9835)); const tunnel = __importStar(__nccwpck_require__(4294)); +const undici_1 = __nccwpck_require__(1773); var HttpCodes; (function (HttpCodes) { HttpCodes[HttpCodes["OK"] = 200] = "OK"; @@ -2140,16 +2446,16 @@ var HttpCodes; HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); +})(HttpCodes || (exports.HttpCodes = HttpCodes = {})); var Headers; (function (Headers) { Headers["Accept"] = "accept"; Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); +})(Headers || (exports.Headers = Headers = {})); var MediaTypes; (function (MediaTypes) { MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); +})(MediaTypes || (exports.MediaTypes = MediaTypes = {})); /** * Returns the proxy URL, depending upon the supplied url and proxy environment variables. * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com @@ -2200,6 +2506,19 @@ class HttpClientResponse { })); }); } + readBodyBuffer() { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { + const chunks = []; + this.message.on('data', (chunk) => { + chunks.push(chunk); + }); + this.message.on('end', () => { + resolve(Buffer.concat(chunks)); + }); + })); + }); + } } exports.HttpClientResponse = HttpClientResponse; function isHttps(requestUrl) { @@ -2505,6 +2824,15 @@ class HttpClient { const parsedUrl = new URL(serverUrl); return this._getAgent(parsedUrl); } + getAgentDispatcher(serverUrl) { + const parsedUrl = new URL(serverUrl); + const proxyUrl = pm.getProxyUrl(parsedUrl); + const useProxy = proxyUrl && proxyUrl.hostname; + if (!useProxy) { + return; + } + return this._getProxyAgentDispatcher(parsedUrl, proxyUrl); + } _prepareRequest(method, requestUrl, headers) { const info = {}; info.parsedUrl = requestUrl; @@ -2604,6 +2932,30 @@ class HttpClient { } return agent; } + _getProxyAgentDispatcher(parsedUrl, proxyUrl) { + let proxyAgent; + if (this._keepAlive) { + proxyAgent = this._proxyAgentDispatcher; + } + // if agent is already assigned use that agent. + if (proxyAgent) { + return proxyAgent; + } + const usingSsl = parsedUrl.protocol === 'https:'; + proxyAgent = new undici_1.ProxyAgent(Object.assign({ uri: proxyUrl.href, pipelining: !this._keepAlive ? 0 : 1 }, ((proxyUrl.username || proxyUrl.password) && { + token: `${proxyUrl.username}:${proxyUrl.password}` + }))); + this._proxyAgentDispatcher = proxyAgent; + if (usingSsl && this._ignoreSslError) { + // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process + // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options + // we have to cast it to any and change it directly + proxyAgent.options = Object.assign(proxyAgent.options.requestTls || {}, { + rejectUnauthorized: false + }); + } + return proxyAgent; + } _performExponentialBackoff(retryNumber) { return __awaiter(this, void 0, void 0, function* () { retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); @@ -2683,7 +3035,7 @@ const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCa /***/ }), -/***/ 2843: +/***/ 9835: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -2704,7 +3056,13 @@ function getProxyUrl(reqUrl) { } })(); if (proxyVar) { - return new URL(proxyVar); + try { + return new URL(proxyVar); + } + catch (_a) { + if (!proxyVar.startsWith('http://') && !proxyVar.startsWith('https://')) + return new URL(`http://${proxyVar}`); + } } else { return undefined; @@ -2715,6 +3073,10 @@ function checkBypass(reqUrl) { if (!reqUrl.hostname) { return false; } + const reqHost = reqUrl.hostname; + if (isLoopbackAddress(reqHost)) { + return true; + } const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; if (!noProxy) { return false; @@ -2740,4812 +3102,6625 @@ function checkBypass(reqUrl) { .split(',') .map(x => x.trim().toUpperCase()) .filter(x => x)) { - if (upperReqHosts.some(x => x === upperNoProxyItem)) { + if (upperNoProxyItem === '*' || + upperReqHosts.some(x => x === upperNoProxyItem || + x.endsWith(`.${upperNoProxyItem}`) || + (upperNoProxyItem.startsWith('.') && + x.endsWith(`${upperNoProxyItem}`)))) { return true; } } return false; } exports.checkBypass = checkBypass; +function isLoopbackAddress(host) { + const hostLower = host.toLowerCase(); + return (hostLower === 'localhost' || + hostLower.startsWith('127.') || + hostLower.startsWith('[::1]') || + hostLower.startsWith('[0:0:0:0:0:0:0:1]')); +} //# sourceMappingURL=proxy.js.map /***/ }), -/***/ 4087: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 334: +/***/ ((module) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.Context = void 0; -const fs_1 = __nccwpck_require__(7147); -const os_1 = __nccwpck_require__(2037); -class Context { - /** - * Hydrate the context from the environment - */ - constructor() { - this.payload = {}; - if (process.env.GITHUB_EVENT_PATH) { - if (fs_1.existsSync(process.env.GITHUB_EVENT_PATH)) { - this.payload = JSON.parse(fs_1.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' })); - } - else { - const path = process.env.GITHUB_EVENT_PATH; - process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${os_1.EOL}`); - } - } - this.eventName = process.env.GITHUB_EVENT_NAME; - this.sha = process.env.GITHUB_SHA; - this.ref = process.env.GITHUB_REF; - this.workflow = process.env.GITHUB_WORKFLOW; - this.action = process.env.GITHUB_ACTION; - this.actor = process.env.GITHUB_ACTOR; - this.job = process.env.GITHUB_JOB; - this.runNumber = parseInt(process.env.GITHUB_RUN_NUMBER, 10); - this.runId = parseInt(process.env.GITHUB_RUN_ID, 10); - } - get issue() { - const payload = this.payload; - return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pull_request || payload).number }); - } - get repo() { - if (process.env.GITHUB_REPOSITORY) { - const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); - return { owner, repo }; - } - if (this.payload.repository) { - return { - owner: this.payload.repository.owner.login, - repo: this.payload.repository.name - }; - } - throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'"); - } -} -exports.Context = Context; -//# sourceMappingURL=context.js.map +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -/***/ }), +// pkg/dist-src/index.js +var dist_src_exports = {}; +__export(dist_src_exports, { + createTokenAuth: () => createTokenAuth +}); +module.exports = __toCommonJS(dist_src_exports); -/***/ 5438: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +// pkg/dist-src/auth.js +var REGEX_IS_INSTALLATION_LEGACY = /^v1\./; +var REGEX_IS_INSTALLATION = /^ghs_/; +var REGEX_IS_USER_TO_SERVER = /^ghu_/; +async function auth(token) { + const isApp = token.split(/\./).length === 3; + const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token); + const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token); + const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth"; + return { + type: "token", + token, + tokenType + }; +} -"use strict"; +// pkg/dist-src/with-authorization-prefix.js +function withAuthorizationPrefix(token) { + if (token.split(/\./).length === 3) { + return `bearer ${token}`; + } + return `token ${token}`; +} -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getOctokit = exports.context = void 0; -const Context = __importStar(__nccwpck_require__(4087)); -const utils_1 = __nccwpck_require__(3030); -exports.context = new Context.Context(); -/** - * Returns a hydrated octokit ready to use for GitHub Actions - * - * @param token the repo PAT or GITHUB_TOKEN - * @param options other options to set - */ -function getOctokit(token, options) { - return new utils_1.GitHub(utils_1.getOctokitOptions(token, options)); +// pkg/dist-src/hook.js +async function hook(token, request, route, parameters) { + const endpoint = request.endpoint.merge( + route, + parameters + ); + endpoint.headers.authorization = withAuthorizationPrefix(token); + return request(endpoint); } -exports.getOctokit = getOctokit; -//# sourceMappingURL=github.js.map + +// pkg/dist-src/index.js +var createTokenAuth = function createTokenAuth2(token) { + if (!token) { + throw new Error("[@octokit/auth-token] No token passed to createTokenAuth"); + } + if (typeof token !== "string") { + throw new Error( + "[@octokit/auth-token] Token passed to createTokenAuth is not a string" + ); + } + token = token.replace(/^(token|bearer) +/i, ""); + return Object.assign(auth.bind(null, token), { + hook: hook.bind(null, token) + }); +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (0); + /***/ }), -/***/ 7914: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 6762: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// pkg/dist-src/index.js +var dist_src_exports = {}; +__export(dist_src_exports, { + Octokit: () => Octokit }); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; +module.exports = __toCommonJS(dist_src_exports); +var import_universal_user_agent = __nccwpck_require__(5030); +var import_before_after_hook = __nccwpck_require__(3682); +var import_request = __nccwpck_require__(6234); +var import_graphql = __nccwpck_require__(8467); +var import_auth_token = __nccwpck_require__(334); + +// pkg/dist-src/version.js +var VERSION = "5.1.0"; + +// pkg/dist-src/index.js +var noop = () => { }; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getApiBaseUrl = exports.getProxyAgent = exports.getAuthString = void 0; -const httpClient = __importStar(__nccwpck_require__(9925)); -function getAuthString(token, options) { - if (!token && !options.auth) { - throw new Error('Parameter token or opts.auth is required'); +var consoleWarn = console.warn.bind(console); +var consoleError = console.error.bind(console); +var userAgentTrail = `octokit-core.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`; +var Octokit = class { + static { + this.VERSION = VERSION; + } + static defaults(defaults) { + const OctokitWithDefaults = class extends this { + constructor(...args) { + const options = args[0] || {}; + if (typeof defaults === "function") { + super(defaults(options)); + return; + } + super( + Object.assign( + {}, + defaults, + options, + options.userAgent && defaults.userAgent ? { + userAgent: `${options.userAgent} ${defaults.userAgent}` + } : null + ) + ); + } + }; + return OctokitWithDefaults; + } + static { + this.plugins = []; + } + /** + * Attach a plugin (or many) to your Octokit instance. + * + * @example + * const API = Octokit.plugin(plugin1, plugin2, plugin3, ...) + */ + static plugin(...newPlugins) { + const currentPlugins = this.plugins; + const NewOctokit = class extends this { + static { + this.plugins = currentPlugins.concat( + newPlugins.filter((plugin) => !currentPlugins.includes(plugin)) + ); + } + }; + return NewOctokit; + } + constructor(options = {}) { + const hook = new import_before_after_hook.Collection(); + const requestDefaults = { + baseUrl: import_request.request.endpoint.DEFAULTS.baseUrl, + headers: {}, + request: Object.assign({}, options.request, { + // @ts-ignore internal usage only, no need to type + hook: hook.bind(null, "request") + }), + mediaType: { + previews: [], + format: "" + } + }; + requestDefaults.headers["user-agent"] = options.userAgent ? `${options.userAgent} ${userAgentTrail}` : userAgentTrail; + if (options.baseUrl) { + requestDefaults.baseUrl = options.baseUrl; } - else if (token && options.auth) { - throw new Error('Parameters token and opts.auth may not both be specified'); + if (options.previews) { + requestDefaults.mediaType.previews = options.previews; } - return typeof options.auth === 'string' ? options.auth : `token ${token}`; -} -exports.getAuthString = getAuthString; -function getProxyAgent(destinationUrl) { - const hc = new httpClient.HttpClient(); - return hc.getAgent(destinationUrl); -} -exports.getProxyAgent = getProxyAgent; -function getApiBaseUrl() { - return process.env['GITHUB_API_URL'] || 'https://api.github.com'; -} -exports.getApiBaseUrl = getApiBaseUrl; -//# sourceMappingURL=utils.js.map + if (options.timeZone) { + requestDefaults.headers["time-zone"] = options.timeZone; + } + this.request = import_request.request.defaults(requestDefaults); + this.graphql = (0, import_graphql.withCustomRequest)(this.request).defaults(requestDefaults); + this.log = Object.assign( + { + debug: noop, + info: noop, + warn: consoleWarn, + error: consoleError + }, + options.log + ); + this.hook = hook; + if (!options.authStrategy) { + if (!options.auth) { + this.auth = async () => ({ + type: "unauthenticated" + }); + } else { + const auth = (0, import_auth_token.createTokenAuth)(options.auth); + hook.wrap("request", auth.hook); + this.auth = auth; + } + } else { + const { authStrategy, ...otherOptions } = options; + const auth = authStrategy( + Object.assign( + { + request: this.request, + log: this.log, + // we pass the current octokit instance as well as its constructor options + // to allow for authentication strategies that return a new octokit instance + // that shares the same internal state as the current one. The original + // requirement for this was the "event-octokit" authentication strategy + // of https://github.com/probot/octokit-auth-probot. + octokit: this, + octokitOptions: otherOptions + }, + options.auth + ) + ); + hook.wrap("request", auth.hook); + this.auth = auth; + } + const classConstructor = this.constructor; + for (let i = 0; i < classConstructor.plugins.length; ++i) { + Object.assign(this, classConstructor.plugins[i](this, options)); + } + } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (0); + /***/ }), -/***/ 3030: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 9440: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); }; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getOctokitOptions = exports.GitHub = exports.context = void 0; -const Context = __importStar(__nccwpck_require__(4087)); -const Utils = __importStar(__nccwpck_require__(7914)); -// octokit + plugins -const core_1 = __nccwpck_require__(6762); -const plugin_rest_endpoint_methods_1 = __nccwpck_require__(3044); -const plugin_paginate_rest_1 = __nccwpck_require__(4193); -exports.context = new Context.Context(); -const baseUrl = Utils.getApiBaseUrl(); -const defaults = { - baseUrl, - request: { - agent: Utils.getProxyAgent(baseUrl) - } +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; }; -exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults); -/** - * Convience function to correctly format Octokit Options to pass into the constructor. - * - * @param token the repo PAT or GITHUB_TOKEN - * @param options other options to set - */ -function getOctokitOptions(token, options) { - const opts = Object.assign({}, options || {}); // Shallow clone - don't mutate the object provided by the caller - // Auth - const auth = Utils.getAuthString(token, opts); - if (auth) { - opts.auth = auth; - } - return opts; -} -exports.getOctokitOptions = getOctokitOptions; -//# sourceMappingURL=utils.js.map +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -/***/ }), +// pkg/dist-src/index.js +var dist_src_exports = {}; +__export(dist_src_exports, { + endpoint: () => endpoint +}); +module.exports = __toCommonJS(dist_src_exports); -/***/ 9925: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +// pkg/dist-src/defaults.js +var import_universal_user_agent = __nccwpck_require__(5030); -"use strict"; +// pkg/dist-src/version.js +var VERSION = "9.0.4"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const http = __nccwpck_require__(3685); -const https = __nccwpck_require__(5687); -const pm = __nccwpck_require__(6443); -let tunnel; -var HttpCodes; -(function (HttpCodes) { - HttpCodes[HttpCodes["OK"] = 200] = "OK"; - HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; - HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; - HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; - HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; - HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; - HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; - HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; - HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; - HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; - HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); -var Headers; -(function (Headers) { - Headers["Accept"] = "accept"; - Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); -var MediaTypes; -(function (MediaTypes) { - MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); -/** - * Returns the proxy URL, depending upon the supplied url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ -function getProxyUrl(serverUrl) { - let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); - return proxyUrl ? proxyUrl.href : ''; +// pkg/dist-src/defaults.js +var userAgent = `octokit-endpoint.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`; +var DEFAULTS = { + method: "GET", + baseUrl: "https://api.github.com", + headers: { + accept: "application/vnd.github.v3+json", + "user-agent": userAgent + }, + mediaType: { + format: "" + } +}; + +// pkg/dist-src/util/lowercase-keys.js +function lowercaseKeys(object) { + if (!object) { + return {}; + } + return Object.keys(object).reduce((newObj, key) => { + newObj[key.toLowerCase()] = object[key]; + return newObj; + }, {}); } -exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [ - HttpCodes.MovedPermanently, - HttpCodes.ResourceMoved, - HttpCodes.SeeOther, - HttpCodes.TemporaryRedirect, - HttpCodes.PermanentRedirect -]; -const HttpResponseRetryCodes = [ - HttpCodes.BadGateway, - HttpCodes.ServiceUnavailable, - HttpCodes.GatewayTimeout -]; -const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; -const ExponentialBackoffCeiling = 10; -const ExponentialBackoffTimeSlice = 5; -class HttpClientError extends Error { - constructor(message, statusCode) { - super(message); - this.name = 'HttpClientError'; - this.statusCode = statusCode; - Object.setPrototypeOf(this, HttpClientError.prototype); - } + +// pkg/dist-src/util/is-plain-object.js +function isPlainObject(value) { + if (typeof value !== "object" || value === null) + return false; + if (Object.prototype.toString.call(value) !== "[object Object]") + return false; + const proto = Object.getPrototypeOf(value); + if (proto === null) + return true; + const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor; + return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value); } -exports.HttpClientError = HttpClientError; -class HttpClientResponse { - constructor(message) { - this.message = message; + +// pkg/dist-src/util/merge-deep.js +function mergeDeep(defaults, options) { + const result = Object.assign({}, defaults); + Object.keys(options).forEach((key) => { + if (isPlainObject(options[key])) { + if (!(key in defaults)) + Object.assign(result, { [key]: options[key] }); + else + result[key] = mergeDeep(defaults[key], options[key]); + } else { + Object.assign(result, { [key]: options[key] }); } - readBody() { - return new Promise(async (resolve, reject) => { - let output = Buffer.alloc(0); - this.message.on('data', (chunk) => { - output = Buffer.concat([output, chunk]); - }); - this.message.on('end', () => { - resolve(output.toString()); - }); - }); + }); + return result; +} + +// pkg/dist-src/util/remove-undefined-properties.js +function removeUndefinedProperties(obj) { + for (const key in obj) { + if (obj[key] === void 0) { + delete obj[key]; } + } + return obj; } -exports.HttpClientResponse = HttpClientResponse; -function isHttps(requestUrl) { - let parsedUrl = new URL(requestUrl); - return parsedUrl.protocol === 'https:'; + +// pkg/dist-src/merge.js +function merge(defaults, route, options) { + if (typeof route === "string") { + let [method, url] = route.split(" "); + options = Object.assign(url ? { method, url } : { url: method }, options); + } else { + options = Object.assign({}, route); + } + options.headers = lowercaseKeys(options.headers); + removeUndefinedProperties(options); + removeUndefinedProperties(options.headers); + const mergedOptions = mergeDeep(defaults || {}, options); + if (options.url === "/graphql") { + if (defaults && defaults.mediaType.previews?.length) { + mergedOptions.mediaType.previews = defaults.mediaType.previews.filter( + (preview) => !mergedOptions.mediaType.previews.includes(preview) + ).concat(mergedOptions.mediaType.previews); + } + mergedOptions.mediaType.previews = (mergedOptions.mediaType.previews || []).map((preview) => preview.replace(/-preview/, "")); + } + return mergedOptions; } -exports.isHttps = isHttps; -class HttpClient { - constructor(userAgent, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = userAgent; - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { - if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; - } - this._socketTimeout = requestOptions.socketTimeout; - if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; - } - if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; - } - if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); - } - if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; - } - if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; - } - if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; - } - } - } - options(requestUrl, additionalHeaders) { - return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); - } - get(requestUrl, additionalHeaders) { - return this.request('GET', requestUrl, null, additionalHeaders || {}); - } - del(requestUrl, additionalHeaders) { - return this.request('DELETE', requestUrl, null, additionalHeaders || {}); - } - post(requestUrl, data, additionalHeaders) { - return this.request('POST', requestUrl, data, additionalHeaders || {}); - } - patch(requestUrl, data, additionalHeaders) { - return this.request('PATCH', requestUrl, data, additionalHeaders || {}); - } - put(requestUrl, data, additionalHeaders) { - return this.request('PUT', requestUrl, data, additionalHeaders || {}); - } - head(requestUrl, additionalHeaders) { - return this.request('HEAD', requestUrl, null, additionalHeaders || {}); + +// pkg/dist-src/util/add-query-parameters.js +function addQueryParameters(url, parameters) { + const separator = /\?/.test(url) ? "&" : "?"; + const names = Object.keys(parameters); + if (names.length === 0) { + return url; + } + return url + separator + names.map((name) => { + if (name === "q") { + return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+"); } - sendStream(verb, requestUrl, stream, additionalHeaders) { - return this.request(verb, requestUrl, stream, additionalHeaders); + return `${name}=${encodeURIComponent(parameters[name])}`; + }).join("&"); +} + +// pkg/dist-src/util/extract-url-variable-names.js +var urlVariableRegex = /\{[^}]+\}/g; +function removeNonChars(variableName) { + return variableName.replace(/^\W+|\W+$/g, "").split(/,/); +} +function extractUrlVariableNames(url) { + const matches = url.match(urlVariableRegex); + if (!matches) { + return []; + } + return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []); +} + +// pkg/dist-src/util/omit.js +function omit(object, keysToOmit) { + const result = { __proto__: null }; + for (const key of Object.keys(object)) { + if (keysToOmit.indexOf(key) === -1) { + result[key] = object[key]; } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ - async getJson(requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - let res = await this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async postJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async putJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async patchJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); + } + return result; +} + +// pkg/dist-src/util/url-template.js +function encodeReserved(str) { + return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) { + if (!/%[0-9A-Fa-f]/.test(part)) { + part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]"); } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ - async request(verb, requestUrl, data, headers) { - if (this._disposed) { - throw new Error('Client has already been disposed.'); - } - let parsedUrl = new URL(requestUrl); - let info = this._prepareRequest(verb, parsedUrl, headers); - // Only perform retries on reads since writes may not be idempotent. - let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 - ? this._maxRetries + 1 - : 1; - let numTries = 0; - let response; - while (numTries < maxTries) { - response = await this.requestRaw(info, data); - // Check if it's an authentication challenge - if (response && - response.message && - response.message.statusCode === HttpCodes.Unauthorized) { - let authenticationHandler; - for (let i = 0; i < this.handlers.length; i++) { - if (this.handlers[i].canHandleAuthentication(response)) { - authenticationHandler = this.handlers[i]; - break; - } - } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info, data); - } - else { - // We have received an unauthorized response but have no handlers to handle it. - // Let the response return to the caller. - return response; - } - } - let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && - this._allowRedirects && - redirectsRemaining > 0) { - const redirectUrl = response.message.headers['location']; - if (!redirectUrl) { - // if there's no location to redirect to, we won't - break; - } - let parsedRedirectUrl = new URL(redirectUrl); - if (parsedUrl.protocol == 'https:' && - parsedUrl.protocol != parsedRedirectUrl.protocol && - !this._allowRedirectDowngrade) { - throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); - } - // we need to finish reading the response before reassigning response - // which will leak the open socket. - await response.readBody(); - // strip authorization header if redirected to a different hostname - if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { - for (let header in headers) { - // header names are case insensitive - if (header.toLowerCase() === 'authorization') { - delete headers[header]; - } - } - } - // let's make the request with the new redirectUrl - info = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = await this.requestRaw(info, data); - redirectsRemaining--; - } - if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { - // If not a retry code, return immediately instead of retrying - return response; - } - numTries += 1; - if (numTries < maxTries) { - await response.readBody(); - await this._performExponentialBackoff(numTries); + return part; + }).join(""); +} +function encodeUnreserved(str) { + return encodeURIComponent(str).replace(/[!'()*]/g, function(c) { + return "%" + c.charCodeAt(0).toString(16).toUpperCase(); + }); +} +function encodeValue(operator, value, key) { + value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value); + if (key) { + return encodeUnreserved(key) + "=" + value; + } else { + return value; + } +} +function isDefined(value) { + return value !== void 0 && value !== null; +} +function isKeyOperator(operator) { + return operator === ";" || operator === "&" || operator === "?"; +} +function getValues(context, operator, key, modifier) { + var value = context[key], result = []; + if (isDefined(value) && value !== "") { + if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { + value = value.toString(); + if (modifier && modifier !== "*") { + value = value.substring(0, parseInt(modifier, 10)); + } + result.push( + encodeValue(operator, value, isKeyOperator(operator) ? key : "") + ); + } else { + if (modifier === "*") { + if (Array.isArray(value)) { + value.filter(isDefined).forEach(function(value2) { + result.push( + encodeValue(operator, value2, isKeyOperator(operator) ? key : "") + ); + }); + } else { + Object.keys(value).forEach(function(k) { + if (isDefined(value[k])) { + result.push(encodeValue(operator, value[k], k)); } + }); } - return response; - } - /** - * Needs to be called if keepAlive is set to true in request options. - */ - dispose() { - if (this._agent) { - this._agent.destroy(); - } - this._disposed = true; - } - /** - * Raw request. - * @param info - * @param data - */ - requestRaw(info, data) { - return new Promise((resolve, reject) => { - let callbackForResult = function (err, res) { - if (err) { - reject(err); - } - resolve(res); - }; - this.requestRawWithCallback(info, data, callbackForResult); - }); - } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ - requestRawWithCallback(info, data, onResult) { - let socket; - if (typeof data === 'string') { - info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); - } - let callbackCalled = false; - let handleResult = (err, res) => { - if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); - } - }; - let req = info.httpModule.request(info.options, (msg) => { - let res = new HttpClientResponse(msg); - handleResult(null, res); - }); - req.on('socket', sock => { - socket = sock; - }); - // If we ever get disconnected, we want the socket to timeout eventually - req.setTimeout(this._socketTimeout || 3 * 60000, () => { - if (socket) { - socket.end(); + } else { + const tmp = []; + if (Array.isArray(value)) { + value.filter(isDefined).forEach(function(value2) { + tmp.push(encodeValue(operator, value2)); + }); + } else { + Object.keys(value).forEach(function(k) { + if (isDefined(value[k])) { + tmp.push(encodeUnreserved(k)); + tmp.push(encodeValue(operator, value[k].toString())); } - handleResult(new Error('Request timeout: ' + info.options.path), null); - }); - req.on('error', function (err) { - // err has statusCode property - // res should have headers - handleResult(err, null); - }); - if (data && typeof data === 'string') { - req.write(data, 'utf8'); - } - if (data && typeof data !== 'string') { - data.on('close', function () { - req.end(); - }); - data.pipe(req); - } - else { - req.end(); - } - } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ - getAgent(serverUrl) { - let parsedUrl = new URL(serverUrl); - return this._getAgent(parsedUrl); - } - _prepareRequest(method, requestUrl, headers) { - const info = {}; - info.parsedUrl = requestUrl; - const usingSsl = info.parsedUrl.protocol === 'https:'; - info.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info.options = {}; - info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port - ? parseInt(info.parsedUrl.port) - : defaultPort; - info.options.path = - (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); - info.options.method = method; - info.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info.options.headers['user-agent'] = this.userAgent; - } - info.options.agent = this._getAgent(info.parsedUrl); - // gives handlers an opportunity to participate - if (this.handlers) { - this.handlers.forEach(handler => { - handler.prepareRequest(info.options); - }); + }); } - return info; - } - _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); + if (isKeyOperator(operator)) { + result.push(encodeUnreserved(key) + "=" + tmp.join(",")); + } else if (tmp.length !== 0) { + result.push(tmp.join(",")); } - return lowercaseKeys(headers || {}); + } } - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; - } - return additionalHeaders[header] || clientHeader || _default; + } else { + if (operator === ";") { + if (isDefined(value)) { + result.push(encodeUnreserved(key)); + } + } else if (value === "" && (operator === "&" || operator === "?")) { + result.push(encodeUnreserved(key) + "="); + } else if (value === "") { + result.push(""); } - _getAgent(parsedUrl) { - let agent; - let proxyUrl = pm.getProxyUrl(parsedUrl); - let useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; - } - if (this._keepAlive && !useProxy) { - agent = this._agent; - } - // if agent is already assigned use that agent. - if (!!agent) { - return agent; - } - const usingSsl = parsedUrl.protocol === 'https:'; - let maxSockets = 100; - if (!!this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; - } - if (useProxy) { - // If using proxy, need tunnel - if (!tunnel) { - tunnel = __nccwpck_require__(4294); - } - const agentOptions = { - maxSockets: maxSockets, - keepAlive: this._keepAlive, - proxy: { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`, - host: proxyUrl.hostname, - port: proxyUrl.port - } - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === 'https:'; - if (usingSsl) { - tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; - } - else { - tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; - } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; - } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { - const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; - } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; + } + return result; +} +function parseUrl(template) { + return { + expand: expand.bind(null, template) + }; +} +function expand(template, context) { + var operators = ["+", "#", ".", "/", ";", "?", "&"]; + template = template.replace( + /\{([^\{\}]+)\}|([^\{\}]+)/g, + function(_, expression, literal) { + if (expression) { + let operator = ""; + const values = []; + if (operators.indexOf(expression.charAt(0)) !== -1) { + operator = expression.charAt(0); + expression = expression.substr(1); } - if (usingSsl && this._ignoreSslError) { - // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process - // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options - // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { - rejectUnauthorized: false - }); + expression.split(/,/g).forEach(function(variable) { + var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); + values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3])); + }); + if (operator && operator !== "+") { + var separator = ","; + if (operator === "?") { + separator = "&"; + } else if (operator !== "#") { + separator = operator; + } + return (values.length !== 0 ? operator : "") + values.join(separator); + } else { + return values.join(","); } - return agent; + } else { + return encodeReserved(literal); + } } - _performExponentialBackoff(retryNumber) { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise(resolve => setTimeout(() => resolve(), ms)); - } - static dateTimeDeserializer(key, value) { - if (typeof value === 'string') { - let a = new Date(value); - if (!isNaN(a.valueOf())) { - return a; - } - } - return value; + ); + if (template === "/") { + return template; + } else { + return template.replace(/\/$/, ""); + } +} + +// pkg/dist-src/parse.js +function parse(options) { + let method = options.method.toUpperCase(); + let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}"); + let headers = Object.assign({}, options.headers); + let body; + let parameters = omit(options, [ + "method", + "baseUrl", + "url", + "headers", + "request", + "mediaType" + ]); + const urlVariableNames = extractUrlVariableNames(url); + url = parseUrl(url).expand(parameters); + if (!/^http/.test(url)) { + url = options.baseUrl + url; + } + const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl"); + const remainingParameters = omit(parameters, omittedParameters); + const isBinaryRequest = /application\/octet-stream/i.test(headers.accept); + if (!isBinaryRequest) { + if (options.mediaType.format) { + headers.accept = headers.accept.split(/,/).map( + (format) => format.replace( + /application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, + `application/vnd$1$2.${options.mediaType.format}` + ) + ).join(","); + } + if (url.endsWith("/graphql")) { + if (options.mediaType.previews?.length) { + const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || []; + headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => { + const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json"; + return `application/vnd.github.${preview}-preview${format}`; + }).join(","); + } } - async _processResponse(res, options) { - return new Promise(async (resolve, reject) => { - const statusCode = res.message.statusCode; - const response = { - statusCode: statusCode, - result: null, - headers: {} - }; - // not found leads to null obj returned - if (statusCode == HttpCodes.NotFound) { - resolve(response); - } - let obj; - let contents; - // get the result from the body - try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; - } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null - } - // note that 3xx redirects are handled by the http layer. - if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = 'Failed request: (' + statusCode + ')'; - } - let err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); - } - else { - resolve(response); - } - }); + } + if (["GET", "HEAD"].includes(method)) { + url = addQueryParameters(url, remainingParameters); + } else { + if ("data" in remainingParameters) { + body = remainingParameters.data; + } else { + if (Object.keys(remainingParameters).length) { + body = remainingParameters; + } } + } + if (!headers["content-type"] && typeof body !== "undefined") { + headers["content-type"] = "application/json; charset=utf-8"; + } + if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") { + body = ""; + } + return Object.assign( + { method, url, headers }, + typeof body !== "undefined" ? { body } : null, + options.request ? { request: options.request } : null + ); +} + +// pkg/dist-src/endpoint-with-defaults.js +function endpointWithDefaults(defaults, route, options) { + return parse(merge(defaults, route, options)); +} + +// pkg/dist-src/with-defaults.js +function withDefaults(oldDefaults, newDefaults) { + const DEFAULTS2 = merge(oldDefaults, newDefaults); + const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2); + return Object.assign(endpoint2, { + DEFAULTS: DEFAULTS2, + defaults: withDefaults.bind(null, DEFAULTS2), + merge: merge.bind(null, DEFAULTS2), + parse + }); } -exports.HttpClient = HttpClient; + +// pkg/dist-src/index.js +var endpoint = withDefaults(null, DEFAULTS); +// Annotate the CommonJS export names for ESM import in node: +0 && (0); /***/ }), -/***/ 6443: -/***/ ((__unused_webpack_module, exports) => { +/***/ 8467: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -function getProxyUrl(reqUrl) { - let usingSsl = reqUrl.protocol === 'https:'; - let proxyUrl; - if (checkBypass(reqUrl)) { - return proxyUrl; - } - let proxyVar; - if (usingSsl) { - proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY']; - } - else { - proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']; - } - if (proxyVar) { - proxyUrl = new URL(proxyVar); - } - return proxyUrl; -} -exports.getProxyUrl = getProxyUrl; -function checkBypass(reqUrl) { - if (!reqUrl.hostname) { - return false; - } - let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; - if (!noProxy) { - return false; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// pkg/dist-src/index.js +var dist_src_exports = {}; +__export(dist_src_exports, { + GraphqlResponseError: () => GraphqlResponseError, + graphql: () => graphql2, + withCustomRequest: () => withCustomRequest +}); +module.exports = __toCommonJS(dist_src_exports); +var import_request3 = __nccwpck_require__(6234); +var import_universal_user_agent = __nccwpck_require__(5030); + +// pkg/dist-src/version.js +var VERSION = "7.0.2"; + +// pkg/dist-src/with-defaults.js +var import_request2 = __nccwpck_require__(6234); + +// pkg/dist-src/graphql.js +var import_request = __nccwpck_require__(6234); + +// pkg/dist-src/error.js +function _buildMessageForResponseErrors(data) { + return `Request failed due to following response errors: +` + data.errors.map((e) => ` - ${e.message}`).join("\n"); +} +var GraphqlResponseError = class extends Error { + constructor(request2, headers, response) { + super(_buildMessageForResponseErrors(response)); + this.request = request2; + this.headers = headers; + this.response = response; + this.name = "GraphqlResponseError"; + this.errors = response.errors; + this.data = response.data; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); } - // Determine the request port - let reqPort; - if (reqUrl.port) { - reqPort = Number(reqUrl.port); + } +}; + +// pkg/dist-src/graphql.js +var NON_VARIABLE_OPTIONS = [ + "method", + "baseUrl", + "url", + "headers", + "request", + "query", + "mediaType" +]; +var FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"]; +var GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/; +function graphql(request2, query, options) { + if (options) { + if (typeof query === "string" && "query" in options) { + return Promise.reject( + new Error(`[@octokit/graphql] "query" cannot be used as variable name`) + ); } - else if (reqUrl.protocol === 'http:') { - reqPort = 80; + for (const key in options) { + if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) + continue; + return Promise.reject( + new Error( + `[@octokit/graphql] "${key}" cannot be used as variable name` + ) + ); } - else if (reqUrl.protocol === 'https:') { - reqPort = 443; + } + const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query; + const requestOptions = Object.keys( + parsedOptions + ).reduce((result, key) => { + if (NON_VARIABLE_OPTIONS.includes(key)) { + result[key] = parsedOptions[key]; + return result; } - // Format the request hostname and hostname with port - let upperReqHosts = [reqUrl.hostname.toUpperCase()]; - if (typeof reqPort === 'number') { - upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); + if (!result.variables) { + result.variables = {}; } - // Compare request host against noproxy - for (let upperNoProxyItem of noProxy - .split(',') - .map(x => x.trim().toUpperCase()) - .filter(x => x)) { - if (upperReqHosts.some(x => x === upperNoProxyItem)) { - return true; - } + result.variables[key] = parsedOptions[key]; + return result; + }, {}); + const baseUrl = parsedOptions.baseUrl || request2.endpoint.DEFAULTS.baseUrl; + if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) { + requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql"); + } + return request2(requestOptions).then((response) => { + if (response.data.errors) { + const headers = {}; + for (const key of Object.keys(response.headers)) { + headers[key] = response.headers[key]; + } + throw new GraphqlResponseError( + requestOptions, + headers, + response.data + ); } - return false; + return response.data.data; + }); } -exports.checkBypass = checkBypass; + +// pkg/dist-src/with-defaults.js +function withDefaults(request2, newDefaults) { + const newRequest = request2.defaults(newDefaults); + const newApi = (query, options) => { + return graphql(newRequest, query, options); + }; + return Object.assign(newApi, { + defaults: withDefaults.bind(null, newRequest), + endpoint: newRequest.endpoint + }); +} + +// pkg/dist-src/index.js +var graphql2 = withDefaults(import_request3.request, { + headers: { + "user-agent": `octokit-graphql.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` + }, + method: "POST", + url: "/graphql" +}); +function withCustomRequest(customRequest) { + return withDefaults(customRequest, { + method: "POST", + url: "/graphql" + }); +} +// Annotate the CommonJS export names for ESM import in node: +0 && (0); /***/ }), -/***/ 334: -/***/ ((__unused_webpack_module, exports) => { +/***/ 4193: +/***/ ((module) => { "use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// pkg/dist-src/index.js +var dist_src_exports = {}; +__export(dist_src_exports, { + composePaginateRest: () => composePaginateRest, + isPaginatingEndpoint: () => isPaginatingEndpoint, + paginateRest: () => paginateRest, + paginatingEndpoints: () => paginatingEndpoints +}); +module.exports = __toCommonJS(dist_src_exports); + +// pkg/dist-src/version.js +var VERSION = "9.1.5"; -Object.defineProperty(exports, "__esModule", ({ value: true })); +// pkg/dist-src/normalize-paginated-list-response.js +function normalizePaginatedListResponse(response) { + if (!response.data) { + return { + ...response, + data: [] + }; + } + const responseNeedsNormalization = "total_count" in response.data && !("url" in response.data); + if (!responseNeedsNormalization) + return response; + const incompleteResults = response.data.incomplete_results; + const repositorySelection = response.data.repository_selection; + const totalCount = response.data.total_count; + delete response.data.incomplete_results; + delete response.data.repository_selection; + delete response.data.total_count; + const namespaceKey = Object.keys(response.data)[0]; + const data = response.data[namespaceKey]; + response.data = data; + if (typeof incompleteResults !== "undefined") { + response.data.incomplete_results = incompleteResults; + } + if (typeof repositorySelection !== "undefined") { + response.data.repository_selection = repositorySelection; + } + response.data.total_count = totalCount; + return response; +} -async function auth(token) { - const tokenType = token.split(/\./).length === 3 ? "app" : /^v\d+\./.test(token) ? "installation" : "oauth"; +// pkg/dist-src/iterator.js +function iterator(octokit, route, parameters) { + const options = typeof route === "function" ? route.endpoint(parameters) : octokit.request.endpoint(route, parameters); + const requestMethod = typeof route === "function" ? route : octokit.request; + const method = options.method; + const headers = options.headers; + let url = options.url; return { - type: "token", - token: token, - tokenType + [Symbol.asyncIterator]: () => ({ + async next() { + if (!url) + return { done: true }; + try { + const response = await requestMethod({ method, url, headers }); + const normalizedResponse = normalizePaginatedListResponse(response); + url = ((normalizedResponse.headers.link || "").match( + /<([^>]+)>;\s*rel="next"/ + ) || [])[1]; + return { value: normalizedResponse }; + } catch (error) { + if (error.status !== 409) + throw error; + url = ""; + return { + value: { + status: 200, + headers: {}, + data: [] + } + }; + } + } + }) }; } -/** - * Prefix token for usage in the Authorization header - * - * @param token OAuth token or JSON Web Token - */ -function withAuthorizationPrefix(token) { - if (token.split(/\./).length === 3) { - return `bearer ${token}`; +// pkg/dist-src/paginate.js +function paginate(octokit, route, parameters, mapFn) { + if (typeof parameters === "function") { + mapFn = parameters; + parameters = void 0; } - - return `token ${token}`; + return gather( + octokit, + [], + iterator(octokit, route, parameters)[Symbol.asyncIterator](), + mapFn + ); } - -async function hook(token, request, route, parameters) { - const endpoint = request.endpoint.merge(route, parameters); - endpoint.headers.authorization = withAuthorizationPrefix(token); - return request(endpoint); +function gather(octokit, results, iterator2, mapFn) { + return iterator2.next().then((result) => { + if (result.done) { + return results; + } + let earlyExit = false; + function done() { + earlyExit = true; + } + results = results.concat( + mapFn ? mapFn(result.value, done) : result.value.data + ); + if (earlyExit) { + return results; + } + return gather(octokit, results, iterator2, mapFn); + }); } -const createTokenAuth = function createTokenAuth(token) { - if (!token) { - throw new Error("[@octokit/auth-token] No token passed to createTokenAuth"); - } +// pkg/dist-src/compose-paginate.js +var composePaginateRest = Object.assign(paginate, { + iterator +}); - if (typeof token !== "string") { - throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string"); - } +// pkg/dist-src/generated/paginating-endpoints.js +var paginatingEndpoints = [ + "GET /advisories", + "GET /app/hook/deliveries", + "GET /app/installation-requests", + "GET /app/installations", + "GET /assignments/{assignment_id}/accepted_assignments", + "GET /classrooms", + "GET /classrooms/{classroom_id}/assignments", + "GET /enterprises/{enterprise}/dependabot/alerts", + "GET /enterprises/{enterprise}/secret-scanning/alerts", + "GET /events", + "GET /gists", + "GET /gists/public", + "GET /gists/starred", + "GET /gists/{gist_id}/comments", + "GET /gists/{gist_id}/commits", + "GET /gists/{gist_id}/forks", + "GET /installation/repositories", + "GET /issues", + "GET /licenses", + "GET /marketplace_listing/plans", + "GET /marketplace_listing/plans/{plan_id}/accounts", + "GET /marketplace_listing/stubbed/plans", + "GET /marketplace_listing/stubbed/plans/{plan_id}/accounts", + "GET /networks/{owner}/{repo}/events", + "GET /notifications", + "GET /organizations", + "GET /orgs/{org}/actions/cache/usage-by-repository", + "GET /orgs/{org}/actions/permissions/repositories", + "GET /orgs/{org}/actions/runners", + "GET /orgs/{org}/actions/secrets", + "GET /orgs/{org}/actions/secrets/{secret_name}/repositories", + "GET /orgs/{org}/actions/variables", + "GET /orgs/{org}/actions/variables/{name}/repositories", + "GET /orgs/{org}/blocks", + "GET /orgs/{org}/code-scanning/alerts", + "GET /orgs/{org}/codespaces", + "GET /orgs/{org}/codespaces/secrets", + "GET /orgs/{org}/codespaces/secrets/{secret_name}/repositories", + "GET /orgs/{org}/copilot/billing/seats", + "GET /orgs/{org}/dependabot/alerts", + "GET /orgs/{org}/dependabot/secrets", + "GET /orgs/{org}/dependabot/secrets/{secret_name}/repositories", + "GET /orgs/{org}/events", + "GET /orgs/{org}/failed_invitations", + "GET /orgs/{org}/hooks", + "GET /orgs/{org}/hooks/{hook_id}/deliveries", + "GET /orgs/{org}/installations", + "GET /orgs/{org}/invitations", + "GET /orgs/{org}/invitations/{invitation_id}/teams", + "GET /orgs/{org}/issues", + "GET /orgs/{org}/members", + "GET /orgs/{org}/members/{username}/codespaces", + "GET /orgs/{org}/migrations", + "GET /orgs/{org}/migrations/{migration_id}/repositories", + "GET /orgs/{org}/outside_collaborators", + "GET /orgs/{org}/packages", + "GET /orgs/{org}/packages/{package_type}/{package_name}/versions", + "GET /orgs/{org}/personal-access-token-requests", + "GET /orgs/{org}/personal-access-token-requests/{pat_request_id}/repositories", + "GET /orgs/{org}/personal-access-tokens", + "GET /orgs/{org}/personal-access-tokens/{pat_id}/repositories", + "GET /orgs/{org}/projects", + "GET /orgs/{org}/properties/values", + "GET /orgs/{org}/public_members", + "GET /orgs/{org}/repos", + "GET /orgs/{org}/rulesets", + "GET /orgs/{org}/rulesets/rule-suites", + "GET /orgs/{org}/secret-scanning/alerts", + "GET /orgs/{org}/security-advisories", + "GET /orgs/{org}/teams", + "GET /orgs/{org}/teams/{team_slug}/discussions", + "GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments", + "GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions", + "GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions", + "GET /orgs/{org}/teams/{team_slug}/invitations", + "GET /orgs/{org}/teams/{team_slug}/members", + "GET /orgs/{org}/teams/{team_slug}/projects", + "GET /orgs/{org}/teams/{team_slug}/repos", + "GET /orgs/{org}/teams/{team_slug}/teams", + "GET /projects/columns/{column_id}/cards", + "GET /projects/{project_id}/collaborators", + "GET /projects/{project_id}/columns", + "GET /repos/{owner}/{repo}/actions/artifacts", + "GET /repos/{owner}/{repo}/actions/caches", + "GET /repos/{owner}/{repo}/actions/organization-secrets", + "GET /repos/{owner}/{repo}/actions/organization-variables", + "GET /repos/{owner}/{repo}/actions/runners", + "GET /repos/{owner}/{repo}/actions/runs", + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts", + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs", + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs", + "GET /repos/{owner}/{repo}/actions/secrets", + "GET /repos/{owner}/{repo}/actions/variables", + "GET /repos/{owner}/{repo}/actions/workflows", + "GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs", + "GET /repos/{owner}/{repo}/activity", + "GET /repos/{owner}/{repo}/assignees", + "GET /repos/{owner}/{repo}/branches", + "GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations", + "GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs", + "GET /repos/{owner}/{repo}/code-scanning/alerts", + "GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances", + "GET /repos/{owner}/{repo}/code-scanning/analyses", + "GET /repos/{owner}/{repo}/codespaces", + "GET /repos/{owner}/{repo}/codespaces/devcontainers", + "GET /repos/{owner}/{repo}/codespaces/secrets", + "GET /repos/{owner}/{repo}/collaborators", + "GET /repos/{owner}/{repo}/comments", + "GET /repos/{owner}/{repo}/comments/{comment_id}/reactions", + "GET /repos/{owner}/{repo}/commits", + "GET /repos/{owner}/{repo}/commits/{commit_sha}/comments", + "GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls", + "GET /repos/{owner}/{repo}/commits/{ref}/check-runs", + "GET /repos/{owner}/{repo}/commits/{ref}/check-suites", + "GET /repos/{owner}/{repo}/commits/{ref}/status", + "GET /repos/{owner}/{repo}/commits/{ref}/statuses", + "GET /repos/{owner}/{repo}/contributors", + "GET /repos/{owner}/{repo}/dependabot/alerts", + "GET /repos/{owner}/{repo}/dependabot/secrets", + "GET /repos/{owner}/{repo}/deployments", + "GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses", + "GET /repos/{owner}/{repo}/environments", + "GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies", + "GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps", + "GET /repos/{owner}/{repo}/events", + "GET /repos/{owner}/{repo}/forks", + "GET /repos/{owner}/{repo}/hooks", + "GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries", + "GET /repos/{owner}/{repo}/invitations", + "GET /repos/{owner}/{repo}/issues", + "GET /repos/{owner}/{repo}/issues/comments", + "GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions", + "GET /repos/{owner}/{repo}/issues/events", + "GET /repos/{owner}/{repo}/issues/{issue_number}/comments", + "GET /repos/{owner}/{repo}/issues/{issue_number}/events", + "GET /repos/{owner}/{repo}/issues/{issue_number}/labels", + "GET /repos/{owner}/{repo}/issues/{issue_number}/reactions", + "GET /repos/{owner}/{repo}/issues/{issue_number}/timeline", + "GET /repos/{owner}/{repo}/keys", + "GET /repos/{owner}/{repo}/labels", + "GET /repos/{owner}/{repo}/milestones", + "GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels", + "GET /repos/{owner}/{repo}/notifications", + "GET /repos/{owner}/{repo}/pages/builds", + "GET /repos/{owner}/{repo}/projects", + "GET /repos/{owner}/{repo}/pulls", + "GET /repos/{owner}/{repo}/pulls/comments", + "GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions", + "GET /repos/{owner}/{repo}/pulls/{pull_number}/comments", + "GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", + "GET /repos/{owner}/{repo}/pulls/{pull_number}/files", + "GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews", + "GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments", + "GET /repos/{owner}/{repo}/releases", + "GET /repos/{owner}/{repo}/releases/{release_id}/assets", + "GET /repos/{owner}/{repo}/releases/{release_id}/reactions", + "GET /repos/{owner}/{repo}/rules/branches/{branch}", + "GET /repos/{owner}/{repo}/rulesets", + "GET /repos/{owner}/{repo}/rulesets/rule-suites", + "GET /repos/{owner}/{repo}/secret-scanning/alerts", + "GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations", + "GET /repos/{owner}/{repo}/security-advisories", + "GET /repos/{owner}/{repo}/stargazers", + "GET /repos/{owner}/{repo}/subscribers", + "GET /repos/{owner}/{repo}/tags", + "GET /repos/{owner}/{repo}/teams", + "GET /repos/{owner}/{repo}/topics", + "GET /repositories", + "GET /repositories/{repository_id}/environments/{environment_name}/secrets", + "GET /repositories/{repository_id}/environments/{environment_name}/variables", + "GET /search/code", + "GET /search/commits", + "GET /search/issues", + "GET /search/labels", + "GET /search/repositories", + "GET /search/topics", + "GET /search/users", + "GET /teams/{team_id}/discussions", + "GET /teams/{team_id}/discussions/{discussion_number}/comments", + "GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions", + "GET /teams/{team_id}/discussions/{discussion_number}/reactions", + "GET /teams/{team_id}/invitations", + "GET /teams/{team_id}/members", + "GET /teams/{team_id}/projects", + "GET /teams/{team_id}/repos", + "GET /teams/{team_id}/teams", + "GET /user/blocks", + "GET /user/codespaces", + "GET /user/codespaces/secrets", + "GET /user/emails", + "GET /user/followers", + "GET /user/following", + "GET /user/gpg_keys", + "GET /user/installations", + "GET /user/installations/{installation_id}/repositories", + "GET /user/issues", + "GET /user/keys", + "GET /user/marketplace_purchases", + "GET /user/marketplace_purchases/stubbed", + "GET /user/memberships/orgs", + "GET /user/migrations", + "GET /user/migrations/{migration_id}/repositories", + "GET /user/orgs", + "GET /user/packages", + "GET /user/packages/{package_type}/{package_name}/versions", + "GET /user/public_emails", + "GET /user/repos", + "GET /user/repository_invitations", + "GET /user/social_accounts", + "GET /user/ssh_signing_keys", + "GET /user/starred", + "GET /user/subscriptions", + "GET /user/teams", + "GET /users", + "GET /users/{username}/events", + "GET /users/{username}/events/orgs/{org}", + "GET /users/{username}/events/public", + "GET /users/{username}/followers", + "GET /users/{username}/following", + "GET /users/{username}/gists", + "GET /users/{username}/gpg_keys", + "GET /users/{username}/keys", + "GET /users/{username}/orgs", + "GET /users/{username}/packages", + "GET /users/{username}/projects", + "GET /users/{username}/received_events", + "GET /users/{username}/received_events/public", + "GET /users/{username}/repos", + "GET /users/{username}/social_accounts", + "GET /users/{username}/ssh_signing_keys", + "GET /users/{username}/starred", + "GET /users/{username}/subscriptions" +]; - token = token.replace(/^(token|bearer) +/i, ""); - return Object.assign(auth.bind(null, token), { - hook: hook.bind(null, token) - }); -}; +// pkg/dist-src/paginating-endpoints.js +function isPaginatingEndpoint(arg) { + if (typeof arg === "string") { + return paginatingEndpoints.includes(arg); + } else { + return false; + } +} -exports.createTokenAuth = createTokenAuth; -//# sourceMappingURL=index.js.map +// pkg/dist-src/index.js +function paginateRest(octokit) { + return { + paginate: Object.assign(paginate.bind(null, octokit), { + iterator: iterator.bind(null, octokit) + }) + }; +} +paginateRest.VERSION = VERSION; +// Annotate the CommonJS export names for ESM import in node: +0 && (0); /***/ }), -/***/ 6762: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 3044: +/***/ ((module) => { "use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -Object.defineProperty(exports, "__esModule", ({ value: true })); - -var universalUserAgent = __nccwpck_require__(5030); -var beforeAfterHook = __nccwpck_require__(3682); -var request = __nccwpck_require__(6234); -var graphql = __nccwpck_require__(8467); -var authToken = __nccwpck_require__(334); +// pkg/dist-src/index.js +var dist_src_exports = {}; +__export(dist_src_exports, { + legacyRestEndpointMethods: () => legacyRestEndpointMethods, + restEndpointMethods: () => restEndpointMethods +}); +module.exports = __toCommonJS(dist_src_exports); -function _objectWithoutPropertiesLoose(source, excluded) { - if (source == null) return {}; - var target = {}; - var sourceKeys = Object.keys(source); - var key, i; +// pkg/dist-src/version.js +var VERSION = "10.2.0"; - for (i = 0; i < sourceKeys.length; i++) { - key = sourceKeys[i]; - if (excluded.indexOf(key) >= 0) continue; - target[key] = source[key]; +// pkg/dist-src/generated/endpoints.js +var Endpoints = { + actions: { + addCustomLabelsToSelfHostedRunnerForOrg: [ + "POST /orgs/{org}/actions/runners/{runner_id}/labels" + ], + addCustomLabelsToSelfHostedRunnerForRepo: [ + "POST /repos/{owner}/{repo}/actions/runners/{runner_id}/labels" + ], + addSelectedRepoToOrgSecret: [ + "PUT /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}" + ], + addSelectedRepoToOrgVariable: [ + "PUT /orgs/{org}/actions/variables/{name}/repositories/{repository_id}" + ], + approveWorkflowRun: [ + "POST /repos/{owner}/{repo}/actions/runs/{run_id}/approve" + ], + cancelWorkflowRun: [ + "POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel" + ], + createEnvironmentVariable: [ + "POST /repositories/{repository_id}/environments/{environment_name}/variables" + ], + createOrUpdateEnvironmentSecret: [ + "PUT /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}" + ], + createOrUpdateOrgSecret: ["PUT /orgs/{org}/actions/secrets/{secret_name}"], + createOrUpdateRepoSecret: [ + "PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}" + ], + createOrgVariable: ["POST /orgs/{org}/actions/variables"], + createRegistrationTokenForOrg: [ + "POST /orgs/{org}/actions/runners/registration-token" + ], + createRegistrationTokenForRepo: [ + "POST /repos/{owner}/{repo}/actions/runners/registration-token" + ], + createRemoveTokenForOrg: ["POST /orgs/{org}/actions/runners/remove-token"], + createRemoveTokenForRepo: [ + "POST /repos/{owner}/{repo}/actions/runners/remove-token" + ], + createRepoVariable: ["POST /repos/{owner}/{repo}/actions/variables"], + createWorkflowDispatch: [ + "POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches" + ], + deleteActionsCacheById: [ + "DELETE /repos/{owner}/{repo}/actions/caches/{cache_id}" + ], + deleteActionsCacheByKey: [ + "DELETE /repos/{owner}/{repo}/actions/caches{?key,ref}" + ], + deleteArtifact: [ + "DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id}" + ], + deleteEnvironmentSecret: [ + "DELETE /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}" + ], + deleteEnvironmentVariable: [ + "DELETE /repositories/{repository_id}/environments/{environment_name}/variables/{name}" + ], + deleteOrgSecret: ["DELETE /orgs/{org}/actions/secrets/{secret_name}"], + deleteOrgVariable: ["DELETE /orgs/{org}/actions/variables/{name}"], + deleteRepoSecret: [ + "DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name}" + ], + deleteRepoVariable: [ + "DELETE /repos/{owner}/{repo}/actions/variables/{name}" + ], + deleteSelfHostedRunnerFromOrg: [ + "DELETE /orgs/{org}/actions/runners/{runner_id}" + ], + deleteSelfHostedRunnerFromRepo: [ + "DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}" + ], + deleteWorkflowRun: ["DELETE /repos/{owner}/{repo}/actions/runs/{run_id}"], + deleteWorkflowRunLogs: [ + "DELETE /repos/{owner}/{repo}/actions/runs/{run_id}/logs" + ], + disableSelectedRepositoryGithubActionsOrganization: [ + "DELETE /orgs/{org}/actions/permissions/repositories/{repository_id}" + ], + disableWorkflow: [ + "PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable" + ], + downloadArtifact: [ + "GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}" + ], + downloadJobLogsForWorkflowRun: [ + "GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs" + ], + downloadWorkflowRunAttemptLogs: [ + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/logs" + ], + downloadWorkflowRunLogs: [ + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs" + ], + enableSelectedRepositoryGithubActionsOrganization: [ + "PUT /orgs/{org}/actions/permissions/repositories/{repository_id}" + ], + enableWorkflow: [ + "PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable" + ], + forceCancelWorkflowRun: [ + "POST /repos/{owner}/{repo}/actions/runs/{run_id}/force-cancel" + ], + generateRunnerJitconfigForOrg: [ + "POST /orgs/{org}/actions/runners/generate-jitconfig" + ], + generateRunnerJitconfigForRepo: [ + "POST /repos/{owner}/{repo}/actions/runners/generate-jitconfig" + ], + getActionsCacheList: ["GET /repos/{owner}/{repo}/actions/caches"], + getActionsCacheUsage: ["GET /repos/{owner}/{repo}/actions/cache/usage"], + getActionsCacheUsageByRepoForOrg: [ + "GET /orgs/{org}/actions/cache/usage-by-repository" + ], + getActionsCacheUsageForOrg: ["GET /orgs/{org}/actions/cache/usage"], + getAllowedActionsOrganization: [ + "GET /orgs/{org}/actions/permissions/selected-actions" + ], + getAllowedActionsRepository: [ + "GET /repos/{owner}/{repo}/actions/permissions/selected-actions" + ], + getArtifact: ["GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}"], + getEnvironmentPublicKey: [ + "GET /repositories/{repository_id}/environments/{environment_name}/secrets/public-key" + ], + getEnvironmentSecret: [ + "GET /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}" + ], + getEnvironmentVariable: [ + "GET /repositories/{repository_id}/environments/{environment_name}/variables/{name}" + ], + getGithubActionsDefaultWorkflowPermissionsOrganization: [ + "GET /orgs/{org}/actions/permissions/workflow" + ], + getGithubActionsDefaultWorkflowPermissionsRepository: [ + "GET /repos/{owner}/{repo}/actions/permissions/workflow" + ], + getGithubActionsPermissionsOrganization: [ + "GET /orgs/{org}/actions/permissions" + ], + getGithubActionsPermissionsRepository: [ + "GET /repos/{owner}/{repo}/actions/permissions" + ], + getJobForWorkflowRun: ["GET /repos/{owner}/{repo}/actions/jobs/{job_id}"], + getOrgPublicKey: ["GET /orgs/{org}/actions/secrets/public-key"], + getOrgSecret: ["GET /orgs/{org}/actions/secrets/{secret_name}"], + getOrgVariable: ["GET /orgs/{org}/actions/variables/{name}"], + getPendingDeploymentsForRun: [ + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments" + ], + getRepoPermissions: [ + "GET /repos/{owner}/{repo}/actions/permissions", + {}, + { renamed: ["actions", "getGithubActionsPermissionsRepository"] } + ], + getRepoPublicKey: ["GET /repos/{owner}/{repo}/actions/secrets/public-key"], + getRepoSecret: ["GET /repos/{owner}/{repo}/actions/secrets/{secret_name}"], + getRepoVariable: ["GET /repos/{owner}/{repo}/actions/variables/{name}"], + getReviewsForRun: [ + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/approvals" + ], + getSelfHostedRunnerForOrg: ["GET /orgs/{org}/actions/runners/{runner_id}"], + getSelfHostedRunnerForRepo: [ + "GET /repos/{owner}/{repo}/actions/runners/{runner_id}" + ], + getWorkflow: ["GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}"], + getWorkflowAccessToRepository: [ + "GET /repos/{owner}/{repo}/actions/permissions/access" + ], + getWorkflowRun: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}"], + getWorkflowRunAttempt: [ + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}" + ], + getWorkflowRunUsage: [ + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing" + ], + getWorkflowUsage: [ + "GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing" + ], + listArtifactsForRepo: ["GET /repos/{owner}/{repo}/actions/artifacts"], + listEnvironmentSecrets: [ + "GET /repositories/{repository_id}/environments/{environment_name}/secrets" + ], + listEnvironmentVariables: [ + "GET /repositories/{repository_id}/environments/{environment_name}/variables" + ], + listJobsForWorkflowRun: [ + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs" + ], + listJobsForWorkflowRunAttempt: [ + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs" + ], + listLabelsForSelfHostedRunnerForOrg: [ + "GET /orgs/{org}/actions/runners/{runner_id}/labels" + ], + listLabelsForSelfHostedRunnerForRepo: [ + "GET /repos/{owner}/{repo}/actions/runners/{runner_id}/labels" + ], + listOrgSecrets: ["GET /orgs/{org}/actions/secrets"], + listOrgVariables: ["GET /orgs/{org}/actions/variables"], + listRepoOrganizationSecrets: [ + "GET /repos/{owner}/{repo}/actions/organization-secrets" + ], + listRepoOrganizationVariables: [ + "GET /repos/{owner}/{repo}/actions/organization-variables" + ], + listRepoSecrets: ["GET /repos/{owner}/{repo}/actions/secrets"], + listRepoVariables: ["GET /repos/{owner}/{repo}/actions/variables"], + listRepoWorkflows: ["GET /repos/{owner}/{repo}/actions/workflows"], + listRunnerApplicationsForOrg: ["GET /orgs/{org}/actions/runners/downloads"], + listRunnerApplicationsForRepo: [ + "GET /repos/{owner}/{repo}/actions/runners/downloads" + ], + listSelectedReposForOrgSecret: [ + "GET /orgs/{org}/actions/secrets/{secret_name}/repositories" + ], + listSelectedReposForOrgVariable: [ + "GET /orgs/{org}/actions/variables/{name}/repositories" + ], + listSelectedRepositoriesEnabledGithubActionsOrganization: [ + "GET /orgs/{org}/actions/permissions/repositories" + ], + listSelfHostedRunnersForOrg: ["GET /orgs/{org}/actions/runners"], + listSelfHostedRunnersForRepo: ["GET /repos/{owner}/{repo}/actions/runners"], + listWorkflowRunArtifacts: [ + "GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts" + ], + listWorkflowRuns: [ + "GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs" + ], + listWorkflowRunsForRepo: ["GET /repos/{owner}/{repo}/actions/runs"], + reRunJobForWorkflowRun: [ + "POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun" + ], + reRunWorkflow: ["POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun"], + reRunWorkflowFailedJobs: [ + "POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun-failed-jobs" + ], + removeAllCustomLabelsFromSelfHostedRunnerForOrg: [ + "DELETE /orgs/{org}/actions/runners/{runner_id}/labels" + ], + removeAllCustomLabelsFromSelfHostedRunnerForRepo: [ + "DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}/labels" + ], + removeCustomLabelFromSelfHostedRunnerForOrg: [ + "DELETE /orgs/{org}/actions/runners/{runner_id}/labels/{name}" + ], + removeCustomLabelFromSelfHostedRunnerForRepo: [ + "DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}/labels/{name}" + ], + removeSelectedRepoFromOrgSecret: [ + "DELETE /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}" + ], + removeSelectedRepoFromOrgVariable: [ + "DELETE /orgs/{org}/actions/variables/{name}/repositories/{repository_id}" + ], + reviewCustomGatesForRun: [ + "POST /repos/{owner}/{repo}/actions/runs/{run_id}/deployment_protection_rule" + ], + reviewPendingDeploymentsForRun: [ + "POST /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments" + ], + setAllowedActionsOrganization: [ + "PUT /orgs/{org}/actions/permissions/selected-actions" + ], + setAllowedActionsRepository: [ + "PUT /repos/{owner}/{repo}/actions/permissions/selected-actions" + ], + setCustomLabelsForSelfHostedRunnerForOrg: [ + "PUT /orgs/{org}/actions/runners/{runner_id}/labels" + ], + setCustomLabelsForSelfHostedRunnerForRepo: [ + "PUT /repos/{owner}/{repo}/actions/runners/{runner_id}/labels" + ], + setGithubActionsDefaultWorkflowPermissionsOrganization: [ + "PUT /orgs/{org}/actions/permissions/workflow" + ], + setGithubActionsDefaultWorkflowPermissionsRepository: [ + "PUT /repos/{owner}/{repo}/actions/permissions/workflow" + ], + setGithubActionsPermissionsOrganization: [ + "PUT /orgs/{org}/actions/permissions" + ], + setGithubActionsPermissionsRepository: [ + "PUT /repos/{owner}/{repo}/actions/permissions" + ], + setSelectedReposForOrgSecret: [ + "PUT /orgs/{org}/actions/secrets/{secret_name}/repositories" + ], + setSelectedReposForOrgVariable: [ + "PUT /orgs/{org}/actions/variables/{name}/repositories" + ], + setSelectedRepositoriesEnabledGithubActionsOrganization: [ + "PUT /orgs/{org}/actions/permissions/repositories" + ], + setWorkflowAccessToRepository: [ + "PUT /repos/{owner}/{repo}/actions/permissions/access" + ], + updateEnvironmentVariable: [ + "PATCH /repositories/{repository_id}/environments/{environment_name}/variables/{name}" + ], + updateOrgVariable: ["PATCH /orgs/{org}/actions/variables/{name}"], + updateRepoVariable: [ + "PATCH /repos/{owner}/{repo}/actions/variables/{name}" + ] + }, + activity: { + checkRepoIsStarredByAuthenticatedUser: ["GET /user/starred/{owner}/{repo}"], + deleteRepoSubscription: ["DELETE /repos/{owner}/{repo}/subscription"], + deleteThreadSubscription: [ + "DELETE /notifications/threads/{thread_id}/subscription" + ], + getFeeds: ["GET /feeds"], + getRepoSubscription: ["GET /repos/{owner}/{repo}/subscription"], + getThread: ["GET /notifications/threads/{thread_id}"], + getThreadSubscriptionForAuthenticatedUser: [ + "GET /notifications/threads/{thread_id}/subscription" + ], + listEventsForAuthenticatedUser: ["GET /users/{username}/events"], + listNotificationsForAuthenticatedUser: ["GET /notifications"], + listOrgEventsForAuthenticatedUser: [ + "GET /users/{username}/events/orgs/{org}" + ], + listPublicEvents: ["GET /events"], + listPublicEventsForRepoNetwork: ["GET /networks/{owner}/{repo}/events"], + listPublicEventsForUser: ["GET /users/{username}/events/public"], + listPublicOrgEvents: ["GET /orgs/{org}/events"], + listReceivedEventsForUser: ["GET /users/{username}/received_events"], + listReceivedPublicEventsForUser: [ + "GET /users/{username}/received_events/public" + ], + listRepoEvents: ["GET /repos/{owner}/{repo}/events"], + listRepoNotificationsForAuthenticatedUser: [ + "GET /repos/{owner}/{repo}/notifications" + ], + listReposStarredByAuthenticatedUser: ["GET /user/starred"], + listReposStarredByUser: ["GET /users/{username}/starred"], + listReposWatchedByUser: ["GET /users/{username}/subscriptions"], + listStargazersForRepo: ["GET /repos/{owner}/{repo}/stargazers"], + listWatchedReposForAuthenticatedUser: ["GET /user/subscriptions"], + listWatchersForRepo: ["GET /repos/{owner}/{repo}/subscribers"], + markNotificationsAsRead: ["PUT /notifications"], + markRepoNotificationsAsRead: ["PUT /repos/{owner}/{repo}/notifications"], + markThreadAsRead: ["PATCH /notifications/threads/{thread_id}"], + setRepoSubscription: ["PUT /repos/{owner}/{repo}/subscription"], + setThreadSubscription: [ + "PUT /notifications/threads/{thread_id}/subscription" + ], + starRepoForAuthenticatedUser: ["PUT /user/starred/{owner}/{repo}"], + unstarRepoForAuthenticatedUser: ["DELETE /user/starred/{owner}/{repo}"] + }, + apps: { + addRepoToInstallation: [ + "PUT /user/installations/{installation_id}/repositories/{repository_id}", + {}, + { renamed: ["apps", "addRepoToInstallationForAuthenticatedUser"] } + ], + addRepoToInstallationForAuthenticatedUser: [ + "PUT /user/installations/{installation_id}/repositories/{repository_id}" + ], + checkToken: ["POST /applications/{client_id}/token"], + createFromManifest: ["POST /app-manifests/{code}/conversions"], + createInstallationAccessToken: [ + "POST /app/installations/{installation_id}/access_tokens" + ], + deleteAuthorization: ["DELETE /applications/{client_id}/grant"], + deleteInstallation: ["DELETE /app/installations/{installation_id}"], + deleteToken: ["DELETE /applications/{client_id}/token"], + getAuthenticated: ["GET /app"], + getBySlug: ["GET /apps/{app_slug}"], + getInstallation: ["GET /app/installations/{installation_id}"], + getOrgInstallation: ["GET /orgs/{org}/installation"], + getRepoInstallation: ["GET /repos/{owner}/{repo}/installation"], + getSubscriptionPlanForAccount: [ + "GET /marketplace_listing/accounts/{account_id}" + ], + getSubscriptionPlanForAccountStubbed: [ + "GET /marketplace_listing/stubbed/accounts/{account_id}" + ], + getUserInstallation: ["GET /users/{username}/installation"], + getWebhookConfigForApp: ["GET /app/hook/config"], + getWebhookDelivery: ["GET /app/hook/deliveries/{delivery_id}"], + listAccountsForPlan: ["GET /marketplace_listing/plans/{plan_id}/accounts"], + listAccountsForPlanStubbed: [ + "GET /marketplace_listing/stubbed/plans/{plan_id}/accounts" + ], + listInstallationReposForAuthenticatedUser: [ + "GET /user/installations/{installation_id}/repositories" + ], + listInstallationRequestsForAuthenticatedApp: [ + "GET /app/installation-requests" + ], + listInstallations: ["GET /app/installations"], + listInstallationsForAuthenticatedUser: ["GET /user/installations"], + listPlans: ["GET /marketplace_listing/plans"], + listPlansStubbed: ["GET /marketplace_listing/stubbed/plans"], + listReposAccessibleToInstallation: ["GET /installation/repositories"], + listSubscriptionsForAuthenticatedUser: ["GET /user/marketplace_purchases"], + listSubscriptionsForAuthenticatedUserStubbed: [ + "GET /user/marketplace_purchases/stubbed" + ], + listWebhookDeliveries: ["GET /app/hook/deliveries"], + redeliverWebhookDelivery: [ + "POST /app/hook/deliveries/{delivery_id}/attempts" + ], + removeRepoFromInstallation: [ + "DELETE /user/installations/{installation_id}/repositories/{repository_id}", + {}, + { renamed: ["apps", "removeRepoFromInstallationForAuthenticatedUser"] } + ], + removeRepoFromInstallationForAuthenticatedUser: [ + "DELETE /user/installations/{installation_id}/repositories/{repository_id}" + ], + resetToken: ["PATCH /applications/{client_id}/token"], + revokeInstallationAccessToken: ["DELETE /installation/token"], + scopeToken: ["POST /applications/{client_id}/token/scoped"], + suspendInstallation: ["PUT /app/installations/{installation_id}/suspended"], + unsuspendInstallation: [ + "DELETE /app/installations/{installation_id}/suspended" + ], + updateWebhookConfigForApp: ["PATCH /app/hook/config"] + }, + billing: { + getGithubActionsBillingOrg: ["GET /orgs/{org}/settings/billing/actions"], + getGithubActionsBillingUser: [ + "GET /users/{username}/settings/billing/actions" + ], + getGithubPackagesBillingOrg: ["GET /orgs/{org}/settings/billing/packages"], + getGithubPackagesBillingUser: [ + "GET /users/{username}/settings/billing/packages" + ], + getSharedStorageBillingOrg: [ + "GET /orgs/{org}/settings/billing/shared-storage" + ], + getSharedStorageBillingUser: [ + "GET /users/{username}/settings/billing/shared-storage" + ] + }, + checks: { + create: ["POST /repos/{owner}/{repo}/check-runs"], + createSuite: ["POST /repos/{owner}/{repo}/check-suites"], + get: ["GET /repos/{owner}/{repo}/check-runs/{check_run_id}"], + getSuite: ["GET /repos/{owner}/{repo}/check-suites/{check_suite_id}"], + listAnnotations: [ + "GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations" + ], + listForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/check-runs"], + listForSuite: [ + "GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs" + ], + listSuitesForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/check-suites"], + rerequestRun: [ + "POST /repos/{owner}/{repo}/check-runs/{check_run_id}/rerequest" + ], + rerequestSuite: [ + "POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest" + ], + setSuitesPreferences: [ + "PATCH /repos/{owner}/{repo}/check-suites/preferences" + ], + update: ["PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}"] + }, + codeScanning: { + deleteAnalysis: [ + "DELETE /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}{?confirm_delete}" + ], + getAlert: [ + "GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}", + {}, + { renamedParameters: { alert_id: "alert_number" } } + ], + getAnalysis: [ + "GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}" + ], + getCodeqlDatabase: [ + "GET /repos/{owner}/{repo}/code-scanning/codeql/databases/{language}" + ], + getDefaultSetup: ["GET /repos/{owner}/{repo}/code-scanning/default-setup"], + getSarif: ["GET /repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}"], + listAlertInstances: [ + "GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances" + ], + listAlertsForOrg: ["GET /orgs/{org}/code-scanning/alerts"], + listAlertsForRepo: ["GET /repos/{owner}/{repo}/code-scanning/alerts"], + listAlertsInstances: [ + "GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances", + {}, + { renamed: ["codeScanning", "listAlertInstances"] } + ], + listCodeqlDatabases: [ + "GET /repos/{owner}/{repo}/code-scanning/codeql/databases" + ], + listRecentAnalyses: ["GET /repos/{owner}/{repo}/code-scanning/analyses"], + updateAlert: [ + "PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}" + ], + updateDefaultSetup: [ + "PATCH /repos/{owner}/{repo}/code-scanning/default-setup" + ], + uploadSarif: ["POST /repos/{owner}/{repo}/code-scanning/sarifs"] + }, + codesOfConduct: { + getAllCodesOfConduct: ["GET /codes_of_conduct"], + getConductCode: ["GET /codes_of_conduct/{key}"] + }, + codespaces: { + addRepositoryForSecretForAuthenticatedUser: [ + "PUT /user/codespaces/secrets/{secret_name}/repositories/{repository_id}" + ], + addSelectedRepoToOrgSecret: [ + "PUT /orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}" + ], + checkPermissionsForDevcontainer: [ + "GET /repos/{owner}/{repo}/codespaces/permissions_check" + ], + codespaceMachinesForAuthenticatedUser: [ + "GET /user/codespaces/{codespace_name}/machines" + ], + createForAuthenticatedUser: ["POST /user/codespaces"], + createOrUpdateOrgSecret: [ + "PUT /orgs/{org}/codespaces/secrets/{secret_name}" + ], + createOrUpdateRepoSecret: [ + "PUT /repos/{owner}/{repo}/codespaces/secrets/{secret_name}" + ], + createOrUpdateSecretForAuthenticatedUser: [ + "PUT /user/codespaces/secrets/{secret_name}" + ], + createWithPrForAuthenticatedUser: [ + "POST /repos/{owner}/{repo}/pulls/{pull_number}/codespaces" + ], + createWithRepoForAuthenticatedUser: [ + "POST /repos/{owner}/{repo}/codespaces" + ], + deleteForAuthenticatedUser: ["DELETE /user/codespaces/{codespace_name}"], + deleteFromOrganization: [ + "DELETE /orgs/{org}/members/{username}/codespaces/{codespace_name}" + ], + deleteOrgSecret: ["DELETE /orgs/{org}/codespaces/secrets/{secret_name}"], + deleteRepoSecret: [ + "DELETE /repos/{owner}/{repo}/codespaces/secrets/{secret_name}" + ], + deleteSecretForAuthenticatedUser: [ + "DELETE /user/codespaces/secrets/{secret_name}" + ], + exportForAuthenticatedUser: [ + "POST /user/codespaces/{codespace_name}/exports" + ], + getCodespacesForUserInOrg: [ + "GET /orgs/{org}/members/{username}/codespaces" + ], + getExportDetailsForAuthenticatedUser: [ + "GET /user/codespaces/{codespace_name}/exports/{export_id}" + ], + getForAuthenticatedUser: ["GET /user/codespaces/{codespace_name}"], + getOrgPublicKey: ["GET /orgs/{org}/codespaces/secrets/public-key"], + getOrgSecret: ["GET /orgs/{org}/codespaces/secrets/{secret_name}"], + getPublicKeyForAuthenticatedUser: [ + "GET /user/codespaces/secrets/public-key" + ], + getRepoPublicKey: [ + "GET /repos/{owner}/{repo}/codespaces/secrets/public-key" + ], + getRepoSecret: [ + "GET /repos/{owner}/{repo}/codespaces/secrets/{secret_name}" + ], + getSecretForAuthenticatedUser: [ + "GET /user/codespaces/secrets/{secret_name}" + ], + listDevcontainersInRepositoryForAuthenticatedUser: [ + "GET /repos/{owner}/{repo}/codespaces/devcontainers" + ], + listForAuthenticatedUser: ["GET /user/codespaces"], + listInOrganization: [ + "GET /orgs/{org}/codespaces", + {}, + { renamedParameters: { org_id: "org" } } + ], + listInRepositoryForAuthenticatedUser: [ + "GET /repos/{owner}/{repo}/codespaces" + ], + listOrgSecrets: ["GET /orgs/{org}/codespaces/secrets"], + listRepoSecrets: ["GET /repos/{owner}/{repo}/codespaces/secrets"], + listRepositoriesForSecretForAuthenticatedUser: [ + "GET /user/codespaces/secrets/{secret_name}/repositories" + ], + listSecretsForAuthenticatedUser: ["GET /user/codespaces/secrets"], + listSelectedReposForOrgSecret: [ + "GET /orgs/{org}/codespaces/secrets/{secret_name}/repositories" + ], + preFlightWithRepoForAuthenticatedUser: [ + "GET /repos/{owner}/{repo}/codespaces/new" + ], + publishForAuthenticatedUser: [ + "POST /user/codespaces/{codespace_name}/publish" + ], + removeRepositoryForSecretForAuthenticatedUser: [ + "DELETE /user/codespaces/secrets/{secret_name}/repositories/{repository_id}" + ], + removeSelectedRepoFromOrgSecret: [ + "DELETE /orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}" + ], + repoMachinesForAuthenticatedUser: [ + "GET /repos/{owner}/{repo}/codespaces/machines" + ], + setRepositoriesForSecretForAuthenticatedUser: [ + "PUT /user/codespaces/secrets/{secret_name}/repositories" + ], + setSelectedReposForOrgSecret: [ + "PUT /orgs/{org}/codespaces/secrets/{secret_name}/repositories" + ], + startForAuthenticatedUser: ["POST /user/codespaces/{codespace_name}/start"], + stopForAuthenticatedUser: ["POST /user/codespaces/{codespace_name}/stop"], + stopInOrganization: [ + "POST /orgs/{org}/members/{username}/codespaces/{codespace_name}/stop" + ], + updateForAuthenticatedUser: ["PATCH /user/codespaces/{codespace_name}"] + }, + copilot: { + addCopilotForBusinessSeatsForTeams: [ + "POST /orgs/{org}/copilot/billing/selected_teams" + ], + addCopilotForBusinessSeatsForUsers: [ + "POST /orgs/{org}/copilot/billing/selected_users" + ], + cancelCopilotSeatAssignmentForTeams: [ + "DELETE /orgs/{org}/copilot/billing/selected_teams" + ], + cancelCopilotSeatAssignmentForUsers: [ + "DELETE /orgs/{org}/copilot/billing/selected_users" + ], + getCopilotOrganizationDetails: ["GET /orgs/{org}/copilot/billing"], + getCopilotSeatDetailsForUser: [ + "GET /orgs/{org}/members/{username}/copilot" + ], + listCopilotSeats: ["GET /orgs/{org}/copilot/billing/seats"] + }, + dependabot: { + addSelectedRepoToOrgSecret: [ + "PUT /orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}" + ], + createOrUpdateOrgSecret: [ + "PUT /orgs/{org}/dependabot/secrets/{secret_name}" + ], + createOrUpdateRepoSecret: [ + "PUT /repos/{owner}/{repo}/dependabot/secrets/{secret_name}" + ], + deleteOrgSecret: ["DELETE /orgs/{org}/dependabot/secrets/{secret_name}"], + deleteRepoSecret: [ + "DELETE /repos/{owner}/{repo}/dependabot/secrets/{secret_name}" + ], + getAlert: ["GET /repos/{owner}/{repo}/dependabot/alerts/{alert_number}"], + getOrgPublicKey: ["GET /orgs/{org}/dependabot/secrets/public-key"], + getOrgSecret: ["GET /orgs/{org}/dependabot/secrets/{secret_name}"], + getRepoPublicKey: [ + "GET /repos/{owner}/{repo}/dependabot/secrets/public-key" + ], + getRepoSecret: [ + "GET /repos/{owner}/{repo}/dependabot/secrets/{secret_name}" + ], + listAlertsForEnterprise: [ + "GET /enterprises/{enterprise}/dependabot/alerts" + ], + listAlertsForOrg: ["GET /orgs/{org}/dependabot/alerts"], + listAlertsForRepo: ["GET /repos/{owner}/{repo}/dependabot/alerts"], + listOrgSecrets: ["GET /orgs/{org}/dependabot/secrets"], + listRepoSecrets: ["GET /repos/{owner}/{repo}/dependabot/secrets"], + listSelectedReposForOrgSecret: [ + "GET /orgs/{org}/dependabot/secrets/{secret_name}/repositories" + ], + removeSelectedRepoFromOrgSecret: [ + "DELETE /orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}" + ], + setSelectedReposForOrgSecret: [ + "PUT /orgs/{org}/dependabot/secrets/{secret_name}/repositories" + ], + updateAlert: [ + "PATCH /repos/{owner}/{repo}/dependabot/alerts/{alert_number}" + ] + }, + dependencyGraph: { + createRepositorySnapshot: [ + "POST /repos/{owner}/{repo}/dependency-graph/snapshots" + ], + diffRange: [ + "GET /repos/{owner}/{repo}/dependency-graph/compare/{basehead}" + ], + exportSbom: ["GET /repos/{owner}/{repo}/dependency-graph/sbom"] + }, + emojis: { get: ["GET /emojis"] }, + gists: { + checkIsStarred: ["GET /gists/{gist_id}/star"], + create: ["POST /gists"], + createComment: ["POST /gists/{gist_id}/comments"], + delete: ["DELETE /gists/{gist_id}"], + deleteComment: ["DELETE /gists/{gist_id}/comments/{comment_id}"], + fork: ["POST /gists/{gist_id}/forks"], + get: ["GET /gists/{gist_id}"], + getComment: ["GET /gists/{gist_id}/comments/{comment_id}"], + getRevision: ["GET /gists/{gist_id}/{sha}"], + list: ["GET /gists"], + listComments: ["GET /gists/{gist_id}/comments"], + listCommits: ["GET /gists/{gist_id}/commits"], + listForUser: ["GET /users/{username}/gists"], + listForks: ["GET /gists/{gist_id}/forks"], + listPublic: ["GET /gists/public"], + listStarred: ["GET /gists/starred"], + star: ["PUT /gists/{gist_id}/star"], + unstar: ["DELETE /gists/{gist_id}/star"], + update: ["PATCH /gists/{gist_id}"], + updateComment: ["PATCH /gists/{gist_id}/comments/{comment_id}"] + }, + git: { + createBlob: ["POST /repos/{owner}/{repo}/git/blobs"], + createCommit: ["POST /repos/{owner}/{repo}/git/commits"], + createRef: ["POST /repos/{owner}/{repo}/git/refs"], + createTag: ["POST /repos/{owner}/{repo}/git/tags"], + createTree: ["POST /repos/{owner}/{repo}/git/trees"], + deleteRef: ["DELETE /repos/{owner}/{repo}/git/refs/{ref}"], + getBlob: ["GET /repos/{owner}/{repo}/git/blobs/{file_sha}"], + getCommit: ["GET /repos/{owner}/{repo}/git/commits/{commit_sha}"], + getRef: ["GET /repos/{owner}/{repo}/git/ref/{ref}"], + getTag: ["GET /repos/{owner}/{repo}/git/tags/{tag_sha}"], + getTree: ["GET /repos/{owner}/{repo}/git/trees/{tree_sha}"], + listMatchingRefs: ["GET /repos/{owner}/{repo}/git/matching-refs/{ref}"], + updateRef: ["PATCH /repos/{owner}/{repo}/git/refs/{ref}"] + }, + gitignore: { + getAllTemplates: ["GET /gitignore/templates"], + getTemplate: ["GET /gitignore/templates/{name}"] + }, + interactions: { + getRestrictionsForAuthenticatedUser: ["GET /user/interaction-limits"], + getRestrictionsForOrg: ["GET /orgs/{org}/interaction-limits"], + getRestrictionsForRepo: ["GET /repos/{owner}/{repo}/interaction-limits"], + getRestrictionsForYourPublicRepos: [ + "GET /user/interaction-limits", + {}, + { renamed: ["interactions", "getRestrictionsForAuthenticatedUser"] } + ], + removeRestrictionsForAuthenticatedUser: ["DELETE /user/interaction-limits"], + removeRestrictionsForOrg: ["DELETE /orgs/{org}/interaction-limits"], + removeRestrictionsForRepo: [ + "DELETE /repos/{owner}/{repo}/interaction-limits" + ], + removeRestrictionsForYourPublicRepos: [ + "DELETE /user/interaction-limits", + {}, + { renamed: ["interactions", "removeRestrictionsForAuthenticatedUser"] } + ], + setRestrictionsForAuthenticatedUser: ["PUT /user/interaction-limits"], + setRestrictionsForOrg: ["PUT /orgs/{org}/interaction-limits"], + setRestrictionsForRepo: ["PUT /repos/{owner}/{repo}/interaction-limits"], + setRestrictionsForYourPublicRepos: [ + "PUT /user/interaction-limits", + {}, + { renamed: ["interactions", "setRestrictionsForAuthenticatedUser"] } + ] + }, + issues: { + addAssignees: [ + "POST /repos/{owner}/{repo}/issues/{issue_number}/assignees" + ], + addLabels: ["POST /repos/{owner}/{repo}/issues/{issue_number}/labels"], + checkUserCanBeAssigned: ["GET /repos/{owner}/{repo}/assignees/{assignee}"], + checkUserCanBeAssignedToIssue: [ + "GET /repos/{owner}/{repo}/issues/{issue_number}/assignees/{assignee}" + ], + create: ["POST /repos/{owner}/{repo}/issues"], + createComment: [ + "POST /repos/{owner}/{repo}/issues/{issue_number}/comments" + ], + createLabel: ["POST /repos/{owner}/{repo}/labels"], + createMilestone: ["POST /repos/{owner}/{repo}/milestones"], + deleteComment: [ + "DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}" + ], + deleteLabel: ["DELETE /repos/{owner}/{repo}/labels/{name}"], + deleteMilestone: [ + "DELETE /repos/{owner}/{repo}/milestones/{milestone_number}" + ], + get: ["GET /repos/{owner}/{repo}/issues/{issue_number}"], + getComment: ["GET /repos/{owner}/{repo}/issues/comments/{comment_id}"], + getEvent: ["GET /repos/{owner}/{repo}/issues/events/{event_id}"], + getLabel: ["GET /repos/{owner}/{repo}/labels/{name}"], + getMilestone: ["GET /repos/{owner}/{repo}/milestones/{milestone_number}"], + list: ["GET /issues"], + listAssignees: ["GET /repos/{owner}/{repo}/assignees"], + listComments: ["GET /repos/{owner}/{repo}/issues/{issue_number}/comments"], + listCommentsForRepo: ["GET /repos/{owner}/{repo}/issues/comments"], + listEvents: ["GET /repos/{owner}/{repo}/issues/{issue_number}/events"], + listEventsForRepo: ["GET /repos/{owner}/{repo}/issues/events"], + listEventsForTimeline: [ + "GET /repos/{owner}/{repo}/issues/{issue_number}/timeline" + ], + listForAuthenticatedUser: ["GET /user/issues"], + listForOrg: ["GET /orgs/{org}/issues"], + listForRepo: ["GET /repos/{owner}/{repo}/issues"], + listLabelsForMilestone: [ + "GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels" + ], + listLabelsForRepo: ["GET /repos/{owner}/{repo}/labels"], + listLabelsOnIssue: [ + "GET /repos/{owner}/{repo}/issues/{issue_number}/labels" + ], + listMilestones: ["GET /repos/{owner}/{repo}/milestones"], + lock: ["PUT /repos/{owner}/{repo}/issues/{issue_number}/lock"], + removeAllLabels: [ + "DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels" + ], + removeAssignees: [ + "DELETE /repos/{owner}/{repo}/issues/{issue_number}/assignees" + ], + removeLabel: [ + "DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}" + ], + setLabels: ["PUT /repos/{owner}/{repo}/issues/{issue_number}/labels"], + unlock: ["DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock"], + update: ["PATCH /repos/{owner}/{repo}/issues/{issue_number}"], + updateComment: ["PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}"], + updateLabel: ["PATCH /repos/{owner}/{repo}/labels/{name}"], + updateMilestone: [ + "PATCH /repos/{owner}/{repo}/milestones/{milestone_number}" + ] + }, + licenses: { + get: ["GET /licenses/{license}"], + getAllCommonlyUsed: ["GET /licenses"], + getForRepo: ["GET /repos/{owner}/{repo}/license"] + }, + markdown: { + render: ["POST /markdown"], + renderRaw: [ + "POST /markdown/raw", + { headers: { "content-type": "text/plain; charset=utf-8" } } + ] + }, + meta: { + get: ["GET /meta"], + getAllVersions: ["GET /versions"], + getOctocat: ["GET /octocat"], + getZen: ["GET /zen"], + root: ["GET /"] + }, + migrations: { + cancelImport: [ + "DELETE /repos/{owner}/{repo}/import", + {}, + { + deprecated: "octokit.rest.migrations.cancelImport() is deprecated, see https://docs.github.com/rest/migrations/source-imports#cancel-an-import" + } + ], + deleteArchiveForAuthenticatedUser: [ + "DELETE /user/migrations/{migration_id}/archive" + ], + deleteArchiveForOrg: [ + "DELETE /orgs/{org}/migrations/{migration_id}/archive" + ], + downloadArchiveForOrg: [ + "GET /orgs/{org}/migrations/{migration_id}/archive" + ], + getArchiveForAuthenticatedUser: [ + "GET /user/migrations/{migration_id}/archive" + ], + getCommitAuthors: [ + "GET /repos/{owner}/{repo}/import/authors", + {}, + { + deprecated: "octokit.rest.migrations.getCommitAuthors() is deprecated, see https://docs.github.com/rest/migrations/source-imports#get-commit-authors" + } + ], + getImportStatus: [ + "GET /repos/{owner}/{repo}/import", + {}, + { + deprecated: "octokit.rest.migrations.getImportStatus() is deprecated, see https://docs.github.com/rest/migrations/source-imports#get-an-import-status" + } + ], + getLargeFiles: [ + "GET /repos/{owner}/{repo}/import/large_files", + {}, + { + deprecated: "octokit.rest.migrations.getLargeFiles() is deprecated, see https://docs.github.com/rest/migrations/source-imports#get-large-files" + } + ], + getStatusForAuthenticatedUser: ["GET /user/migrations/{migration_id}"], + getStatusForOrg: ["GET /orgs/{org}/migrations/{migration_id}"], + listForAuthenticatedUser: ["GET /user/migrations"], + listForOrg: ["GET /orgs/{org}/migrations"], + listReposForAuthenticatedUser: [ + "GET /user/migrations/{migration_id}/repositories" + ], + listReposForOrg: ["GET /orgs/{org}/migrations/{migration_id}/repositories"], + listReposForUser: [ + "GET /user/migrations/{migration_id}/repositories", + {}, + { renamed: ["migrations", "listReposForAuthenticatedUser"] } + ], + mapCommitAuthor: [ + "PATCH /repos/{owner}/{repo}/import/authors/{author_id}", + {}, + { + deprecated: "octokit.rest.migrations.mapCommitAuthor() is deprecated, see https://docs.github.com/rest/migrations/source-imports#map-a-commit-author" + } + ], + setLfsPreference: [ + "PATCH /repos/{owner}/{repo}/import/lfs", + {}, + { + deprecated: "octokit.rest.migrations.setLfsPreference() is deprecated, see https://docs.github.com/rest/migrations/source-imports#update-git-lfs-preference" + } + ], + startForAuthenticatedUser: ["POST /user/migrations"], + startForOrg: ["POST /orgs/{org}/migrations"], + startImport: [ + "PUT /repos/{owner}/{repo}/import", + {}, + { + deprecated: "octokit.rest.migrations.startImport() is deprecated, see https://docs.github.com/rest/migrations/source-imports#start-an-import" + } + ], + unlockRepoForAuthenticatedUser: [ + "DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock" + ], + unlockRepoForOrg: [ + "DELETE /orgs/{org}/migrations/{migration_id}/repos/{repo_name}/lock" + ], + updateImport: [ + "PATCH /repos/{owner}/{repo}/import", + {}, + { + deprecated: "octokit.rest.migrations.updateImport() is deprecated, see https://docs.github.com/rest/migrations/source-imports#update-an-import" + } + ] + }, + orgs: { + addSecurityManagerTeam: [ + "PUT /orgs/{org}/security-managers/teams/{team_slug}" + ], + blockUser: ["PUT /orgs/{org}/blocks/{username}"], + cancelInvitation: ["DELETE /orgs/{org}/invitations/{invitation_id}"], + checkBlockedUser: ["GET /orgs/{org}/blocks/{username}"], + checkMembershipForUser: ["GET /orgs/{org}/members/{username}"], + checkPublicMembershipForUser: ["GET /orgs/{org}/public_members/{username}"], + convertMemberToOutsideCollaborator: [ + "PUT /orgs/{org}/outside_collaborators/{username}" + ], + createInvitation: ["POST /orgs/{org}/invitations"], + createOrUpdateCustomProperties: ["PATCH /orgs/{org}/properties/schema"], + createOrUpdateCustomPropertiesValuesForRepos: [ + "PATCH /orgs/{org}/properties/values" + ], + createOrUpdateCustomProperty: [ + "PUT /orgs/{org}/properties/schema/{custom_property_name}" + ], + createWebhook: ["POST /orgs/{org}/hooks"], + delete: ["DELETE /orgs/{org}"], + deleteWebhook: ["DELETE /orgs/{org}/hooks/{hook_id}"], + enableOrDisableSecurityProductOnAllOrgRepos: [ + "POST /orgs/{org}/{security_product}/{enablement}" + ], + get: ["GET /orgs/{org}"], + getAllCustomProperties: ["GET /orgs/{org}/properties/schema"], + getCustomProperty: [ + "GET /orgs/{org}/properties/schema/{custom_property_name}" + ], + getMembershipForAuthenticatedUser: ["GET /user/memberships/orgs/{org}"], + getMembershipForUser: ["GET /orgs/{org}/memberships/{username}"], + getWebhook: ["GET /orgs/{org}/hooks/{hook_id}"], + getWebhookConfigForOrg: ["GET /orgs/{org}/hooks/{hook_id}/config"], + getWebhookDelivery: [ + "GET /orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id}" + ], + list: ["GET /organizations"], + listAppInstallations: ["GET /orgs/{org}/installations"], + listBlockedUsers: ["GET /orgs/{org}/blocks"], + listCustomPropertiesValuesForRepos: ["GET /orgs/{org}/properties/values"], + listFailedInvitations: ["GET /orgs/{org}/failed_invitations"], + listForAuthenticatedUser: ["GET /user/orgs"], + listForUser: ["GET /users/{username}/orgs"], + listInvitationTeams: ["GET /orgs/{org}/invitations/{invitation_id}/teams"], + listMembers: ["GET /orgs/{org}/members"], + listMembershipsForAuthenticatedUser: ["GET /user/memberships/orgs"], + listOutsideCollaborators: ["GET /orgs/{org}/outside_collaborators"], + listPatGrantRepositories: [ + "GET /orgs/{org}/personal-access-tokens/{pat_id}/repositories" + ], + listPatGrantRequestRepositories: [ + "GET /orgs/{org}/personal-access-token-requests/{pat_request_id}/repositories" + ], + listPatGrantRequests: ["GET /orgs/{org}/personal-access-token-requests"], + listPatGrants: ["GET /orgs/{org}/personal-access-tokens"], + listPendingInvitations: ["GET /orgs/{org}/invitations"], + listPublicMembers: ["GET /orgs/{org}/public_members"], + listSecurityManagerTeams: ["GET /orgs/{org}/security-managers"], + listWebhookDeliveries: ["GET /orgs/{org}/hooks/{hook_id}/deliveries"], + listWebhooks: ["GET /orgs/{org}/hooks"], + pingWebhook: ["POST /orgs/{org}/hooks/{hook_id}/pings"], + redeliverWebhookDelivery: [ + "POST /orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id}/attempts" + ], + removeCustomProperty: [ + "DELETE /orgs/{org}/properties/schema/{custom_property_name}" + ], + removeMember: ["DELETE /orgs/{org}/members/{username}"], + removeMembershipForUser: ["DELETE /orgs/{org}/memberships/{username}"], + removeOutsideCollaborator: [ + "DELETE /orgs/{org}/outside_collaborators/{username}" + ], + removePublicMembershipForAuthenticatedUser: [ + "DELETE /orgs/{org}/public_members/{username}" + ], + removeSecurityManagerTeam: [ + "DELETE /orgs/{org}/security-managers/teams/{team_slug}" + ], + reviewPatGrantRequest: [ + "POST /orgs/{org}/personal-access-token-requests/{pat_request_id}" + ], + reviewPatGrantRequestsInBulk: [ + "POST /orgs/{org}/personal-access-token-requests" + ], + setMembershipForUser: ["PUT /orgs/{org}/memberships/{username}"], + setPublicMembershipForAuthenticatedUser: [ + "PUT /orgs/{org}/public_members/{username}" + ], + unblockUser: ["DELETE /orgs/{org}/blocks/{username}"], + update: ["PATCH /orgs/{org}"], + updateMembershipForAuthenticatedUser: [ + "PATCH /user/memberships/orgs/{org}" + ], + updatePatAccess: ["POST /orgs/{org}/personal-access-tokens/{pat_id}"], + updatePatAccesses: ["POST /orgs/{org}/personal-access-tokens"], + updateWebhook: ["PATCH /orgs/{org}/hooks/{hook_id}"], + updateWebhookConfigForOrg: ["PATCH /orgs/{org}/hooks/{hook_id}/config"] + }, + packages: { + deletePackageForAuthenticatedUser: [ + "DELETE /user/packages/{package_type}/{package_name}" + ], + deletePackageForOrg: [ + "DELETE /orgs/{org}/packages/{package_type}/{package_name}" + ], + deletePackageForUser: [ + "DELETE /users/{username}/packages/{package_type}/{package_name}" + ], + deletePackageVersionForAuthenticatedUser: [ + "DELETE /user/packages/{package_type}/{package_name}/versions/{package_version_id}" + ], + deletePackageVersionForOrg: [ + "DELETE /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}" + ], + deletePackageVersionForUser: [ + "DELETE /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}" + ], + getAllPackageVersionsForAPackageOwnedByAnOrg: [ + "GET /orgs/{org}/packages/{package_type}/{package_name}/versions", + {}, + { renamed: ["packages", "getAllPackageVersionsForPackageOwnedByOrg"] } + ], + getAllPackageVersionsForAPackageOwnedByTheAuthenticatedUser: [ + "GET /user/packages/{package_type}/{package_name}/versions", + {}, + { + renamed: [ + "packages", + "getAllPackageVersionsForPackageOwnedByAuthenticatedUser" + ] + } + ], + getAllPackageVersionsForPackageOwnedByAuthenticatedUser: [ + "GET /user/packages/{package_type}/{package_name}/versions" + ], + getAllPackageVersionsForPackageOwnedByOrg: [ + "GET /orgs/{org}/packages/{package_type}/{package_name}/versions" + ], + getAllPackageVersionsForPackageOwnedByUser: [ + "GET /users/{username}/packages/{package_type}/{package_name}/versions" + ], + getPackageForAuthenticatedUser: [ + "GET /user/packages/{package_type}/{package_name}" + ], + getPackageForOrganization: [ + "GET /orgs/{org}/packages/{package_type}/{package_name}" + ], + getPackageForUser: [ + "GET /users/{username}/packages/{package_type}/{package_name}" + ], + getPackageVersionForAuthenticatedUser: [ + "GET /user/packages/{package_type}/{package_name}/versions/{package_version_id}" + ], + getPackageVersionForOrganization: [ + "GET /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}" + ], + getPackageVersionForUser: [ + "GET /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}" + ], + listDockerMigrationConflictingPackagesForAuthenticatedUser: [ + "GET /user/docker/conflicts" + ], + listDockerMigrationConflictingPackagesForOrganization: [ + "GET /orgs/{org}/docker/conflicts" + ], + listDockerMigrationConflictingPackagesForUser: [ + "GET /users/{username}/docker/conflicts" + ], + listPackagesForAuthenticatedUser: ["GET /user/packages"], + listPackagesForOrganization: ["GET /orgs/{org}/packages"], + listPackagesForUser: ["GET /users/{username}/packages"], + restorePackageForAuthenticatedUser: [ + "POST /user/packages/{package_type}/{package_name}/restore{?token}" + ], + restorePackageForOrg: [ + "POST /orgs/{org}/packages/{package_type}/{package_name}/restore{?token}" + ], + restorePackageForUser: [ + "POST /users/{username}/packages/{package_type}/{package_name}/restore{?token}" + ], + restorePackageVersionForAuthenticatedUser: [ + "POST /user/packages/{package_type}/{package_name}/versions/{package_version_id}/restore" + ], + restorePackageVersionForOrg: [ + "POST /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore" + ], + restorePackageVersionForUser: [ + "POST /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore" + ] + }, + projects: { + addCollaborator: ["PUT /projects/{project_id}/collaborators/{username}"], + createCard: ["POST /projects/columns/{column_id}/cards"], + createColumn: ["POST /projects/{project_id}/columns"], + createForAuthenticatedUser: ["POST /user/projects"], + createForOrg: ["POST /orgs/{org}/projects"], + createForRepo: ["POST /repos/{owner}/{repo}/projects"], + delete: ["DELETE /projects/{project_id}"], + deleteCard: ["DELETE /projects/columns/cards/{card_id}"], + deleteColumn: ["DELETE /projects/columns/{column_id}"], + get: ["GET /projects/{project_id}"], + getCard: ["GET /projects/columns/cards/{card_id}"], + getColumn: ["GET /projects/columns/{column_id}"], + getPermissionForUser: [ + "GET /projects/{project_id}/collaborators/{username}/permission" + ], + listCards: ["GET /projects/columns/{column_id}/cards"], + listCollaborators: ["GET /projects/{project_id}/collaborators"], + listColumns: ["GET /projects/{project_id}/columns"], + listForOrg: ["GET /orgs/{org}/projects"], + listForRepo: ["GET /repos/{owner}/{repo}/projects"], + listForUser: ["GET /users/{username}/projects"], + moveCard: ["POST /projects/columns/cards/{card_id}/moves"], + moveColumn: ["POST /projects/columns/{column_id}/moves"], + removeCollaborator: [ + "DELETE /projects/{project_id}/collaborators/{username}" + ], + update: ["PATCH /projects/{project_id}"], + updateCard: ["PATCH /projects/columns/cards/{card_id}"], + updateColumn: ["PATCH /projects/columns/{column_id}"] + }, + pulls: { + checkIfMerged: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/merge"], + create: ["POST /repos/{owner}/{repo}/pulls"], + createReplyForReviewComment: [ + "POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies" + ], + createReview: ["POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews"], + createReviewComment: [ + "POST /repos/{owner}/{repo}/pulls/{pull_number}/comments" + ], + deletePendingReview: [ + "DELETE /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}" + ], + deleteReviewComment: [ + "DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}" + ], + dismissReview: [ + "PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals" + ], + get: ["GET /repos/{owner}/{repo}/pulls/{pull_number}"], + getReview: [ + "GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}" + ], + getReviewComment: ["GET /repos/{owner}/{repo}/pulls/comments/{comment_id}"], + list: ["GET /repos/{owner}/{repo}/pulls"], + listCommentsForReview: [ + "GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments" + ], + listCommits: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/commits"], + listFiles: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/files"], + listRequestedReviewers: [ + "GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers" + ], + listReviewComments: [ + "GET /repos/{owner}/{repo}/pulls/{pull_number}/comments" + ], + listReviewCommentsForRepo: ["GET /repos/{owner}/{repo}/pulls/comments"], + listReviews: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews"], + merge: ["PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge"], + removeRequestedReviewers: [ + "DELETE /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers" + ], + requestReviewers: [ + "POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers" + ], + submitReview: [ + "POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events" + ], + update: ["PATCH /repos/{owner}/{repo}/pulls/{pull_number}"], + updateBranch: [ + "PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch" + ], + updateReview: [ + "PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}" + ], + updateReviewComment: [ + "PATCH /repos/{owner}/{repo}/pulls/comments/{comment_id}" + ] + }, + rateLimit: { get: ["GET /rate_limit"] }, + reactions: { + createForCommitComment: [ + "POST /repos/{owner}/{repo}/comments/{comment_id}/reactions" + ], + createForIssue: [ + "POST /repos/{owner}/{repo}/issues/{issue_number}/reactions" + ], + createForIssueComment: [ + "POST /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions" + ], + createForPullRequestReviewComment: [ + "POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions" + ], + createForRelease: [ + "POST /repos/{owner}/{repo}/releases/{release_id}/reactions" + ], + createForTeamDiscussionCommentInOrg: [ + "POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions" + ], + createForTeamDiscussionInOrg: [ + "POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions" + ], + deleteForCommitComment: [ + "DELETE /repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id}" + ], + deleteForIssue: [ + "DELETE /repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id}" + ], + deleteForIssueComment: [ + "DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id}" + ], + deleteForPullRequestComment: [ + "DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id}" + ], + deleteForRelease: [ + "DELETE /repos/{owner}/{repo}/releases/{release_id}/reactions/{reaction_id}" + ], + deleteForTeamDiscussion: [ + "DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions/{reaction_id}" + ], + deleteForTeamDiscussionComment: [ + "DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions/{reaction_id}" + ], + listForCommitComment: [ + "GET /repos/{owner}/{repo}/comments/{comment_id}/reactions" + ], + listForIssue: ["GET /repos/{owner}/{repo}/issues/{issue_number}/reactions"], + listForIssueComment: [ + "GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions" + ], + listForPullRequestReviewComment: [ + "GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions" + ], + listForRelease: [ + "GET /repos/{owner}/{repo}/releases/{release_id}/reactions" + ], + listForTeamDiscussionCommentInOrg: [ + "GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions" + ], + listForTeamDiscussionInOrg: [ + "GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions" + ] + }, + repos: { + acceptInvitation: [ + "PATCH /user/repository_invitations/{invitation_id}", + {}, + { renamed: ["repos", "acceptInvitationForAuthenticatedUser"] } + ], + acceptInvitationForAuthenticatedUser: [ + "PATCH /user/repository_invitations/{invitation_id}" + ], + addAppAccessRestrictions: [ + "POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", + {}, + { mapToData: "apps" } + ], + addCollaborator: ["PUT /repos/{owner}/{repo}/collaborators/{username}"], + addStatusCheckContexts: [ + "POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", + {}, + { mapToData: "contexts" } + ], + addTeamAccessRestrictions: [ + "POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", + {}, + { mapToData: "teams" } + ], + addUserAccessRestrictions: [ + "POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", + {}, + { mapToData: "users" } + ], + checkAutomatedSecurityFixes: [ + "GET /repos/{owner}/{repo}/automated-security-fixes" + ], + checkCollaborator: ["GET /repos/{owner}/{repo}/collaborators/{username}"], + checkVulnerabilityAlerts: [ + "GET /repos/{owner}/{repo}/vulnerability-alerts" + ], + codeownersErrors: ["GET /repos/{owner}/{repo}/codeowners/errors"], + compareCommits: ["GET /repos/{owner}/{repo}/compare/{base}...{head}"], + compareCommitsWithBasehead: [ + "GET /repos/{owner}/{repo}/compare/{basehead}" + ], + createAutolink: ["POST /repos/{owner}/{repo}/autolinks"], + createCommitComment: [ + "POST /repos/{owner}/{repo}/commits/{commit_sha}/comments" + ], + createCommitSignatureProtection: [ + "POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures" + ], + createCommitStatus: ["POST /repos/{owner}/{repo}/statuses/{sha}"], + createDeployKey: ["POST /repos/{owner}/{repo}/keys"], + createDeployment: ["POST /repos/{owner}/{repo}/deployments"], + createDeploymentBranchPolicy: [ + "POST /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies" + ], + createDeploymentProtectionRule: [ + "POST /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules" + ], + createDeploymentStatus: [ + "POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses" + ], + createDispatchEvent: ["POST /repos/{owner}/{repo}/dispatches"], + createForAuthenticatedUser: ["POST /user/repos"], + createFork: ["POST /repos/{owner}/{repo}/forks"], + createInOrg: ["POST /orgs/{org}/repos"], + createOrUpdateEnvironment: [ + "PUT /repos/{owner}/{repo}/environments/{environment_name}" + ], + createOrUpdateFileContents: ["PUT /repos/{owner}/{repo}/contents/{path}"], + createOrgRuleset: ["POST /orgs/{org}/rulesets"], + createPagesDeployment: ["POST /repos/{owner}/{repo}/pages/deployment"], + createPagesSite: ["POST /repos/{owner}/{repo}/pages"], + createRelease: ["POST /repos/{owner}/{repo}/releases"], + createRepoRuleset: ["POST /repos/{owner}/{repo}/rulesets"], + createTagProtection: ["POST /repos/{owner}/{repo}/tags/protection"], + createUsingTemplate: [ + "POST /repos/{template_owner}/{template_repo}/generate" + ], + createWebhook: ["POST /repos/{owner}/{repo}/hooks"], + declineInvitation: [ + "DELETE /user/repository_invitations/{invitation_id}", + {}, + { renamed: ["repos", "declineInvitationForAuthenticatedUser"] } + ], + declineInvitationForAuthenticatedUser: [ + "DELETE /user/repository_invitations/{invitation_id}" + ], + delete: ["DELETE /repos/{owner}/{repo}"], + deleteAccessRestrictions: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions" + ], + deleteAdminBranchProtection: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins" + ], + deleteAnEnvironment: [ + "DELETE /repos/{owner}/{repo}/environments/{environment_name}" + ], + deleteAutolink: ["DELETE /repos/{owner}/{repo}/autolinks/{autolink_id}"], + deleteBranchProtection: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection" + ], + deleteCommitComment: ["DELETE /repos/{owner}/{repo}/comments/{comment_id}"], + deleteCommitSignatureProtection: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures" + ], + deleteDeployKey: ["DELETE /repos/{owner}/{repo}/keys/{key_id}"], + deleteDeployment: [ + "DELETE /repos/{owner}/{repo}/deployments/{deployment_id}" + ], + deleteDeploymentBranchPolicy: [ + "DELETE /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}" + ], + deleteFile: ["DELETE /repos/{owner}/{repo}/contents/{path}"], + deleteInvitation: [ + "DELETE /repos/{owner}/{repo}/invitations/{invitation_id}" + ], + deleteOrgRuleset: ["DELETE /orgs/{org}/rulesets/{ruleset_id}"], + deletePagesSite: ["DELETE /repos/{owner}/{repo}/pages"], + deletePullRequestReviewProtection: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews" + ], + deleteRelease: ["DELETE /repos/{owner}/{repo}/releases/{release_id}"], + deleteReleaseAsset: [ + "DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}" + ], + deleteRepoRuleset: ["DELETE /repos/{owner}/{repo}/rulesets/{ruleset_id}"], + deleteTagProtection: [ + "DELETE /repos/{owner}/{repo}/tags/protection/{tag_protection_id}" + ], + deleteWebhook: ["DELETE /repos/{owner}/{repo}/hooks/{hook_id}"], + disableAutomatedSecurityFixes: [ + "DELETE /repos/{owner}/{repo}/automated-security-fixes" + ], + disableDeploymentProtectionRule: [ + "DELETE /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}" + ], + disablePrivateVulnerabilityReporting: [ + "DELETE /repos/{owner}/{repo}/private-vulnerability-reporting" + ], + disableVulnerabilityAlerts: [ + "DELETE /repos/{owner}/{repo}/vulnerability-alerts" + ], + downloadArchive: [ + "GET /repos/{owner}/{repo}/zipball/{ref}", + {}, + { renamed: ["repos", "downloadZipballArchive"] } + ], + downloadTarballArchive: ["GET /repos/{owner}/{repo}/tarball/{ref}"], + downloadZipballArchive: ["GET /repos/{owner}/{repo}/zipball/{ref}"], + enableAutomatedSecurityFixes: [ + "PUT /repos/{owner}/{repo}/automated-security-fixes" + ], + enablePrivateVulnerabilityReporting: [ + "PUT /repos/{owner}/{repo}/private-vulnerability-reporting" + ], + enableVulnerabilityAlerts: [ + "PUT /repos/{owner}/{repo}/vulnerability-alerts" + ], + generateReleaseNotes: [ + "POST /repos/{owner}/{repo}/releases/generate-notes" + ], + get: ["GET /repos/{owner}/{repo}"], + getAccessRestrictions: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions" + ], + getAdminBranchProtection: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins" + ], + getAllDeploymentProtectionRules: [ + "GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules" + ], + getAllEnvironments: ["GET /repos/{owner}/{repo}/environments"], + getAllStatusCheckContexts: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts" + ], + getAllTopics: ["GET /repos/{owner}/{repo}/topics"], + getAppsWithAccessToProtectedBranch: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps" + ], + getAutolink: ["GET /repos/{owner}/{repo}/autolinks/{autolink_id}"], + getBranch: ["GET /repos/{owner}/{repo}/branches/{branch}"], + getBranchProtection: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection" + ], + getBranchRules: ["GET /repos/{owner}/{repo}/rules/branches/{branch}"], + getClones: ["GET /repos/{owner}/{repo}/traffic/clones"], + getCodeFrequencyStats: ["GET /repos/{owner}/{repo}/stats/code_frequency"], + getCollaboratorPermissionLevel: [ + "GET /repos/{owner}/{repo}/collaborators/{username}/permission" + ], + getCombinedStatusForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/status"], + getCommit: ["GET /repos/{owner}/{repo}/commits/{ref}"], + getCommitActivityStats: ["GET /repos/{owner}/{repo}/stats/commit_activity"], + getCommitComment: ["GET /repos/{owner}/{repo}/comments/{comment_id}"], + getCommitSignatureProtection: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures" + ], + getCommunityProfileMetrics: ["GET /repos/{owner}/{repo}/community/profile"], + getContent: ["GET /repos/{owner}/{repo}/contents/{path}"], + getContributorsStats: ["GET /repos/{owner}/{repo}/stats/contributors"], + getCustomDeploymentProtectionRule: [ + "GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}" + ], + getCustomPropertiesValues: ["GET /repos/{owner}/{repo}/properties/values"], + getDeployKey: ["GET /repos/{owner}/{repo}/keys/{key_id}"], + getDeployment: ["GET /repos/{owner}/{repo}/deployments/{deployment_id}"], + getDeploymentBranchPolicy: [ + "GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}" + ], + getDeploymentStatus: [ + "GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}" + ], + getEnvironment: [ + "GET /repos/{owner}/{repo}/environments/{environment_name}" + ], + getLatestPagesBuild: ["GET /repos/{owner}/{repo}/pages/builds/latest"], + getLatestRelease: ["GET /repos/{owner}/{repo}/releases/latest"], + getOrgRuleSuite: ["GET /orgs/{org}/rulesets/rule-suites/{rule_suite_id}"], + getOrgRuleSuites: ["GET /orgs/{org}/rulesets/rule-suites"], + getOrgRuleset: ["GET /orgs/{org}/rulesets/{ruleset_id}"], + getOrgRulesets: ["GET /orgs/{org}/rulesets"], + getPages: ["GET /repos/{owner}/{repo}/pages"], + getPagesBuild: ["GET /repos/{owner}/{repo}/pages/builds/{build_id}"], + getPagesHealthCheck: ["GET /repos/{owner}/{repo}/pages/health"], + getParticipationStats: ["GET /repos/{owner}/{repo}/stats/participation"], + getPullRequestReviewProtection: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews" + ], + getPunchCardStats: ["GET /repos/{owner}/{repo}/stats/punch_card"], + getReadme: ["GET /repos/{owner}/{repo}/readme"], + getReadmeInDirectory: ["GET /repos/{owner}/{repo}/readme/{dir}"], + getRelease: ["GET /repos/{owner}/{repo}/releases/{release_id}"], + getReleaseAsset: ["GET /repos/{owner}/{repo}/releases/assets/{asset_id}"], + getReleaseByTag: ["GET /repos/{owner}/{repo}/releases/tags/{tag}"], + getRepoRuleSuite: [ + "GET /repos/{owner}/{repo}/rulesets/rule-suites/{rule_suite_id}" + ], + getRepoRuleSuites: ["GET /repos/{owner}/{repo}/rulesets/rule-suites"], + getRepoRuleset: ["GET /repos/{owner}/{repo}/rulesets/{ruleset_id}"], + getRepoRulesets: ["GET /repos/{owner}/{repo}/rulesets"], + getStatusChecksProtection: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks" + ], + getTeamsWithAccessToProtectedBranch: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams" + ], + getTopPaths: ["GET /repos/{owner}/{repo}/traffic/popular/paths"], + getTopReferrers: ["GET /repos/{owner}/{repo}/traffic/popular/referrers"], + getUsersWithAccessToProtectedBranch: [ + "GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users" + ], + getViews: ["GET /repos/{owner}/{repo}/traffic/views"], + getWebhook: ["GET /repos/{owner}/{repo}/hooks/{hook_id}"], + getWebhookConfigForRepo: [ + "GET /repos/{owner}/{repo}/hooks/{hook_id}/config" + ], + getWebhookDelivery: [ + "GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}" + ], + listActivities: ["GET /repos/{owner}/{repo}/activity"], + listAutolinks: ["GET /repos/{owner}/{repo}/autolinks"], + listBranches: ["GET /repos/{owner}/{repo}/branches"], + listBranchesForHeadCommit: [ + "GET /repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head" + ], + listCollaborators: ["GET /repos/{owner}/{repo}/collaborators"], + listCommentsForCommit: [ + "GET /repos/{owner}/{repo}/commits/{commit_sha}/comments" + ], + listCommitCommentsForRepo: ["GET /repos/{owner}/{repo}/comments"], + listCommitStatusesForRef: [ + "GET /repos/{owner}/{repo}/commits/{ref}/statuses" + ], + listCommits: ["GET /repos/{owner}/{repo}/commits"], + listContributors: ["GET /repos/{owner}/{repo}/contributors"], + listCustomDeploymentRuleIntegrations: [ + "GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps" + ], + listDeployKeys: ["GET /repos/{owner}/{repo}/keys"], + listDeploymentBranchPolicies: [ + "GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies" + ], + listDeploymentStatuses: [ + "GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses" + ], + listDeployments: ["GET /repos/{owner}/{repo}/deployments"], + listForAuthenticatedUser: ["GET /user/repos"], + listForOrg: ["GET /orgs/{org}/repos"], + listForUser: ["GET /users/{username}/repos"], + listForks: ["GET /repos/{owner}/{repo}/forks"], + listInvitations: ["GET /repos/{owner}/{repo}/invitations"], + listInvitationsForAuthenticatedUser: ["GET /user/repository_invitations"], + listLanguages: ["GET /repos/{owner}/{repo}/languages"], + listPagesBuilds: ["GET /repos/{owner}/{repo}/pages/builds"], + listPublic: ["GET /repositories"], + listPullRequestsAssociatedWithCommit: [ + "GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls" + ], + listReleaseAssets: [ + "GET /repos/{owner}/{repo}/releases/{release_id}/assets" + ], + listReleases: ["GET /repos/{owner}/{repo}/releases"], + listTagProtection: ["GET /repos/{owner}/{repo}/tags/protection"], + listTags: ["GET /repos/{owner}/{repo}/tags"], + listTeams: ["GET /repos/{owner}/{repo}/teams"], + listWebhookDeliveries: [ + "GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries" + ], + listWebhooks: ["GET /repos/{owner}/{repo}/hooks"], + merge: ["POST /repos/{owner}/{repo}/merges"], + mergeUpstream: ["POST /repos/{owner}/{repo}/merge-upstream"], + pingWebhook: ["POST /repos/{owner}/{repo}/hooks/{hook_id}/pings"], + redeliverWebhookDelivery: [ + "POST /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}/attempts" + ], + removeAppAccessRestrictions: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", + {}, + { mapToData: "apps" } + ], + removeCollaborator: [ + "DELETE /repos/{owner}/{repo}/collaborators/{username}" + ], + removeStatusCheckContexts: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", + {}, + { mapToData: "contexts" } + ], + removeStatusCheckProtection: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks" + ], + removeTeamAccessRestrictions: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", + {}, + { mapToData: "teams" } + ], + removeUserAccessRestrictions: [ + "DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", + {}, + { mapToData: "users" } + ], + renameBranch: ["POST /repos/{owner}/{repo}/branches/{branch}/rename"], + replaceAllTopics: ["PUT /repos/{owner}/{repo}/topics"], + requestPagesBuild: ["POST /repos/{owner}/{repo}/pages/builds"], + setAdminBranchProtection: [ + "POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins" + ], + setAppAccessRestrictions: [ + "PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", + {}, + { mapToData: "apps" } + ], + setStatusCheckContexts: [ + "PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", + {}, + { mapToData: "contexts" } + ], + setTeamAccessRestrictions: [ + "PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", + {}, + { mapToData: "teams" } + ], + setUserAccessRestrictions: [ + "PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", + {}, + { mapToData: "users" } + ], + testPushWebhook: ["POST /repos/{owner}/{repo}/hooks/{hook_id}/tests"], + transfer: ["POST /repos/{owner}/{repo}/transfer"], + update: ["PATCH /repos/{owner}/{repo}"], + updateBranchProtection: [ + "PUT /repos/{owner}/{repo}/branches/{branch}/protection" + ], + updateCommitComment: ["PATCH /repos/{owner}/{repo}/comments/{comment_id}"], + updateDeploymentBranchPolicy: [ + "PUT /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}" + ], + updateInformationAboutPagesSite: ["PUT /repos/{owner}/{repo}/pages"], + updateInvitation: [ + "PATCH /repos/{owner}/{repo}/invitations/{invitation_id}" + ], + updateOrgRuleset: ["PUT /orgs/{org}/rulesets/{ruleset_id}"], + updatePullRequestReviewProtection: [ + "PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews" + ], + updateRelease: ["PATCH /repos/{owner}/{repo}/releases/{release_id}"], + updateReleaseAsset: [ + "PATCH /repos/{owner}/{repo}/releases/assets/{asset_id}" + ], + updateRepoRuleset: ["PUT /repos/{owner}/{repo}/rulesets/{ruleset_id}"], + updateStatusCheckPotection: [ + "PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks", + {}, + { renamed: ["repos", "updateStatusCheckProtection"] } + ], + updateStatusCheckProtection: [ + "PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks" + ], + updateWebhook: ["PATCH /repos/{owner}/{repo}/hooks/{hook_id}"], + updateWebhookConfigForRepo: [ + "PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config" + ], + uploadReleaseAsset: [ + "POST /repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}", + { baseUrl: "https://uploads.github.com" } + ] + }, + search: { + code: ["GET /search/code"], + commits: ["GET /search/commits"], + issuesAndPullRequests: ["GET /search/issues"], + labels: ["GET /search/labels"], + repos: ["GET /search/repositories"], + topics: ["GET /search/topics"], + users: ["GET /search/users"] + }, + secretScanning: { + getAlert: [ + "GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}" + ], + listAlertsForEnterprise: [ + "GET /enterprises/{enterprise}/secret-scanning/alerts" + ], + listAlertsForOrg: ["GET /orgs/{org}/secret-scanning/alerts"], + listAlertsForRepo: ["GET /repos/{owner}/{repo}/secret-scanning/alerts"], + listLocationsForAlert: [ + "GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations" + ], + updateAlert: [ + "PATCH /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}" + ] + }, + securityAdvisories: { + createPrivateVulnerabilityReport: [ + "POST /repos/{owner}/{repo}/security-advisories/reports" + ], + createRepositoryAdvisory: [ + "POST /repos/{owner}/{repo}/security-advisories" + ], + createRepositoryAdvisoryCveRequest: [ + "POST /repos/{owner}/{repo}/security-advisories/{ghsa_id}/cve" + ], + getGlobalAdvisory: ["GET /advisories/{ghsa_id}"], + getRepositoryAdvisory: [ + "GET /repos/{owner}/{repo}/security-advisories/{ghsa_id}" + ], + listGlobalAdvisories: ["GET /advisories"], + listOrgRepositoryAdvisories: ["GET /orgs/{org}/security-advisories"], + listRepositoryAdvisories: ["GET /repos/{owner}/{repo}/security-advisories"], + updateRepositoryAdvisory: [ + "PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id}" + ] + }, + teams: { + addOrUpdateMembershipForUserInOrg: [ + "PUT /orgs/{org}/teams/{team_slug}/memberships/{username}" + ], + addOrUpdateProjectPermissionsInOrg: [ + "PUT /orgs/{org}/teams/{team_slug}/projects/{project_id}" + ], + addOrUpdateRepoPermissionsInOrg: [ + "PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}" + ], + checkPermissionsForProjectInOrg: [ + "GET /orgs/{org}/teams/{team_slug}/projects/{project_id}" + ], + checkPermissionsForRepoInOrg: [ + "GET /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}" + ], + create: ["POST /orgs/{org}/teams"], + createDiscussionCommentInOrg: [ + "POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments" + ], + createDiscussionInOrg: ["POST /orgs/{org}/teams/{team_slug}/discussions"], + deleteDiscussionCommentInOrg: [ + "DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}" + ], + deleteDiscussionInOrg: [ + "DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}" + ], + deleteInOrg: ["DELETE /orgs/{org}/teams/{team_slug}"], + getByName: ["GET /orgs/{org}/teams/{team_slug}"], + getDiscussionCommentInOrg: [ + "GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}" + ], + getDiscussionInOrg: [ + "GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}" + ], + getMembershipForUserInOrg: [ + "GET /orgs/{org}/teams/{team_slug}/memberships/{username}" + ], + list: ["GET /orgs/{org}/teams"], + listChildInOrg: ["GET /orgs/{org}/teams/{team_slug}/teams"], + listDiscussionCommentsInOrg: [ + "GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments" + ], + listDiscussionsInOrg: ["GET /orgs/{org}/teams/{team_slug}/discussions"], + listForAuthenticatedUser: ["GET /user/teams"], + listMembersInOrg: ["GET /orgs/{org}/teams/{team_slug}/members"], + listPendingInvitationsInOrg: [ + "GET /orgs/{org}/teams/{team_slug}/invitations" + ], + listProjectsInOrg: ["GET /orgs/{org}/teams/{team_slug}/projects"], + listReposInOrg: ["GET /orgs/{org}/teams/{team_slug}/repos"], + removeMembershipForUserInOrg: [ + "DELETE /orgs/{org}/teams/{team_slug}/memberships/{username}" + ], + removeProjectInOrg: [ + "DELETE /orgs/{org}/teams/{team_slug}/projects/{project_id}" + ], + removeRepoInOrg: [ + "DELETE /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}" + ], + updateDiscussionCommentInOrg: [ + "PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}" + ], + updateDiscussionInOrg: [ + "PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}" + ], + updateInOrg: ["PATCH /orgs/{org}/teams/{team_slug}"] + }, + users: { + addEmailForAuthenticated: [ + "POST /user/emails", + {}, + { renamed: ["users", "addEmailForAuthenticatedUser"] } + ], + addEmailForAuthenticatedUser: ["POST /user/emails"], + addSocialAccountForAuthenticatedUser: ["POST /user/social_accounts"], + block: ["PUT /user/blocks/{username}"], + checkBlocked: ["GET /user/blocks/{username}"], + checkFollowingForUser: ["GET /users/{username}/following/{target_user}"], + checkPersonIsFollowedByAuthenticated: ["GET /user/following/{username}"], + createGpgKeyForAuthenticated: [ + "POST /user/gpg_keys", + {}, + { renamed: ["users", "createGpgKeyForAuthenticatedUser"] } + ], + createGpgKeyForAuthenticatedUser: ["POST /user/gpg_keys"], + createPublicSshKeyForAuthenticated: [ + "POST /user/keys", + {}, + { renamed: ["users", "createPublicSshKeyForAuthenticatedUser"] } + ], + createPublicSshKeyForAuthenticatedUser: ["POST /user/keys"], + createSshSigningKeyForAuthenticatedUser: ["POST /user/ssh_signing_keys"], + deleteEmailForAuthenticated: [ + "DELETE /user/emails", + {}, + { renamed: ["users", "deleteEmailForAuthenticatedUser"] } + ], + deleteEmailForAuthenticatedUser: ["DELETE /user/emails"], + deleteGpgKeyForAuthenticated: [ + "DELETE /user/gpg_keys/{gpg_key_id}", + {}, + { renamed: ["users", "deleteGpgKeyForAuthenticatedUser"] } + ], + deleteGpgKeyForAuthenticatedUser: ["DELETE /user/gpg_keys/{gpg_key_id}"], + deletePublicSshKeyForAuthenticated: [ + "DELETE /user/keys/{key_id}", + {}, + { renamed: ["users", "deletePublicSshKeyForAuthenticatedUser"] } + ], + deletePublicSshKeyForAuthenticatedUser: ["DELETE /user/keys/{key_id}"], + deleteSocialAccountForAuthenticatedUser: ["DELETE /user/social_accounts"], + deleteSshSigningKeyForAuthenticatedUser: [ + "DELETE /user/ssh_signing_keys/{ssh_signing_key_id}" + ], + follow: ["PUT /user/following/{username}"], + getAuthenticated: ["GET /user"], + getByUsername: ["GET /users/{username}"], + getContextForUser: ["GET /users/{username}/hovercard"], + getGpgKeyForAuthenticated: [ + "GET /user/gpg_keys/{gpg_key_id}", + {}, + { renamed: ["users", "getGpgKeyForAuthenticatedUser"] } + ], + getGpgKeyForAuthenticatedUser: ["GET /user/gpg_keys/{gpg_key_id}"], + getPublicSshKeyForAuthenticated: [ + "GET /user/keys/{key_id}", + {}, + { renamed: ["users", "getPublicSshKeyForAuthenticatedUser"] } + ], + getPublicSshKeyForAuthenticatedUser: ["GET /user/keys/{key_id}"], + getSshSigningKeyForAuthenticatedUser: [ + "GET /user/ssh_signing_keys/{ssh_signing_key_id}" + ], + list: ["GET /users"], + listBlockedByAuthenticated: [ + "GET /user/blocks", + {}, + { renamed: ["users", "listBlockedByAuthenticatedUser"] } + ], + listBlockedByAuthenticatedUser: ["GET /user/blocks"], + listEmailsForAuthenticated: [ + "GET /user/emails", + {}, + { renamed: ["users", "listEmailsForAuthenticatedUser"] } + ], + listEmailsForAuthenticatedUser: ["GET /user/emails"], + listFollowedByAuthenticated: [ + "GET /user/following", + {}, + { renamed: ["users", "listFollowedByAuthenticatedUser"] } + ], + listFollowedByAuthenticatedUser: ["GET /user/following"], + listFollowersForAuthenticatedUser: ["GET /user/followers"], + listFollowersForUser: ["GET /users/{username}/followers"], + listFollowingForUser: ["GET /users/{username}/following"], + listGpgKeysForAuthenticated: [ + "GET /user/gpg_keys", + {}, + { renamed: ["users", "listGpgKeysForAuthenticatedUser"] } + ], + listGpgKeysForAuthenticatedUser: ["GET /user/gpg_keys"], + listGpgKeysForUser: ["GET /users/{username}/gpg_keys"], + listPublicEmailsForAuthenticated: [ + "GET /user/public_emails", + {}, + { renamed: ["users", "listPublicEmailsForAuthenticatedUser"] } + ], + listPublicEmailsForAuthenticatedUser: ["GET /user/public_emails"], + listPublicKeysForUser: ["GET /users/{username}/keys"], + listPublicSshKeysForAuthenticated: [ + "GET /user/keys", + {}, + { renamed: ["users", "listPublicSshKeysForAuthenticatedUser"] } + ], + listPublicSshKeysForAuthenticatedUser: ["GET /user/keys"], + listSocialAccountsForAuthenticatedUser: ["GET /user/social_accounts"], + listSocialAccountsForUser: ["GET /users/{username}/social_accounts"], + listSshSigningKeysForAuthenticatedUser: ["GET /user/ssh_signing_keys"], + listSshSigningKeysForUser: ["GET /users/{username}/ssh_signing_keys"], + setPrimaryEmailVisibilityForAuthenticated: [ + "PATCH /user/email/visibility", + {}, + { renamed: ["users", "setPrimaryEmailVisibilityForAuthenticatedUser"] } + ], + setPrimaryEmailVisibilityForAuthenticatedUser: [ + "PATCH /user/email/visibility" + ], + unblock: ["DELETE /user/blocks/{username}"], + unfollow: ["DELETE /user/following/{username}"], + updateAuthenticated: ["PATCH /user"] + } +}; +var endpoints_default = Endpoints; + +// pkg/dist-src/endpoints-to-methods.js +var endpointMethodsMap = /* @__PURE__ */ new Map(); +for (const [scope, endpoints] of Object.entries(endpoints_default)) { + for (const [methodName, endpoint] of Object.entries(endpoints)) { + const [route, defaults, decorations] = endpoint; + const [method, url] = route.split(/ /); + const endpointDefaults = Object.assign( + { + method, + url + }, + defaults + ); + if (!endpointMethodsMap.has(scope)) { + endpointMethodsMap.set(scope, /* @__PURE__ */ new Map()); + } + endpointMethodsMap.get(scope).set(methodName, { + scope, + methodName, + endpointDefaults, + decorations + }); + } +} +var handler = { + has({ scope }, methodName) { + return endpointMethodsMap.get(scope).has(methodName); + }, + getOwnPropertyDescriptor(target, methodName) { + return { + value: this.get(target, methodName), + // ensures method is in the cache + configurable: true, + writable: true, + enumerable: true + }; + }, + defineProperty(target, methodName, descriptor) { + Object.defineProperty(target.cache, methodName, descriptor); + return true; + }, + deleteProperty(target, methodName) { + delete target.cache[methodName]; + return true; + }, + ownKeys({ scope }) { + return [...endpointMethodsMap.get(scope).keys()]; + }, + set(target, methodName, value) { + return target.cache[methodName] = value; + }, + get({ octokit, scope, cache }, methodName) { + if (cache[methodName]) { + return cache[methodName]; + } + const method = endpointMethodsMap.get(scope).get(methodName); + if (!method) { + return void 0; + } + const { endpointDefaults, decorations } = method; + if (decorations) { + cache[methodName] = decorate( + octokit, + scope, + methodName, + endpointDefaults, + decorations + ); + } else { + cache[methodName] = octokit.request.defaults(endpointDefaults); + } + return cache[methodName]; + } +}; +function endpointsToMethods(octokit) { + const newMethods = {}; + for (const scope of endpointMethodsMap.keys()) { + newMethods[scope] = new Proxy({ octokit, scope, cache: {} }, handler); + } + return newMethods; +} +function decorate(octokit, scope, methodName, defaults, decorations) { + const requestWithDefaults = octokit.request.defaults(defaults); + function withDecorations(...args) { + let options = requestWithDefaults.endpoint.merge(...args); + if (decorations.mapToData) { + options = Object.assign({}, options, { + data: options[decorations.mapToData], + [decorations.mapToData]: void 0 + }); + return requestWithDefaults(options); + } + if (decorations.renamed) { + const [newScope, newMethodName] = decorations.renamed; + octokit.log.warn( + `octokit.${scope}.${methodName}() has been renamed to octokit.${newScope}.${newMethodName}()` + ); + } + if (decorations.deprecated) { + octokit.log.warn(decorations.deprecated); + } + if (decorations.renamedParameters) { + const options2 = requestWithDefaults.endpoint.merge(...args); + for (const [name, alias] of Object.entries( + decorations.renamedParameters + )) { + if (name in options2) { + octokit.log.warn( + `"${name}" parameter is deprecated for "octokit.${scope}.${methodName}()". Use "${alias}" instead` + ); + if (!(alias in options2)) { + options2[alias] = options2[name]; + } + delete options2[name]; + } + } + return requestWithDefaults(options2); + } + return requestWithDefaults(...args); } + return Object.assign(withDecorations, requestWithDefaults); +} - return target; +// pkg/dist-src/index.js +function restEndpointMethods(octokit) { + const api = endpointsToMethods(octokit); + return { + rest: api + }; +} +restEndpointMethods.VERSION = VERSION; +function legacyRestEndpointMethods(octokit) { + const api = endpointsToMethods(octokit); + return { + ...api, + rest: api + }; } +legacyRestEndpointMethods.VERSION = VERSION; +// Annotate the CommonJS export names for ESM import in node: +0 && (0); -function _objectWithoutProperties(source, excluded) { - if (source == null) return {}; - var target = _objectWithoutPropertiesLoose(source, excluded); +/***/ }), - var key, i; +/***/ 537: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - if (Object.getOwnPropertySymbols) { - var sourceSymbolKeys = Object.getOwnPropertySymbols(source); +"use strict"; - for (i = 0; i < sourceSymbolKeys.length; i++) { - key = sourceSymbolKeys[i]; - if (excluded.indexOf(key) >= 0) continue; - if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; - target[key] = source[key]; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// pkg/dist-src/index.js +var dist_src_exports = {}; +__export(dist_src_exports, { + RequestError: () => RequestError +}); +module.exports = __toCommonJS(dist_src_exports); +var import_deprecation = __nccwpck_require__(8932); +var import_once = __toESM(__nccwpck_require__(1223)); +var logOnceCode = (0, import_once.default)((deprecation) => console.warn(deprecation)); +var logOnceHeaders = (0, import_once.default)((deprecation) => console.warn(deprecation)); +var RequestError = class extends Error { + constructor(message, statusCode, options) { + super(message); + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); + } + this.name = "HttpError"; + this.status = statusCode; + let headers; + if ("headers" in options && typeof options.headers !== "undefined") { + headers = options.headers; } + if ("response" in options) { + this.response = options.response; + headers = options.response.headers; + } + const requestCopy = Object.assign({}, options.request); + if (options.request.headers.authorization) { + requestCopy.headers = Object.assign({}, options.request.headers, { + authorization: options.request.headers.authorization.replace( + / .*$/, + " [REDACTED]" + ) + }); + } + requestCopy.url = requestCopy.url.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]").replace(/\baccess_token=\w+/g, "access_token=[REDACTED]"); + this.request = requestCopy; + Object.defineProperty(this, "code", { + get() { + logOnceCode( + new import_deprecation.Deprecation( + "[@octokit/request-error] `error.code` is deprecated, use `error.status`." + ) + ); + return statusCode; + } + }); + Object.defineProperty(this, "headers", { + get() { + logOnceHeaders( + new import_deprecation.Deprecation( + "[@octokit/request-error] `error.headers` is deprecated, use `error.response.headers`." + ) + ); + return headers || {}; + } + }); } +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (0); - return target; -} - -const VERSION = "3.2.4"; -class Octokit { - constructor(options = {}) { - const hook = new beforeAfterHook.Collection(); - const requestDefaults = { - baseUrl: request.request.endpoint.DEFAULTS.baseUrl, - headers: {}, - request: Object.assign({}, options.request, { - hook: hook.bind(null, "request") - }), - mediaType: { - previews: [], - format: "" - } - }; // prepend default user agent with `options.userAgent` if set +/***/ }), - requestDefaults.headers["user-agent"] = [options.userAgent, `octokit-core.js/${VERSION} ${universalUserAgent.getUserAgent()}`].filter(Boolean).join(" "); +/***/ 6234: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - if (options.baseUrl) { - requestDefaults.baseUrl = options.baseUrl; - } +"use strict"; - if (options.previews) { - requestDefaults.mediaType.previews = options.previews; - } +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); - if (options.timeZone) { - requestDefaults.headers["time-zone"] = options.timeZone; - } +// pkg/dist-src/index.js +var dist_src_exports = {}; +__export(dist_src_exports, { + request: () => request +}); +module.exports = __toCommonJS(dist_src_exports); +var import_endpoint = __nccwpck_require__(9440); +var import_universal_user_agent = __nccwpck_require__(5030); - this.request = request.request.defaults(requestDefaults); - this.graphql = graphql.withCustomRequest(this.request).defaults(requestDefaults); - this.log = Object.assign({ - debug: () => {}, - info: () => {}, - warn: console.warn.bind(console), - error: console.error.bind(console) - }, options.log); - this.hook = hook; // (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance - // is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered. - // (2) If only `options.auth` is set, use the default token authentication strategy. - // (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance. - // TODO: type `options.auth` based on `options.authStrategy`. +// pkg/dist-src/version.js +var VERSION = "8.2.0"; - if (!options.authStrategy) { - if (!options.auth) { - // (1) - this.auth = async () => ({ - type: "unauthenticated" - }); - } else { - // (2) - const auth = authToken.createTokenAuth(options.auth); // @ts-ignore ¯\_(ツ)_/¯ - - hook.wrap("request", auth.hook); - this.auth = auth; - } - } else { - const { - authStrategy - } = options, - otherOptions = _objectWithoutProperties(options, ["authStrategy"]); - - const auth = authStrategy(Object.assign({ - request: this.request, - log: this.log, - // we pass the current octokit instance as well as its constructor options - // to allow for authentication strategies that return a new octokit instance - // that shares the same internal state as the current one. The original - // requirement for this was the "event-octokit" authentication strategy - // of https://github.com/probot/octokit-auth-probot. - octokit: this, - octokitOptions: otherOptions - }, options.auth)); // @ts-ignore ¯\_(ツ)_/¯ +// pkg/dist-src/is-plain-object.js +function isPlainObject(value) { + if (typeof value !== "object" || value === null) + return false; + if (Object.prototype.toString.call(value) !== "[object Object]") + return false; + const proto = Object.getPrototypeOf(value); + if (proto === null) + return true; + const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor; + return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value); +} - hook.wrap("request", auth.hook); - this.auth = auth; - } // apply plugins - // https://stackoverflow.com/a/16345172 +// pkg/dist-src/fetch-wrapper.js +var import_request_error = __nccwpck_require__(537); +// pkg/dist-src/get-buffer-response.js +function getBufferResponse(response) { + return response.arrayBuffer(); +} - const classConstructor = this.constructor; - classConstructor.plugins.forEach(plugin => { - Object.assign(this, plugin(this, options)); - }); +// pkg/dist-src/fetch-wrapper.js +function fetchWrapper(requestOptions) { + var _a, _b, _c; + const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console; + const parseSuccessResponseBody = ((_a = requestOptions.request) == null ? void 0 : _a.parseSuccessResponseBody) !== false; + if (isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) { + requestOptions.body = JSON.stringify(requestOptions.body); } - - static defaults(defaults) { - const OctokitWithDefaults = class extends this { - constructor(...args) { - const options = args[0] || {}; - - if (typeof defaults === "function") { - super(defaults(options)); - return; - } - - super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent ? { - userAgent: `${options.userAgent} ${defaults.userAgent}` - } : null)); + let headers = {}; + let status; + let url; + let { fetch } = globalThis; + if ((_b = requestOptions.request) == null ? void 0 : _b.fetch) { + fetch = requestOptions.request.fetch; + } + if (!fetch) { + throw new Error( + "fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing" + ); + } + return fetch(requestOptions.url, { + method: requestOptions.method, + body: requestOptions.body, + headers: requestOptions.headers, + signal: (_c = requestOptions.request) == null ? void 0 : _c.signal, + // duplex must be set if request.body is ReadableStream or Async Iterables. + // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex. + ...requestOptions.body && { duplex: "half" } + }).then(async (response) => { + url = response.url; + status = response.status; + for (const keyAndValue of response.headers) { + headers[keyAndValue[0]] = keyAndValue[1]; + } + if ("deprecation" in headers) { + const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/); + const deprecationLink = matches && matches.pop(); + log.warn( + `[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${headers.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}` + ); + } + if (status === 204 || status === 205) { + return; + } + if (requestOptions.method === "HEAD") { + if (status < 400) { + return; } - + throw new import_request_error.RequestError(response.statusText, status, { + response: { + url, + status, + headers, + data: void 0 + }, + request: requestOptions + }); + } + if (status === 304) { + throw new import_request_error.RequestError("Not modified", status, { + response: { + url, + status, + headers, + data: await getResponseData(response) + }, + request: requestOptions + }); + } + if (status >= 400) { + const data = await getResponseData(response); + const error = new import_request_error.RequestError(toErrorMessage(data), status, { + response: { + url, + status, + headers, + data + }, + request: requestOptions + }); + throw error; + } + return parseSuccessResponseBody ? await getResponseData(response) : response.body; + }).then((data) => { + return { + status, + url, + headers, + data }; - return OctokitWithDefaults; + }).catch((error) => { + if (error instanceof import_request_error.RequestError) + throw error; + else if (error.name === "AbortError") + throw error; + let message = error.message; + if (error.name === "TypeError" && "cause" in error) { + if (error.cause instanceof Error) { + message = error.cause.message; + } else if (typeof error.cause === "string") { + message = error.cause; + } + } + throw new import_request_error.RequestError(message, 500, { + request: requestOptions + }); + }); +} +async function getResponseData(response) { + const contentType = response.headers.get("content-type"); + if (/application\/json/.test(contentType)) { + return response.json().catch(() => response.text()).catch(() => ""); } - /** - * Attach a plugin (or many) to your Octokit instance. - * - * @example - * const API = Octokit.plugin(plugin1, plugin2, plugin3, ...) - */ - - - static plugin(...newPlugins) { - var _a; - - const currentPlugins = this.plugins; - const NewOctokit = (_a = class extends this {}, _a.plugins = currentPlugins.concat(newPlugins.filter(plugin => !currentPlugins.includes(plugin))), _a); - return NewOctokit; + if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) { + return response.text(); } + return getBufferResponse(response); +} +function toErrorMessage(data) { + if (typeof data === "string") + return data; + let suffix; + if ("documentation_url" in data) { + suffix = ` - ${data.documentation_url}`; + } else { + suffix = ""; + } + if ("message" in data) { + if (Array.isArray(data.errors)) { + return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}${suffix}`; + } + return `${data.message}${suffix}`; + } + return `Unknown error: ${JSON.stringify(data)}`; +} +// pkg/dist-src/with-defaults.js +function withDefaults(oldEndpoint, newDefaults) { + const endpoint2 = oldEndpoint.defaults(newDefaults); + const newApi = function(route, parameters) { + const endpointOptions = endpoint2.merge(route, parameters); + if (!endpointOptions.request || !endpointOptions.request.hook) { + return fetchWrapper(endpoint2.parse(endpointOptions)); + } + const request2 = (route2, parameters2) => { + return fetchWrapper( + endpoint2.parse(endpoint2.merge(route2, parameters2)) + ); + }; + Object.assign(request2, { + endpoint: endpoint2, + defaults: withDefaults.bind(null, endpoint2) + }); + return endpointOptions.request.hook(request2, endpointOptions); + }; + return Object.assign(newApi, { + endpoint: endpoint2, + defaults: withDefaults.bind(null, endpoint2) + }); } -Octokit.VERSION = VERSION; -Octokit.plugins = []; -exports.Octokit = Octokit; -//# sourceMappingURL=index.js.map +// pkg/dist-src/index.js +var request = withDefaults(import_endpoint.endpoint, { + headers: { + "user-agent": `octokit-request.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}` + } +}); +// Annotate the CommonJS export names for ESM import in node: +0 && (0); /***/ }), -/***/ 9440: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 9417: +/***/ ((module) => { "use strict"; +module.exports = balanced; +function balanced(a, b, str) { + if (a instanceof RegExp) a = maybeMatch(a, str); + if (b instanceof RegExp) b = maybeMatch(b, str); -Object.defineProperty(exports, "__esModule", ({ value: true })); - -var isPlainObject = __nccwpck_require__(558); -var universalUserAgent = __nccwpck_require__(5030); - -function lowercaseKeys(object) { - if (!object) { - return {}; - } + var r = range(a, b, str); - return Object.keys(object).reduce((newObj, key) => { - newObj[key.toLowerCase()] = object[key]; - return newObj; - }, {}); + return r && { + start: r[0], + end: r[1], + pre: str.slice(0, r[0]), + body: str.slice(r[0] + a.length, r[1]), + post: str.slice(r[1] + b.length) + }; } -function mergeDeep(defaults, options) { - const result = Object.assign({}, defaults); - Object.keys(options).forEach(key => { - if (isPlainObject.isPlainObject(options[key])) { - if (!(key in defaults)) Object.assign(result, { - [key]: options[key] - });else result[key] = mergeDeep(defaults[key], options[key]); - } else { - Object.assign(result, { - [key]: options[key] - }); - } - }); - return result; +function maybeMatch(reg, str) { + var m = str.match(reg); + return m ? m[0] : null; } -function removeUndefinedProperties(obj) { - for (const key in obj) { - if (obj[key] === undefined) { - delete obj[key]; - } - } - - return obj; -} +balanced.range = range; +function range(a, b, str) { + var begs, beg, left, right, result; + var ai = str.indexOf(a); + var bi = str.indexOf(b, ai + 1); + var i = ai; -function merge(defaults, route, options) { - if (typeof route === "string") { - let [method, url] = route.split(" "); - options = Object.assign(url ? { - method, - url - } : { - url: method - }, options); - } else { - options = Object.assign({}, route); - } // lowercase header names before merging with defaults to avoid duplicates + if (ai >= 0 && bi > 0) { + if(a===b) { + return [ai, bi]; + } + begs = []; + left = str.length; + while (i >= 0 && !result) { + if (i == ai) { + begs.push(i); + ai = str.indexOf(a, i + 1); + } else if (begs.length == 1) { + result = [ begs.pop(), bi ]; + } else { + beg = begs.pop(); + if (beg < left) { + left = beg; + right = bi; + } - options.headers = lowercaseKeys(options.headers); // remove properties with undefined values before merging + bi = str.indexOf(b, i + 1); + } - removeUndefinedProperties(options); - removeUndefinedProperties(options.headers); - const mergedOptions = mergeDeep(defaults || {}, options); // mediaType.previews arrays are merged, instead of overwritten + i = ai < bi && ai >= 0 ? ai : bi; + } - if (defaults && defaults.mediaType.previews.length) { - mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(preview => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews); + if (begs.length) { + result = [ left, right ]; + } } - mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map(preview => preview.replace(/-preview/, "")); - return mergedOptions; + return result; } -function addQueryParameters(url, parameters) { - const separator = /\?/.test(url) ? "&" : "?"; - const names = Object.keys(parameters); - if (names.length === 0) { - return url; - } +/***/ }), - return url + separator + names.map(name => { - if (name === "q") { - return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+"); - } +/***/ 3682: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - return `${name}=${encodeURIComponent(parameters[name])}`; - }).join("&"); -} +var register = __nccwpck_require__(4670); +var addHook = __nccwpck_require__(5549); +var removeHook = __nccwpck_require__(6819); -const urlVariableRegex = /\{[^}]+\}/g; +// bind with array of arguments: https://stackoverflow.com/a/21792913 +var bind = Function.bind; +var bindable = bind.bind(bind); -function removeNonChars(variableName) { - return variableName.replace(/^\W+|\W+$/g, "").split(/,/); +function bindApi(hook, state, name) { + var removeHookRef = bindable(removeHook, null).apply( + null, + name ? [state, name] : [state] + ); + hook.api = { remove: removeHookRef }; + hook.remove = removeHookRef; + ["before", "error", "after", "wrap"].forEach(function (kind) { + var args = name ? [state, kind, name] : [state, kind]; + hook[kind] = hook.api[kind] = bindable(addHook, null).apply(null, args); + }); } -function extractUrlVariableNames(url) { - const matches = url.match(urlVariableRegex); - - if (!matches) { - return []; - } - - return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []); +function HookSingular() { + var singularHookName = "h"; + var singularHookState = { + registry: {}, + }; + var singularHook = register.bind(null, singularHookState, singularHookName); + bindApi(singularHook, singularHookState, singularHookName); + return singularHook; } -function omit(object, keysToOmit) { - return Object.keys(object).filter(option => !keysToOmit.includes(option)).reduce((obj, key) => { - obj[key] = object[key]; - return obj; - }, {}); -} +function HookCollection() { + var state = { + registry: {}, + }; -// Based on https://github.com/bramstein/url-template, licensed under BSD -// TODO: create separate package. -// -// Copyright (c) 2012-2014, Bram Stein -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. 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. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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. - -/* istanbul ignore file */ -function encodeReserved(str) { - return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) { - if (!/%[0-9A-Fa-f]/.test(part)) { - part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]"); - } + var hook = register.bind(null, state); + bindApi(hook, state); - return part; - }).join(""); + return hook; } -function encodeUnreserved(str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { - return "%" + c.charCodeAt(0).toString(16).toUpperCase(); - }); +var collectionHookDeprecationMessageDisplayed = false; +function Hook() { + if (!collectionHookDeprecationMessageDisplayed) { + console.warn( + '[before-after-hook]: "Hook()" repurposing warning, use "Hook.Collection()". Read more: https://git.io/upgrade-before-after-hook-to-1.4' + ); + collectionHookDeprecationMessageDisplayed = true; + } + return HookCollection(); } -function encodeValue(operator, value, key) { - value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value); +Hook.Singular = HookSingular.bind(); +Hook.Collection = HookCollection.bind(); - if (key) { - return encodeUnreserved(key) + "=" + value; - } else { - return value; - } -} +module.exports = Hook; +// expose constructors as a named property for TypeScript +module.exports.Hook = Hook; +module.exports.Singular = Hook.Singular; +module.exports.Collection = Hook.Collection; -function isDefined(value) { - return value !== undefined && value !== null; -} -function isKeyOperator(operator) { - return operator === ";" || operator === "&" || operator === "?"; -} +/***/ }), -function getValues(context, operator, key, modifier) { - var value = context[key], - result = []; +/***/ 5549: +/***/ ((module) => { - if (isDefined(value) && value !== "") { - if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { - value = value.toString(); +module.exports = addHook; - if (modifier && modifier !== "*") { - value = value.substring(0, parseInt(modifier, 10)); - } +function addHook(state, kind, name, hook) { + var orig = hook; + if (!state.registry[name]) { + state.registry[name] = []; + } - result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); - } else { - if (modifier === "*") { - if (Array.isArray(value)) { - value.filter(isDefined).forEach(function (value) { - result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); - }); - } else { - Object.keys(value).forEach(function (k) { - if (isDefined(value[k])) { - result.push(encodeValue(operator, value[k], k)); - } - }); - } - } else { - const tmp = []; + if (kind === "before") { + hook = function (method, options) { + return Promise.resolve() + .then(orig.bind(null, options)) + .then(method.bind(null, options)); + }; + } - if (Array.isArray(value)) { - value.filter(isDefined).forEach(function (value) { - tmp.push(encodeValue(operator, value)); - }); - } else { - Object.keys(value).forEach(function (k) { - if (isDefined(value[k])) { - tmp.push(encodeUnreserved(k)); - tmp.push(encodeValue(operator, value[k].toString())); - } - }); - } + if (kind === "after") { + hook = function (method, options) { + var result; + return Promise.resolve() + .then(method.bind(null, options)) + .then(function (result_) { + result = result_; + return orig(result, options); + }) + .then(function () { + return result; + }); + }; + } - if (isKeyOperator(operator)) { - result.push(encodeUnreserved(key) + "=" + tmp.join(",")); - } else if (tmp.length !== 0) { - result.push(tmp.join(",")); - } - } - } - } else { - if (operator === ";") { - if (isDefined(value)) { - result.push(encodeUnreserved(key)); - } - } else if (value === "" && (operator === "&" || operator === "?")) { - result.push(encodeUnreserved(key) + "="); - } else if (value === "") { - result.push(""); - } + if (kind === "error") { + hook = function (method, options) { + return Promise.resolve() + .then(method.bind(null, options)) + .catch(function (error) { + return orig(error, options); + }); + }; } - return result; + state.registry[name].push({ + hook: hook, + orig: orig, + }); } -function parseUrl(template) { - return { - expand: expand.bind(null, template) - }; -} -function expand(template, context) { - var operators = ["+", "#", ".", "/", ";", "?", "&"]; - return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) { - if (expression) { - let operator = ""; - const values = []; +/***/ }), - if (operators.indexOf(expression.charAt(0)) !== -1) { - operator = expression.charAt(0); - expression = expression.substr(1); - } +/***/ 4670: +/***/ ((module) => { - expression.split(/,/g).forEach(function (variable) { - var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); - values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3])); - }); +module.exports = register; - if (operator && operator !== "+") { - var separator = ","; +function register(state, name, method, options) { + if (typeof method !== "function") { + throw new Error("method for before hook must be a function"); + } - if (operator === "?") { - separator = "&"; - } else if (operator !== "#") { - separator = operator; - } + if (!options) { + options = {}; + } - return (values.length !== 0 ? operator : "") + values.join(separator); - } else { - return values.join(","); - } - } else { - return encodeReserved(literal); + if (Array.isArray(name)) { + return name.reverse().reduce(function (callback, name) { + return register.bind(null, state, name, callback, options); + }, method)(); + } + + return Promise.resolve().then(function () { + if (!state.registry[name]) { + return method(options); } + + return state.registry[name].reduce(function (method, registered) { + return registered.hook.bind(null, method, options); + }, method)(); }); } -function parse(options) { - // https://fetch.spec.whatwg.org/#methods - let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible - let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}"); - let headers = Object.assign({}, options.headers); - let body; - let parameters = omit(options, ["method", "baseUrl", "url", "headers", "request", "mediaType"]); // extract variable names from URL to calculate remaining variables later +/***/ }), - const urlVariableNames = extractUrlVariableNames(url); - url = parseUrl(url).expand(parameters); +/***/ 6819: +/***/ ((module) => { - if (!/^http/.test(url)) { - url = options.baseUrl + url; - } +module.exports = removeHook; - const omittedParameters = Object.keys(options).filter(option => urlVariableNames.includes(option)).concat("baseUrl"); - const remainingParameters = omit(parameters, omittedParameters); - const isBinaryRequest = /application\/octet-stream/i.test(headers.accept); +function removeHook(state, name, method) { + if (!state.registry[name]) { + return; + } - if (!isBinaryRequest) { - if (options.mediaType.format) { - // e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw - headers.accept = headers.accept.split(/,/).map(preview => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)).join(","); - } + var index = state.registry[name] + .map(function (registered) { + return registered.orig; + }) + .indexOf(method); - if (options.mediaType.previews.length) { - const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || []; - headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map(preview => { - const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json"; - return `application/vnd.github.${preview}-preview${format}`; - }).join(","); - } - } // for GET/HEAD requests, set URL query parameters from remaining parameters - // for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters + if (index === -1) { + return; + } + state.registry[name].splice(index, 1); +} - if (["GET", "HEAD"].includes(method)) { - url = addQueryParameters(url, remainingParameters); - } else { - if ("data" in remainingParameters) { - body = remainingParameters.data; - } else { - if (Object.keys(remainingParameters).length) { - body = remainingParameters; - } else { - headers["content-length"] = 0; - } - } - } // default content-type for JSON if body is set +/***/ }), - if (!headers["content-type"] && typeof body !== "undefined") { - headers["content-type"] = "application/json; charset=utf-8"; - } // GitHub expects 'content-length: 0' header for PUT/PATCH requests without body. - // fetch does not allow to set `content-length` header, but we can set body to an empty string +/***/ 3717: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +var balanced = __nccwpck_require__(9417); - if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") { - body = ""; - } // Only return body/request keys if present +module.exports = expandTop; +var escSlash = '\0SLASH'+Math.random()+'\0'; +var escOpen = '\0OPEN'+Math.random()+'\0'; +var escClose = '\0CLOSE'+Math.random()+'\0'; +var escComma = '\0COMMA'+Math.random()+'\0'; +var escPeriod = '\0PERIOD'+Math.random()+'\0'; - return Object.assign({ - method, - url, - headers - }, typeof body !== "undefined" ? { - body - } : null, options.request ? { - request: options.request - } : null); +function numeric(str) { + return parseInt(str, 10) == str + ? parseInt(str, 10) + : str.charCodeAt(0); } -function endpointWithDefaults(defaults, route, options) { - return parse(merge(defaults, route, options)); +function escapeBraces(str) { + return str.split('\\\\').join(escSlash) + .split('\\{').join(escOpen) + .split('\\}').join(escClose) + .split('\\,').join(escComma) + .split('\\.').join(escPeriod); } -function withDefaults(oldDefaults, newDefaults) { - const DEFAULTS = merge(oldDefaults, newDefaults); - const endpoint = endpointWithDefaults.bind(null, DEFAULTS); - return Object.assign(endpoint, { - DEFAULTS, - defaults: withDefaults.bind(null, DEFAULTS), - merge: merge.bind(null, DEFAULTS), - parse - }); +function unescapeBraces(str) { + return str.split(escSlash).join('\\') + .split(escOpen).join('{') + .split(escClose).join('}') + .split(escComma).join(',') + .split(escPeriod).join('.'); } -const VERSION = "6.0.10"; -const userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}`; // DEFAULTS has all properties set that EndpointOptions has, except url. -// So we use RequestParameters and add method as additional required property. +// Basically just str.split(","), but handling cases +// where we have nested braced sections, which should be +// treated as individual members, like {a,{b,c},d} +function parseCommaParts(str) { + if (!str) + return ['']; -const DEFAULTS = { - method: "GET", - baseUrl: "https://api.github.com", - headers: { - accept: "application/vnd.github.v3+json", - "user-agent": userAgent - }, - mediaType: { - format: "", - previews: [] - } -}; + var parts = []; + var m = balanced('{', '}', str); -const endpoint = withDefaults(null, DEFAULTS); + if (!m) + return str.split(','); -exports.endpoint = endpoint; -//# sourceMappingURL=index.js.map + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); + p[p.length-1] += '{' + body + '}'; + var postParts = parseCommaParts(post); + if (post.length) { + p[p.length-1] += postParts.shift(); + p.push.apply(p, postParts); + } -/***/ }), + parts.push.apply(parts, p); -/***/ 558: -/***/ ((__unused_webpack_module, exports) => { + return parts; +} -"use strict"; +function expandTop(str) { + if (!str) + return []; + // I don't know why Bash 4.3 does this, but it does. + // Anything starting with {} will have the first two bytes preserved + // but *only* at the top level, so {},a}b will not expand to anything, + // but a{},b}c will be expanded to [a}c,abc]. + // One could argue that this is a bug in Bash, but since the goal of + // this module is to match Bash's rules, we escape a leading {} + if (str.substr(0, 2) === '{}') { + str = '\\{\\}' + str.substr(2); + } -Object.defineProperty(exports, "__esModule", ({ value: true })); + return expand(escapeBraces(str), true).map(unescapeBraces); +} -/*! - * is-plain-object - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ +function embrace(str) { + return '{' + str + '}'; +} +function isPadded(el) { + return /^-?0\d/.test(el); +} -function isObject(o) { - return Object.prototype.toString.call(o) === '[object Object]'; +function lte(i, y) { + return i <= y; +} +function gte(i, y) { + return i >= y; } -function isPlainObject(o) { - var ctor,prot; +function expand(str, isTop) { + var expansions = []; - if (isObject(o) === false) return false; + var m = balanced('{', '}', str); + if (!m) return [str]; - // If has modified constructor - ctor = o.constructor; - if (ctor === undefined) return true; + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre; + var post = m.post.length + ? expand(m.post, false) + : ['']; + + if (/\$$/.test(m.pre)) { + for (var k = 0; k < post.length; k++) { + var expansion = pre+ '{' + m.body + '}' + post[k]; + expansions.push(expansion); + } + } else { + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); + var isSequence = isNumericSequence || isAlphaSequence; + var isOptions = m.body.indexOf(',') >= 0; + if (!isSequence && !isOptions) { + // {a},b} + if (m.post.match(/,.*\}/)) { + str = m.pre + '{' + m.body + escClose + m.post; + return expand(str); + } + return [str]; + } + + var n; + if (isSequence) { + n = m.body.split(/\.\./); + } else { + n = parseCommaParts(m.body); + if (n.length === 1) { + // x{{a,b}}y ==> x{a}y x{b}y + n = expand(n[0], false).map(embrace); + if (n.length === 1) { + return post.map(function(p) { + return m.pre + n[0] + p; + }); + } + } + } - // If has modified prototype - prot = ctor.prototype; - if (isObject(prot) === false) return false; + // at this point, n is the parts, and we know it's not a comma set + // with a single entry. + var N; - // If constructor does not have an Object-specific method - if (prot.hasOwnProperty('isPrototypeOf') === false) { - return false; + if (isSequence) { + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length) + var incr = n.length == 3 + ? Math.abs(numeric(n[2])) + : 1; + var test = lte; + var reverse = y < x; + if (reverse) { + incr *= -1; + test = gte; + } + var pad = n.some(isPadded); + + N = []; + + for (var i = x; test(i, y); i += incr) { + var c; + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') + c = ''; + } else { + c = String(i); + if (pad) { + var need = width - c.length; + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) + c = '-' + z + c.slice(1); + else + c = z + c; + } + } + } + N.push(c); + } + } else { + N = []; + + for (var j = 0; j < n.length; j++) { + N.push.apply(N, expand(n[j], false)); + } + } + + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + var expansion = pre + N[j] + post[k]; + if (!isTop || isSequence || expansion) + expansions.push(expansion); + } + } } - // Most likely a plain Object - return true; + return expansions; } -exports.isPlainObject = isPlainObject; /***/ }), -/***/ 8467: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 8932: +/***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -var request = __nccwpck_require__(6234); -var universalUserAgent = __nccwpck_require__(5030); - -const VERSION = "4.5.8"; - -class GraphqlError extends Error { - constructor(request, response) { - const message = response.data.errors[0].message; - super(message); - Object.assign(this, response.data); - Object.assign(this, { - headers: response.headers - }); - this.name = "GraphqlError"; - this.request = request; // Maintains proper stack trace (only available on V8) +class Deprecation extends Error { + constructor(message) { + super(message); // Maintains proper stack trace (only available on V8) /* istanbul ignore next */ if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } - } - -} - -const NON_VARIABLE_OPTIONS = ["method", "baseUrl", "url", "headers", "request", "query", "mediaType"]; -const GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/; -function graphql(request, query, options) { - if (typeof query === "string" && options && "query" in options) { - return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`)); - } - - const parsedOptions = typeof query === "string" ? Object.assign({ - query - }, options) : query; - const requestOptions = Object.keys(parsedOptions).reduce((result, key) => { - if (NON_VARIABLE_OPTIONS.includes(key)) { - result[key] = parsedOptions[key]; - return result; - } - - if (!result.variables) { - result.variables = {}; - } - - result.variables[key] = parsedOptions[key]; - return result; - }, {}); // workaround for GitHub Enterprise baseUrl set with /api/v3 suffix - // https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451 - const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl; - - if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) { - requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql"); + this.name = 'Deprecation'; } - return request(requestOptions).then(response => { - if (response.data.errors) { - const headers = {}; +} - for (const key of Object.keys(response.headers)) { - headers[key] = response.headers[key]; - } +exports.Deprecation = Deprecation; - throw new GraphqlError(requestOptions, { - headers, - data: response.data - }); - } - return response.data.data; - }); -} +/***/ }), -function withDefaults(request$1, newDefaults) { - const newRequest = request$1.defaults(newDefaults); +/***/ 4766: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - const newApi = (query, options) => { - return graphql(newRequest, query, options); - }; +"use strict"; - return Object.assign(newApi, { - defaults: withDefaults.bind(null, newRequest), - endpoint: request.request.endpoint - }); +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getApplicativeComposition = exports.getApplicativeMonoid = void 0; +/** + * The `Applicative` type class extends the `Apply` type class with a `of` function, which can be used to create values + * of type `f a` from values of type `a`. + * + * Where `Apply` provides the ability to lift functions of two or more arguments to functions whose arguments are + * wrapped using `f`, and `Functor` provides the ability to lift functions of one argument, `pure` can be seen as the + * function which lifts functions of _zero_ arguments. That is, `Applicative` functors support a lifting operation for + * any number of function arguments. + * + * Instances must satisfy the following laws in addition to the `Apply` laws: + * + * 1. Identity: `A.ap(A.of(a => a), fa) <-> fa` + * 2. Homomorphism: `A.ap(A.of(ab), A.of(a)) <-> A.of(ab(a))` + * 3. Interchange: `A.ap(fab, A.of(a)) <-> A.ap(A.of(ab => ab(a)), fab)` + * + * Note. `Functor`'s `map` can be derived: `A.map(x, f) = A.ap(A.of(f), x)` + * + * @since 2.0.0 + */ +var Apply_1 = __nccwpck_require__(205); +var function_1 = __nccwpck_require__(6985); +var Functor_1 = __nccwpck_require__(5533); +function getApplicativeMonoid(F) { + var f = (0, Apply_1.getApplySemigroup)(F); + return function (M) { return ({ + concat: f(M).concat, + empty: F.of(M.empty) + }); }; } - -const graphql$1 = withDefaults(request.request, { - headers: { - "user-agent": `octokit-graphql.js/${VERSION} ${universalUserAgent.getUserAgent()}` - }, - method: "POST", - url: "/graphql" -}); -function withCustomRequest(customRequest) { - return withDefaults(customRequest, { - method: "POST", - url: "/graphql" - }); +exports.getApplicativeMonoid = getApplicativeMonoid; +/** @deprecated */ +function getApplicativeComposition(F, G) { + var map = (0, Functor_1.getFunctorComposition)(F, G).map; + var _ap = (0, Apply_1.ap)(F, G); + return { + map: map, + of: function (a) { return F.of(G.of(a)); }, + ap: function (fgab, fga) { return (0, function_1.pipe)(fgab, _ap(fga)); } + }; } - -exports.graphql = graphql$1; -exports.withCustomRequest = withCustomRequest; -//# sourceMappingURL=index.js.map +exports.getApplicativeComposition = getApplicativeComposition; /***/ }), -/***/ 4193: -/***/ ((__unused_webpack_module, exports) => { +/***/ 205: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); - -const VERSION = "2.7.0"; - +exports.sequenceS = exports.sequenceT = exports.getApplySemigroup = exports.apS = exports.apSecond = exports.apFirst = exports.ap = void 0; /** - * Some “list” response that can be paginated have a different response structure + * The `Apply` class provides the `ap` which is used to apply a function to an argument under a type constructor. + * + * `Apply` can be used to lift functions of two or more arguments to work on values wrapped with the type constructor + * `f`. + * + * Instances must satisfy the following law in addition to the `Functor` laws: + * + * 1. Associative composition: `F.ap(F.ap(F.map(fbc, bc => ab => a => bc(ab(a))), fab), fa) <-> F.ap(fbc, F.ap(fab, fa))` + * + * Formally, `Apply` represents a strong lax semi-monoidal endofunctor. + * + * @example + * import * as O from 'fp-ts/Option' + * import { pipe } from 'fp-ts/function' * - * They have a `total_count` key in the response (search also has `incomplete_results`, - * /installation/repositories also has `repository_selection`), as well as a key with - * the list of the items which name varies from endpoint to endpoint. + * const f = (a: string) => (b: number) => (c: boolean) => a + String(b) + String(c) + * const fa: O.Option = O.some('s') + * const fb: O.Option = O.some(1) + * const fc: O.Option = O.some(true) * - * Octokit normalizes these responses so that paginated results are always returned following - * the same structure. One challenge is that if the list response has only one page, no Link - * header is provided, so this header alone is not sufficient to check wether a response is - * paginated or not. + * assert.deepStrictEqual( + * pipe( + * // lift a function + * O.some(f), + * // apply the first argument + * O.ap(fa), + * // apply the second argument + * O.ap(fb), + * // apply the third argument + * O.ap(fc) + * ), + * O.some('s1true') + * ) * - * We check if a "total_count" key is present in the response data, but also make sure that - * a "url" property is not, as the "Get the combined status for a specific ref" endpoint would - * otherwise match: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref + * @since 2.0.0 */ -function normalizePaginatedListResponse(response) { - const responseNeedsNormalization = "total_count" in response.data && !("url" in response.data); - if (!responseNeedsNormalization) return response; // keep the additional properties intact as there is currently no other way - // to retrieve the same information. - - const incompleteResults = response.data.incomplete_results; - const repositorySelection = response.data.repository_selection; - const totalCount = response.data.total_count; - delete response.data.incomplete_results; - delete response.data.repository_selection; - delete response.data.total_count; - const namespaceKey = Object.keys(response.data)[0]; - const data = response.data[namespaceKey]; - response.data = data; - - if (typeof incompleteResults !== "undefined") { - response.data.incomplete_results = incompleteResults; - } - - if (typeof repositorySelection !== "undefined") { - response.data.repository_selection = repositorySelection; - } - - response.data.total_count = totalCount; - return response; +var function_1 = __nccwpck_require__(6985); +var _ = __importStar(__nccwpck_require__(1840)); +function ap(F, G) { + return function (fa) { + return function (fab) { + return F.ap(F.map(fab, function (gab) { return function (ga) { return G.ap(gab, ga); }; }), fa); + }; + }; } - -function iterator(octokit, route, parameters) { - const options = typeof route === "function" ? route.endpoint(parameters) : octokit.request.endpoint(route, parameters); - const requestMethod = typeof route === "function" ? route : octokit.request; - const method = options.method; - const headers = options.headers; - let url = options.url; - return { - [Symbol.asyncIterator]: () => ({ - async next() { - if (!url) return { - done: true +exports.ap = ap; +function apFirst(A) { + return function (second) { return function (first) { + return A.ap(A.map(first, function (a) { return function () { return a; }; }), second); + }; }; +} +exports.apFirst = apFirst; +function apSecond(A) { + return function (second) { + return function (first) { + return A.ap(A.map(first, function () { return function (b) { return b; }; }), second); }; - const response = await requestMethod({ - method, - url, - headers - }); - const normalizedResponse = normalizePaginatedListResponse(response); // `response.headers.link` format: - // '; rel="next", ; rel="last"' - // sets `url` to undefined if "next" URL is not present or `link` header is not set - - url = ((normalizedResponse.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1]; - return { - value: normalizedResponse + }; +} +exports.apSecond = apSecond; +function apS(F) { + return function (name, fb) { + return function (fa) { + return F.ap(F.map(fa, function (a) { return function (b) { + var _a; + return Object.assign({}, a, (_a = {}, _a[name] = b, _a)); + }; }), fb); }; - } - - }) - }; + }; } - -function paginate(octokit, route, parameters, mapFn) { - if (typeof parameters === "function") { - mapFn = parameters; - parameters = undefined; - } - - return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn); +exports.apS = apS; +function getApplySemigroup(F) { + return function (S) { return ({ + concat: function (first, second) { + return F.ap(F.map(first, function (x) { return function (y) { return S.concat(x, y); }; }), second); + } + }); }; } - -function gather(octokit, results, iterator, mapFn) { - return iterator.next().then(result => { - if (result.done) { - return results; - } - - let earlyExit = false; - - function done() { - earlyExit = true; +exports.getApplySemigroup = getApplySemigroup; +function curried(f, n, acc) { + return function (x) { + var combined = Array(acc.length + 1); + for (var i = 0; i < acc.length; i++) { + combined[i] = acc[i]; + } + combined[acc.length] = x; + return n === 0 ? f.apply(null, combined) : curried(f, n - 1, combined); + }; +} +var tupleConstructors = { + 1: function (a) { return [a]; }, + 2: function (a) { return function (b) { return [a, b]; }; }, + 3: function (a) { return function (b) { return function (c) { return [a, b, c]; }; }; }, + 4: function (a) { return function (b) { return function (c) { return function (d) { return [a, b, c, d]; }; }; }; }, + 5: function (a) { return function (b) { return function (c) { return function (d) { return function (e) { return [a, b, c, d, e]; }; }; }; }; } +}; +function getTupleConstructor(len) { + if (!_.has.call(tupleConstructors, len)) { + tupleConstructors[len] = curried(function_1.tuple, len - 1, []); } - - results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data); - - if (earlyExit) { - return results; + return tupleConstructors[len]; +} +function sequenceT(F) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var len = args.length; + var f = getTupleConstructor(len); + var fas = F.map(args[0], f); + for (var i = 1; i < len; i++) { + fas = F.ap(fas, args[i]); + } + return fas; + }; +} +exports.sequenceT = sequenceT; +function getRecordConstructor(keys) { + var len = keys.length; + switch (len) { + case 1: + return function (a) { + var _a; + return (_a = {}, _a[keys[0]] = a, _a); + }; + case 2: + return function (a) { return function (b) { + var _a; + return (_a = {}, _a[keys[0]] = a, _a[keys[1]] = b, _a); + }; }; + case 3: + return function (a) { return function (b) { return function (c) { + var _a; + return (_a = {}, _a[keys[0]] = a, _a[keys[1]] = b, _a[keys[2]] = c, _a); + }; }; }; + case 4: + return function (a) { return function (b) { return function (c) { return function (d) { + var _a; + return (_a = {}, + _a[keys[0]] = a, + _a[keys[1]] = b, + _a[keys[2]] = c, + _a[keys[3]] = d, + _a); + }; }; }; }; + case 5: + return function (a) { return function (b) { return function (c) { return function (d) { return function (e) { + var _a; + return (_a = {}, + _a[keys[0]] = a, + _a[keys[1]] = b, + _a[keys[2]] = c, + _a[keys[3]] = d, + _a[keys[4]] = e, + _a); + }; }; }; }; }; + default: + return curried(function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var r = {}; + for (var i = 0; i < len; i++) { + r[keys[i]] = args[i]; + } + return r; + }, len - 1, []); } - - return gather(octokit, results, iterator, mapFn); - }); } - -const composePaginateRest = Object.assign(paginate, { - iterator -}); - -/** - * @param octokit Octokit instance - * @param options Options passed to Octokit constructor - */ - -function paginateRest(octokit) { - return { - paginate: Object.assign(paginate.bind(null, octokit), { - iterator: iterator.bind(null, octokit) - }) - }; +function sequenceS(F) { + return function (r) { + var keys = Object.keys(r); + var len = keys.length; + var f = getRecordConstructor(keys); + var fr = F.map(r[keys[0]], f); + for (var i = 1; i < len; i++) { + fr = F.ap(fr, r[keys[i]]); + } + return fr; + }; } -paginateRest.VERSION = VERSION; - -exports.composePaginateRest = composePaginateRest; -exports.paginateRest = paginateRest; -//# sourceMappingURL=index.js.map +exports.sequenceS = sequenceS; /***/ }), -/***/ 3044: -/***/ ((__unused_webpack_module, exports) => { +/***/ 3834: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); - -const Endpoints = { - actions: { - addSelectedRepoToOrgSecret: ["PUT /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}"], - cancelWorkflowRun: ["POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel"], - createOrUpdateOrgSecret: ["PUT /orgs/{org}/actions/secrets/{secret_name}"], - createOrUpdateRepoSecret: ["PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}"], - createRegistrationTokenForOrg: ["POST /orgs/{org}/actions/runners/registration-token"], - createRegistrationTokenForRepo: ["POST /repos/{owner}/{repo}/actions/runners/registration-token"], - createRemoveTokenForOrg: ["POST /orgs/{org}/actions/runners/remove-token"], - createRemoveTokenForRepo: ["POST /repos/{owner}/{repo}/actions/runners/remove-token"], - createWorkflowDispatch: ["POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches"], - deleteArtifact: ["DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id}"], - deleteOrgSecret: ["DELETE /orgs/{org}/actions/secrets/{secret_name}"], - deleteRepoSecret: ["DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name}"], - deleteSelfHostedRunnerFromOrg: ["DELETE /orgs/{org}/actions/runners/{runner_id}"], - deleteSelfHostedRunnerFromRepo: ["DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}"], - deleteWorkflowRun: ["DELETE /repos/{owner}/{repo}/actions/runs/{run_id}"], - deleteWorkflowRunLogs: ["DELETE /repos/{owner}/{repo}/actions/runs/{run_id}/logs"], - disableSelectedRepositoryGithubActionsOrganization: ["DELETE /orgs/{org}/actions/permissions/repositories/{repository_id}"], - disableWorkflow: ["PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable"], - downloadArtifact: ["GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}"], - downloadJobLogsForWorkflowRun: ["GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs"], - downloadWorkflowRunLogs: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs"], - enableSelectedRepositoryGithubActionsOrganization: ["PUT /orgs/{org}/actions/permissions/repositories/{repository_id}"], - enableWorkflow: ["PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable"], - getAllowedActionsOrganization: ["GET /orgs/{org}/actions/permissions/selected-actions"], - getAllowedActionsRepository: ["GET /repos/{owner}/{repo}/actions/permissions/selected-actions"], - getArtifact: ["GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}"], - getGithubActionsPermissionsOrganization: ["GET /orgs/{org}/actions/permissions"], - getGithubActionsPermissionsRepository: ["GET /repos/{owner}/{repo}/actions/permissions"], - getJobForWorkflowRun: ["GET /repos/{owner}/{repo}/actions/jobs/{job_id}"], - getOrgPublicKey: ["GET /orgs/{org}/actions/secrets/public-key"], - getOrgSecret: ["GET /orgs/{org}/actions/secrets/{secret_name}"], - getRepoPermissions: ["GET /repos/{owner}/{repo}/actions/permissions", {}, { - renamed: ["actions", "getGithubActionsPermissionsRepository"] - }], - getRepoPublicKey: ["GET /repos/{owner}/{repo}/actions/secrets/public-key"], - getRepoSecret: ["GET /repos/{owner}/{repo}/actions/secrets/{secret_name}"], - getSelfHostedRunnerForOrg: ["GET /orgs/{org}/actions/runners/{runner_id}"], - getSelfHostedRunnerForRepo: ["GET /repos/{owner}/{repo}/actions/runners/{runner_id}"], - getWorkflow: ["GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}"], - getWorkflowRun: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}"], - getWorkflowRunUsage: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing"], - getWorkflowUsage: ["GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing"], - listArtifactsForRepo: ["GET /repos/{owner}/{repo}/actions/artifacts"], - listJobsForWorkflowRun: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs"], - listOrgSecrets: ["GET /orgs/{org}/actions/secrets"], - listRepoSecrets: ["GET /repos/{owner}/{repo}/actions/secrets"], - listRepoWorkflows: ["GET /repos/{owner}/{repo}/actions/workflows"], - listRunnerApplicationsForOrg: ["GET /orgs/{org}/actions/runners/downloads"], - listRunnerApplicationsForRepo: ["GET /repos/{owner}/{repo}/actions/runners/downloads"], - listSelectedReposForOrgSecret: ["GET /orgs/{org}/actions/secrets/{secret_name}/repositories"], - listSelectedRepositoriesEnabledGithubActionsOrganization: ["GET /orgs/{org}/actions/permissions/repositories"], - listSelfHostedRunnersForOrg: ["GET /orgs/{org}/actions/runners"], - listSelfHostedRunnersForRepo: ["GET /repos/{owner}/{repo}/actions/runners"], - listWorkflowRunArtifacts: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts"], - listWorkflowRuns: ["GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs"], - listWorkflowRunsForRepo: ["GET /repos/{owner}/{repo}/actions/runs"], - reRunWorkflow: ["POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun"], - removeSelectedRepoFromOrgSecret: ["DELETE /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}"], - setAllowedActionsOrganization: ["PUT /orgs/{org}/actions/permissions/selected-actions"], - setAllowedActionsRepository: ["PUT /repos/{owner}/{repo}/actions/permissions/selected-actions"], - setGithubActionsPermissionsOrganization: ["PUT /orgs/{org}/actions/permissions"], - setGithubActionsPermissionsRepository: ["PUT /repos/{owner}/{repo}/actions/permissions"], - setSelectedReposForOrgSecret: ["PUT /orgs/{org}/actions/secrets/{secret_name}/repositories"], - setSelectedRepositoriesEnabledGithubActionsOrganization: ["PUT /orgs/{org}/actions/permissions/repositories"] - }, - activity: { - checkRepoIsStarredByAuthenticatedUser: ["GET /user/starred/{owner}/{repo}"], - deleteRepoSubscription: ["DELETE /repos/{owner}/{repo}/subscription"], - deleteThreadSubscription: ["DELETE /notifications/threads/{thread_id}/subscription"], - getFeeds: ["GET /feeds"], - getRepoSubscription: ["GET /repos/{owner}/{repo}/subscription"], - getThread: ["GET /notifications/threads/{thread_id}"], - getThreadSubscriptionForAuthenticatedUser: ["GET /notifications/threads/{thread_id}/subscription"], - listEventsForAuthenticatedUser: ["GET /users/{username}/events"], - listNotificationsForAuthenticatedUser: ["GET /notifications"], - listOrgEventsForAuthenticatedUser: ["GET /users/{username}/events/orgs/{org}"], - listPublicEvents: ["GET /events"], - listPublicEventsForRepoNetwork: ["GET /networks/{owner}/{repo}/events"], - listPublicEventsForUser: ["GET /users/{username}/events/public"], - listPublicOrgEvents: ["GET /orgs/{org}/events"], - listReceivedEventsForUser: ["GET /users/{username}/received_events"], - listReceivedPublicEventsForUser: ["GET /users/{username}/received_events/public"], - listRepoEvents: ["GET /repos/{owner}/{repo}/events"], - listRepoNotificationsForAuthenticatedUser: ["GET /repos/{owner}/{repo}/notifications"], - listReposStarredByAuthenticatedUser: ["GET /user/starred"], - listReposStarredByUser: ["GET /users/{username}/starred"], - listReposWatchedByUser: ["GET /users/{username}/subscriptions"], - listStargazersForRepo: ["GET /repos/{owner}/{repo}/stargazers"], - listWatchedReposForAuthenticatedUser: ["GET /user/subscriptions"], - listWatchersForRepo: ["GET /repos/{owner}/{repo}/subscribers"], - markNotificationsAsRead: ["PUT /notifications"], - markRepoNotificationsAsRead: ["PUT /repos/{owner}/{repo}/notifications"], - markThreadAsRead: ["PATCH /notifications/threads/{thread_id}"], - setRepoSubscription: ["PUT /repos/{owner}/{repo}/subscription"], - setThreadSubscription: ["PUT /notifications/threads/{thread_id}/subscription"], - starRepoForAuthenticatedUser: ["PUT /user/starred/{owner}/{repo}"], - unstarRepoForAuthenticatedUser: ["DELETE /user/starred/{owner}/{repo}"] - }, - apps: { - addRepoToInstallation: ["PUT /user/installations/{installation_id}/repositories/{repository_id}"], - checkToken: ["POST /applications/{client_id}/token"], - createContentAttachment: ["POST /content_references/{content_reference_id}/attachments", { - mediaType: { - previews: ["corsair"] - } - }], - createFromManifest: ["POST /app-manifests/{code}/conversions"], - createInstallationAccessToken: ["POST /app/installations/{installation_id}/access_tokens"], - deleteAuthorization: ["DELETE /applications/{client_id}/grant"], - deleteInstallation: ["DELETE /app/installations/{installation_id}"], - deleteToken: ["DELETE /applications/{client_id}/token"], - getAuthenticated: ["GET /app"], - getBySlug: ["GET /apps/{app_slug}"], - getInstallation: ["GET /app/installations/{installation_id}"], - getOrgInstallation: ["GET /orgs/{org}/installation"], - getRepoInstallation: ["GET /repos/{owner}/{repo}/installation"], - getSubscriptionPlanForAccount: ["GET /marketplace_listing/accounts/{account_id}"], - getSubscriptionPlanForAccountStubbed: ["GET /marketplace_listing/stubbed/accounts/{account_id}"], - getUserInstallation: ["GET /users/{username}/installation"], - getWebhookConfigForApp: ["GET /app/hook/config"], - listAccountsForPlan: ["GET /marketplace_listing/plans/{plan_id}/accounts"], - listAccountsForPlanStubbed: ["GET /marketplace_listing/stubbed/plans/{plan_id}/accounts"], - listInstallationReposForAuthenticatedUser: ["GET /user/installations/{installation_id}/repositories"], - listInstallations: ["GET /app/installations"], - listInstallationsForAuthenticatedUser: ["GET /user/installations"], - listPlans: ["GET /marketplace_listing/plans"], - listPlansStubbed: ["GET /marketplace_listing/stubbed/plans"], - listReposAccessibleToInstallation: ["GET /installation/repositories"], - listSubscriptionsForAuthenticatedUser: ["GET /user/marketplace_purchases"], - listSubscriptionsForAuthenticatedUserStubbed: ["GET /user/marketplace_purchases/stubbed"], - removeRepoFromInstallation: ["DELETE /user/installations/{installation_id}/repositories/{repository_id}"], - resetToken: ["PATCH /applications/{client_id}/token"], - revokeInstallationAccessToken: ["DELETE /installation/token"], - suspendInstallation: ["PUT /app/installations/{installation_id}/suspended"], - unsuspendInstallation: ["DELETE /app/installations/{installation_id}/suspended"], - updateWebhookConfigForApp: ["PATCH /app/hook/config"] - }, - billing: { - getGithubActionsBillingOrg: ["GET /orgs/{org}/settings/billing/actions"], - getGithubActionsBillingUser: ["GET /users/{username}/settings/billing/actions"], - getGithubPackagesBillingOrg: ["GET /orgs/{org}/settings/billing/packages"], - getGithubPackagesBillingUser: ["GET /users/{username}/settings/billing/packages"], - getSharedStorageBillingOrg: ["GET /orgs/{org}/settings/billing/shared-storage"], - getSharedStorageBillingUser: ["GET /users/{username}/settings/billing/shared-storage"] - }, - checks: { - create: ["POST /repos/{owner}/{repo}/check-runs"], - createSuite: ["POST /repos/{owner}/{repo}/check-suites"], - get: ["GET /repos/{owner}/{repo}/check-runs/{check_run_id}"], - getSuite: ["GET /repos/{owner}/{repo}/check-suites/{check_suite_id}"], - listAnnotations: ["GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations"], - listForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/check-runs"], - listForSuite: ["GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs"], - listSuitesForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/check-suites"], - rerequestSuite: ["POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest"], - setSuitesPreferences: ["PATCH /repos/{owner}/{repo}/check-suites/preferences"], - update: ["PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}"] - }, - codeScanning: { - getAlert: ["GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}", {}, { - renamedParameters: { - alert_id: "alert_number" - } - }], - listAlertsForRepo: ["GET /repos/{owner}/{repo}/code-scanning/alerts"], - listRecentAnalyses: ["GET /repos/{owner}/{repo}/code-scanning/analyses"], - updateAlert: ["PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}"], - uploadSarif: ["POST /repos/{owner}/{repo}/code-scanning/sarifs"] - }, - codesOfConduct: { - getAllCodesOfConduct: ["GET /codes_of_conduct", { - mediaType: { - previews: ["scarlet-witch"] - } - }], - getConductCode: ["GET /codes_of_conduct/{key}", { - mediaType: { - previews: ["scarlet-witch"] - } - }], - getForRepo: ["GET /repos/{owner}/{repo}/community/code_of_conduct", { - mediaType: { - previews: ["scarlet-witch"] - } - }] - }, - emojis: { - get: ["GET /emojis"] - }, - enterpriseAdmin: { - disableSelectedOrganizationGithubActionsEnterprise: ["DELETE /enterprises/{enterprise}/actions/permissions/organizations/{org_id}"], - enableSelectedOrganizationGithubActionsEnterprise: ["PUT /enterprises/{enterprise}/actions/permissions/organizations/{org_id}"], - getAllowedActionsEnterprise: ["GET /enterprises/{enterprise}/actions/permissions/selected-actions"], - getGithubActionsPermissionsEnterprise: ["GET /enterprises/{enterprise}/actions/permissions"], - listSelectedOrganizationsEnabledGithubActionsEnterprise: ["GET /enterprises/{enterprise}/actions/permissions/organizations"], - setAllowedActionsEnterprise: ["PUT /enterprises/{enterprise}/actions/permissions/selected-actions"], - setGithubActionsPermissionsEnterprise: ["PUT /enterprises/{enterprise}/actions/permissions"], - setSelectedOrganizationsEnabledGithubActionsEnterprise: ["PUT /enterprises/{enterprise}/actions/permissions/organizations"] - }, - gists: { - checkIsStarred: ["GET /gists/{gist_id}/star"], - create: ["POST /gists"], - createComment: ["POST /gists/{gist_id}/comments"], - delete: ["DELETE /gists/{gist_id}"], - deleteComment: ["DELETE /gists/{gist_id}/comments/{comment_id}"], - fork: ["POST /gists/{gist_id}/forks"], - get: ["GET /gists/{gist_id}"], - getComment: ["GET /gists/{gist_id}/comments/{comment_id}"], - getRevision: ["GET /gists/{gist_id}/{sha}"], - list: ["GET /gists"], - listComments: ["GET /gists/{gist_id}/comments"], - listCommits: ["GET /gists/{gist_id}/commits"], - listForUser: ["GET /users/{username}/gists"], - listForks: ["GET /gists/{gist_id}/forks"], - listPublic: ["GET /gists/public"], - listStarred: ["GET /gists/starred"], - star: ["PUT /gists/{gist_id}/star"], - unstar: ["DELETE /gists/{gist_id}/star"], - update: ["PATCH /gists/{gist_id}"], - updateComment: ["PATCH /gists/{gist_id}/comments/{comment_id}"] - }, - git: { - createBlob: ["POST /repos/{owner}/{repo}/git/blobs"], - createCommit: ["POST /repos/{owner}/{repo}/git/commits"], - createRef: ["POST /repos/{owner}/{repo}/git/refs"], - createTag: ["POST /repos/{owner}/{repo}/git/tags"], - createTree: ["POST /repos/{owner}/{repo}/git/trees"], - deleteRef: ["DELETE /repos/{owner}/{repo}/git/refs/{ref}"], - getBlob: ["GET /repos/{owner}/{repo}/git/blobs/{file_sha}"], - getCommit: ["GET /repos/{owner}/{repo}/git/commits/{commit_sha}"], - getRef: ["GET /repos/{owner}/{repo}/git/ref/{ref}"], - getTag: ["GET /repos/{owner}/{repo}/git/tags/{tag_sha}"], - getTree: ["GET /repos/{owner}/{repo}/git/trees/{tree_sha}"], - listMatchingRefs: ["GET /repos/{owner}/{repo}/git/matching-refs/{ref}"], - updateRef: ["PATCH /repos/{owner}/{repo}/git/refs/{ref}"] - }, - gitignore: { - getAllTemplates: ["GET /gitignore/templates"], - getTemplate: ["GET /gitignore/templates/{name}"] - }, - interactions: { - getRestrictionsForOrg: ["GET /orgs/{org}/interaction-limits"], - getRestrictionsForRepo: ["GET /repos/{owner}/{repo}/interaction-limits"], - getRestrictionsForYourPublicRepos: ["GET /user/interaction-limits"], - removeRestrictionsForOrg: ["DELETE /orgs/{org}/interaction-limits"], - removeRestrictionsForRepo: ["DELETE /repos/{owner}/{repo}/interaction-limits"], - removeRestrictionsForYourPublicRepos: ["DELETE /user/interaction-limits"], - setRestrictionsForOrg: ["PUT /orgs/{org}/interaction-limits"], - setRestrictionsForRepo: ["PUT /repos/{owner}/{repo}/interaction-limits"], - setRestrictionsForYourPublicRepos: ["PUT /user/interaction-limits"] - }, - issues: { - addAssignees: ["POST /repos/{owner}/{repo}/issues/{issue_number}/assignees"], - addLabels: ["POST /repos/{owner}/{repo}/issues/{issue_number}/labels"], - checkUserCanBeAssigned: ["GET /repos/{owner}/{repo}/assignees/{assignee}"], - create: ["POST /repos/{owner}/{repo}/issues"], - createComment: ["POST /repos/{owner}/{repo}/issues/{issue_number}/comments"], - createLabel: ["POST /repos/{owner}/{repo}/labels"], - createMilestone: ["POST /repos/{owner}/{repo}/milestones"], - deleteComment: ["DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}"], - deleteLabel: ["DELETE /repos/{owner}/{repo}/labels/{name}"], - deleteMilestone: ["DELETE /repos/{owner}/{repo}/milestones/{milestone_number}"], - get: ["GET /repos/{owner}/{repo}/issues/{issue_number}"], - getComment: ["GET /repos/{owner}/{repo}/issues/comments/{comment_id}"], - getEvent: ["GET /repos/{owner}/{repo}/issues/events/{event_id}"], - getLabel: ["GET /repos/{owner}/{repo}/labels/{name}"], - getMilestone: ["GET /repos/{owner}/{repo}/milestones/{milestone_number}"], - list: ["GET /issues"], - listAssignees: ["GET /repos/{owner}/{repo}/assignees"], - listComments: ["GET /repos/{owner}/{repo}/issues/{issue_number}/comments"], - listCommentsForRepo: ["GET /repos/{owner}/{repo}/issues/comments"], - listEvents: ["GET /repos/{owner}/{repo}/issues/{issue_number}/events"], - listEventsForRepo: ["GET /repos/{owner}/{repo}/issues/events"], - listEventsForTimeline: ["GET /repos/{owner}/{repo}/issues/{issue_number}/timeline", { - mediaType: { - previews: ["mockingbird"] - } - }], - listForAuthenticatedUser: ["GET /user/issues"], - listForOrg: ["GET /orgs/{org}/issues"], - listForRepo: ["GET /repos/{owner}/{repo}/issues"], - listLabelsForMilestone: ["GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels"], - listLabelsForRepo: ["GET /repos/{owner}/{repo}/labels"], - listLabelsOnIssue: ["GET /repos/{owner}/{repo}/issues/{issue_number}/labels"], - listMilestones: ["GET /repos/{owner}/{repo}/milestones"], - lock: ["PUT /repos/{owner}/{repo}/issues/{issue_number}/lock"], - removeAllLabels: ["DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels"], - removeAssignees: ["DELETE /repos/{owner}/{repo}/issues/{issue_number}/assignees"], - removeLabel: ["DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}"], - setLabels: ["PUT /repos/{owner}/{repo}/issues/{issue_number}/labels"], - unlock: ["DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock"], - update: ["PATCH /repos/{owner}/{repo}/issues/{issue_number}"], - updateComment: ["PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}"], - updateLabel: ["PATCH /repos/{owner}/{repo}/labels/{name}"], - updateMilestone: ["PATCH /repos/{owner}/{repo}/milestones/{milestone_number}"] - }, - licenses: { - get: ["GET /licenses/{license}"], - getAllCommonlyUsed: ["GET /licenses"], - getForRepo: ["GET /repos/{owner}/{repo}/license"] - }, - markdown: { - render: ["POST /markdown"], - renderRaw: ["POST /markdown/raw", { - headers: { - "content-type": "text/plain; charset=utf-8" - } - }] - }, - meta: { - get: ["GET /meta"], - getOctocat: ["GET /octocat"], - getZen: ["GET /zen"], - root: ["GET /"] - }, - migrations: { - cancelImport: ["DELETE /repos/{owner}/{repo}/import"], - deleteArchiveForAuthenticatedUser: ["DELETE /user/migrations/{migration_id}/archive", { - mediaType: { - previews: ["wyandotte"] - } - }], - deleteArchiveForOrg: ["DELETE /orgs/{org}/migrations/{migration_id}/archive", { - mediaType: { - previews: ["wyandotte"] - } - }], - downloadArchiveForOrg: ["GET /orgs/{org}/migrations/{migration_id}/archive", { - mediaType: { - previews: ["wyandotte"] - } - }], - getArchiveForAuthenticatedUser: ["GET /user/migrations/{migration_id}/archive", { - mediaType: { - previews: ["wyandotte"] - } - }], - getCommitAuthors: ["GET /repos/{owner}/{repo}/import/authors"], - getImportStatus: ["GET /repos/{owner}/{repo}/import"], - getLargeFiles: ["GET /repos/{owner}/{repo}/import/large_files"], - getStatusForAuthenticatedUser: ["GET /user/migrations/{migration_id}", { - mediaType: { - previews: ["wyandotte"] - } - }], - getStatusForOrg: ["GET /orgs/{org}/migrations/{migration_id}", { - mediaType: { - previews: ["wyandotte"] - } - }], - listForAuthenticatedUser: ["GET /user/migrations", { - mediaType: { - previews: ["wyandotte"] - } - }], - listForOrg: ["GET /orgs/{org}/migrations", { - mediaType: { - previews: ["wyandotte"] - } - }], - listReposForOrg: ["GET /orgs/{org}/migrations/{migration_id}/repositories", { - mediaType: { - previews: ["wyandotte"] - } - }], - listReposForUser: ["GET /user/migrations/{migration_id}/repositories", { - mediaType: { - previews: ["wyandotte"] - } - }], - mapCommitAuthor: ["PATCH /repos/{owner}/{repo}/import/authors/{author_id}"], - setLfsPreference: ["PATCH /repos/{owner}/{repo}/import/lfs"], - startForAuthenticatedUser: ["POST /user/migrations"], - startForOrg: ["POST /orgs/{org}/migrations"], - startImport: ["PUT /repos/{owner}/{repo}/import"], - unlockRepoForAuthenticatedUser: ["DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock", { - mediaType: { - previews: ["wyandotte"] - } - }], - unlockRepoForOrg: ["DELETE /orgs/{org}/migrations/{migration_id}/repos/{repo_name}/lock", { - mediaType: { - previews: ["wyandotte"] - } - }], - updateImport: ["PATCH /repos/{owner}/{repo}/import"] - }, - orgs: { - blockUser: ["PUT /orgs/{org}/blocks/{username}", { - mediaType: { - previews: ["giant-sentry-fist"] - } - }], - checkBlockedUser: ["GET /orgs/{org}/blocks/{username}", { - mediaType: { - previews: ["giant-sentry-fist"] - } - }], - checkMembershipForUser: ["GET /orgs/{org}/members/{username}"], - checkPublicMembershipForUser: ["GET /orgs/{org}/public_members/{username}"], - convertMemberToOutsideCollaborator: ["PUT /orgs/{org}/outside_collaborators/{username}"], - createInvitation: ["POST /orgs/{org}/invitations"], - createWebhook: ["POST /orgs/{org}/hooks"], - deleteWebhook: ["DELETE /orgs/{org}/hooks/{hook_id}"], - get: ["GET /orgs/{org}"], - getMembershipForAuthenticatedUser: ["GET /user/memberships/orgs/{org}"], - getMembershipForUser: ["GET /orgs/{org}/memberships/{username}"], - getWebhook: ["GET /orgs/{org}/hooks/{hook_id}"], - getWebhookConfigForOrg: ["GET /orgs/{org}/hooks/{hook_id}/config"], - list: ["GET /organizations"], - listAppInstallations: ["GET /orgs/{org}/installations"], - listBlockedUsers: ["GET /orgs/{org}/blocks", { - mediaType: { - previews: ["giant-sentry-fist"] - } - }], - listForAuthenticatedUser: ["GET /user/orgs"], - listForUser: ["GET /users/{username}/orgs"], - listInvitationTeams: ["GET /orgs/{org}/invitations/{invitation_id}/teams"], - listMembers: ["GET /orgs/{org}/members"], - listMembershipsForAuthenticatedUser: ["GET /user/memberships/orgs"], - listOutsideCollaborators: ["GET /orgs/{org}/outside_collaborators"], - listPendingInvitations: ["GET /orgs/{org}/invitations"], - listPublicMembers: ["GET /orgs/{org}/public_members"], - listWebhooks: ["GET /orgs/{org}/hooks"], - pingWebhook: ["POST /orgs/{org}/hooks/{hook_id}/pings"], - removeMember: ["DELETE /orgs/{org}/members/{username}"], - removeMembershipForUser: ["DELETE /orgs/{org}/memberships/{username}"], - removeOutsideCollaborator: ["DELETE /orgs/{org}/outside_collaborators/{username}"], - removePublicMembershipForAuthenticatedUser: ["DELETE /orgs/{org}/public_members/{username}"], - setMembershipForUser: ["PUT /orgs/{org}/memberships/{username}"], - setPublicMembershipForAuthenticatedUser: ["PUT /orgs/{org}/public_members/{username}"], - unblockUser: ["DELETE /orgs/{org}/blocks/{username}", { - mediaType: { - previews: ["giant-sentry-fist"] - } - }], - update: ["PATCH /orgs/{org}"], - updateMembershipForAuthenticatedUser: ["PATCH /user/memberships/orgs/{org}"], - updateWebhook: ["PATCH /orgs/{org}/hooks/{hook_id}"], - updateWebhookConfigForOrg: ["PATCH /orgs/{org}/hooks/{hook_id}/config"] - }, - projects: { - addCollaborator: ["PUT /projects/{project_id}/collaborators/{username}", { - mediaType: { - previews: ["inertia"] - } - }], - createCard: ["POST /projects/columns/{column_id}/cards", { - mediaType: { - previews: ["inertia"] - } - }], - createColumn: ["POST /projects/{project_id}/columns", { - mediaType: { - previews: ["inertia"] - } - }], - createForAuthenticatedUser: ["POST /user/projects", { - mediaType: { - previews: ["inertia"] - } - }], - createForOrg: ["POST /orgs/{org}/projects", { - mediaType: { - previews: ["inertia"] - } - }], - createForRepo: ["POST /repos/{owner}/{repo}/projects", { - mediaType: { - previews: ["inertia"] - } - }], - delete: ["DELETE /projects/{project_id}", { - mediaType: { - previews: ["inertia"] - } - }], - deleteCard: ["DELETE /projects/columns/cards/{card_id}", { - mediaType: { - previews: ["inertia"] - } - }], - deleteColumn: ["DELETE /projects/columns/{column_id}", { - mediaType: { - previews: ["inertia"] - } - }], - get: ["GET /projects/{project_id}", { - mediaType: { - previews: ["inertia"] - } - }], - getCard: ["GET /projects/columns/cards/{card_id}", { - mediaType: { - previews: ["inertia"] - } - }], - getColumn: ["GET /projects/columns/{column_id}", { - mediaType: { - previews: ["inertia"] - } - }], - getPermissionForUser: ["GET /projects/{project_id}/collaborators/{username}/permission", { - mediaType: { - previews: ["inertia"] - } - }], - listCards: ["GET /projects/columns/{column_id}/cards", { - mediaType: { - previews: ["inertia"] - } - }], - listCollaborators: ["GET /projects/{project_id}/collaborators", { - mediaType: { - previews: ["inertia"] - } - }], - listColumns: ["GET /projects/{project_id}/columns", { - mediaType: { - previews: ["inertia"] - } - }], - listForOrg: ["GET /orgs/{org}/projects", { - mediaType: { - previews: ["inertia"] - } - }], - listForRepo: ["GET /repos/{owner}/{repo}/projects", { - mediaType: { - previews: ["inertia"] - } - }], - listForUser: ["GET /users/{username}/projects", { - mediaType: { - previews: ["inertia"] - } - }], - moveCard: ["POST /projects/columns/cards/{card_id}/moves", { - mediaType: { - previews: ["inertia"] - } - }], - moveColumn: ["POST /projects/columns/{column_id}/moves", { - mediaType: { - previews: ["inertia"] - } - }], - removeCollaborator: ["DELETE /projects/{project_id}/collaborators/{username}", { - mediaType: { - previews: ["inertia"] - } - }], - update: ["PATCH /projects/{project_id}", { - mediaType: { - previews: ["inertia"] - } - }], - updateCard: ["PATCH /projects/columns/cards/{card_id}", { - mediaType: { - previews: ["inertia"] - } - }], - updateColumn: ["PATCH /projects/columns/{column_id}", { - mediaType: { - previews: ["inertia"] - } - }] - }, - pulls: { - checkIfMerged: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/merge"], - create: ["POST /repos/{owner}/{repo}/pulls"], - createReplyForReviewComment: ["POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies"], - createReview: ["POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews"], - createReviewComment: ["POST /repos/{owner}/{repo}/pulls/{pull_number}/comments"], - deletePendingReview: ["DELETE /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}"], - deleteReviewComment: ["DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}"], - dismissReview: ["PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals"], - get: ["GET /repos/{owner}/{repo}/pulls/{pull_number}"], - getReview: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}"], - getReviewComment: ["GET /repos/{owner}/{repo}/pulls/comments/{comment_id}"], - list: ["GET /repos/{owner}/{repo}/pulls"], - listCommentsForReview: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments"], - listCommits: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/commits"], - listFiles: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/files"], - listRequestedReviewers: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers"], - listReviewComments: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/comments"], - listReviewCommentsForRepo: ["GET /repos/{owner}/{repo}/pulls/comments"], - listReviews: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews"], - merge: ["PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge"], - removeRequestedReviewers: ["DELETE /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers"], - requestReviewers: ["POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers"], - submitReview: ["POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events"], - update: ["PATCH /repos/{owner}/{repo}/pulls/{pull_number}"], - updateBranch: ["PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch", { - mediaType: { - previews: ["lydian"] - } - }], - updateReview: ["PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}"], - updateReviewComment: ["PATCH /repos/{owner}/{repo}/pulls/comments/{comment_id}"] - }, - rateLimit: { - get: ["GET /rate_limit"] - }, - reactions: { - createForCommitComment: ["POST /repos/{owner}/{repo}/comments/{comment_id}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - createForIssue: ["POST /repos/{owner}/{repo}/issues/{issue_number}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - createForIssueComment: ["POST /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - createForPullRequestReviewComment: ["POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - createForTeamDiscussionCommentInOrg: ["POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - createForTeamDiscussionInOrg: ["POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - deleteForCommitComment: ["DELETE /repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id}", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - deleteForIssue: ["DELETE /repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id}", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - deleteForIssueComment: ["DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id}", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - deleteForPullRequestComment: ["DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id}", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - deleteForTeamDiscussion: ["DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions/{reaction_id}", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - deleteForTeamDiscussionComment: ["DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions/{reaction_id}", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - deleteLegacy: ["DELETE /reactions/{reaction_id}", { - mediaType: { - previews: ["squirrel-girl"] - } - }, { - deprecated: "octokit.reactions.deleteLegacy() is deprecated, see https://docs.github.com/v3/reactions/#delete-a-reaction-legacy" - }], - listForCommitComment: ["GET /repos/{owner}/{repo}/comments/{comment_id}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - listForIssue: ["GET /repos/{owner}/{repo}/issues/{issue_number}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - listForIssueComment: ["GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - listForPullRequestReviewComment: ["GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - listForTeamDiscussionCommentInOrg: ["GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }], - listForTeamDiscussionInOrg: ["GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions", { - mediaType: { - previews: ["squirrel-girl"] - } - }] - }, - repos: { - acceptInvitation: ["PATCH /user/repository_invitations/{invitation_id}"], - addAppAccessRestrictions: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", {}, { - mapToData: "apps" - }], - addCollaborator: ["PUT /repos/{owner}/{repo}/collaborators/{username}"], - addStatusCheckContexts: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", {}, { - mapToData: "contexts" - }], - addTeamAccessRestrictions: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", {}, { - mapToData: "teams" - }], - addUserAccessRestrictions: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", {}, { - mapToData: "users" - }], - checkCollaborator: ["GET /repos/{owner}/{repo}/collaborators/{username}"], - checkVulnerabilityAlerts: ["GET /repos/{owner}/{repo}/vulnerability-alerts", { - mediaType: { - previews: ["dorian"] - } - }], - compareCommits: ["GET /repos/{owner}/{repo}/compare/{base}...{head}"], - createCommitComment: ["POST /repos/{owner}/{repo}/commits/{commit_sha}/comments"], - createCommitSignatureProtection: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures", { - mediaType: { - previews: ["zzzax"] - } - }], - createCommitStatus: ["POST /repos/{owner}/{repo}/statuses/{sha}"], - createDeployKey: ["POST /repos/{owner}/{repo}/keys"], - createDeployment: ["POST /repos/{owner}/{repo}/deployments"], - createDeploymentStatus: ["POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses"], - createDispatchEvent: ["POST /repos/{owner}/{repo}/dispatches"], - createForAuthenticatedUser: ["POST /user/repos"], - createFork: ["POST /repos/{owner}/{repo}/forks"], - createInOrg: ["POST /orgs/{org}/repos"], - createOrUpdateFileContents: ["PUT /repos/{owner}/{repo}/contents/{path}"], - createPagesSite: ["POST /repos/{owner}/{repo}/pages", { - mediaType: { - previews: ["switcheroo"] - } - }], - createRelease: ["POST /repos/{owner}/{repo}/releases"], - createUsingTemplate: ["POST /repos/{template_owner}/{template_repo}/generate", { - mediaType: { - previews: ["baptiste"] - } - }], - createWebhook: ["POST /repos/{owner}/{repo}/hooks"], - declineInvitation: ["DELETE /user/repository_invitations/{invitation_id}"], - delete: ["DELETE /repos/{owner}/{repo}"], - deleteAccessRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions"], - deleteAdminBranchProtection: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins"], - deleteBranchProtection: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection"], - deleteCommitComment: ["DELETE /repos/{owner}/{repo}/comments/{comment_id}"], - deleteCommitSignatureProtection: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures", { - mediaType: { - previews: ["zzzax"] - } - }], - deleteDeployKey: ["DELETE /repos/{owner}/{repo}/keys/{key_id}"], - deleteDeployment: ["DELETE /repos/{owner}/{repo}/deployments/{deployment_id}"], - deleteFile: ["DELETE /repos/{owner}/{repo}/contents/{path}"], - deleteInvitation: ["DELETE /repos/{owner}/{repo}/invitations/{invitation_id}"], - deletePagesSite: ["DELETE /repos/{owner}/{repo}/pages", { - mediaType: { - previews: ["switcheroo"] - } - }], - deletePullRequestReviewProtection: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews"], - deleteRelease: ["DELETE /repos/{owner}/{repo}/releases/{release_id}"], - deleteReleaseAsset: ["DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}"], - deleteWebhook: ["DELETE /repos/{owner}/{repo}/hooks/{hook_id}"], - disableAutomatedSecurityFixes: ["DELETE /repos/{owner}/{repo}/automated-security-fixes", { - mediaType: { - previews: ["london"] - } - }], - disableVulnerabilityAlerts: ["DELETE /repos/{owner}/{repo}/vulnerability-alerts", { - mediaType: { - previews: ["dorian"] - } - }], - downloadArchive: ["GET /repos/{owner}/{repo}/zipball/{ref}", {}, { - renamed: ["repos", "downloadZipballArchive"] - }], - downloadTarballArchive: ["GET /repos/{owner}/{repo}/tarball/{ref}"], - downloadZipballArchive: ["GET /repos/{owner}/{repo}/zipball/{ref}"], - enableAutomatedSecurityFixes: ["PUT /repos/{owner}/{repo}/automated-security-fixes", { - mediaType: { - previews: ["london"] - } - }], - enableVulnerabilityAlerts: ["PUT /repos/{owner}/{repo}/vulnerability-alerts", { - mediaType: { - previews: ["dorian"] - } - }], - get: ["GET /repos/{owner}/{repo}"], - getAccessRestrictions: ["GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions"], - getAdminBranchProtection: ["GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins"], - getAllStatusCheckContexts: ["GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts"], - getAllTopics: ["GET /repos/{owner}/{repo}/topics", { - mediaType: { - previews: ["mercy"] - } - }], - getAppsWithAccessToProtectedBranch: ["GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps"], - getBranch: ["GET /repos/{owner}/{repo}/branches/{branch}"], - getBranchProtection: ["GET /repos/{owner}/{repo}/branches/{branch}/protection"], - getClones: ["GET /repos/{owner}/{repo}/traffic/clones"], - getCodeFrequencyStats: ["GET /repos/{owner}/{repo}/stats/code_frequency"], - getCollaboratorPermissionLevel: ["GET /repos/{owner}/{repo}/collaborators/{username}/permission"], - getCombinedStatusForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/status"], - getCommit: ["GET /repos/{owner}/{repo}/commits/{ref}"], - getCommitActivityStats: ["GET /repos/{owner}/{repo}/stats/commit_activity"], - getCommitComment: ["GET /repos/{owner}/{repo}/comments/{comment_id}"], - getCommitSignatureProtection: ["GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures", { - mediaType: { - previews: ["zzzax"] - } - }], - getCommunityProfileMetrics: ["GET /repos/{owner}/{repo}/community/profile"], - getContent: ["GET /repos/{owner}/{repo}/contents/{path}"], - getContributorsStats: ["GET /repos/{owner}/{repo}/stats/contributors"], - getDeployKey: ["GET /repos/{owner}/{repo}/keys/{key_id}"], - getDeployment: ["GET /repos/{owner}/{repo}/deployments/{deployment_id}"], - getDeploymentStatus: ["GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}"], - getLatestPagesBuild: ["GET /repos/{owner}/{repo}/pages/builds/latest"], - getLatestRelease: ["GET /repos/{owner}/{repo}/releases/latest"], - getPages: ["GET /repos/{owner}/{repo}/pages"], - getPagesBuild: ["GET /repos/{owner}/{repo}/pages/builds/{build_id}"], - getParticipationStats: ["GET /repos/{owner}/{repo}/stats/participation"], - getPullRequestReviewProtection: ["GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews"], - getPunchCardStats: ["GET /repos/{owner}/{repo}/stats/punch_card"], - getReadme: ["GET /repos/{owner}/{repo}/readme"], - getRelease: ["GET /repos/{owner}/{repo}/releases/{release_id}"], - getReleaseAsset: ["GET /repos/{owner}/{repo}/releases/assets/{asset_id}"], - getReleaseByTag: ["GET /repos/{owner}/{repo}/releases/tags/{tag}"], - getStatusChecksProtection: ["GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks"], - getTeamsWithAccessToProtectedBranch: ["GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams"], - getTopPaths: ["GET /repos/{owner}/{repo}/traffic/popular/paths"], - getTopReferrers: ["GET /repos/{owner}/{repo}/traffic/popular/referrers"], - getUsersWithAccessToProtectedBranch: ["GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users"], - getViews: ["GET /repos/{owner}/{repo}/traffic/views"], - getWebhook: ["GET /repos/{owner}/{repo}/hooks/{hook_id}"], - getWebhookConfigForRepo: ["GET /repos/{owner}/{repo}/hooks/{hook_id}/config"], - listBranches: ["GET /repos/{owner}/{repo}/branches"], - listBranchesForHeadCommit: ["GET /repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head", { - mediaType: { - previews: ["groot"] - } - }], - listCollaborators: ["GET /repos/{owner}/{repo}/collaborators"], - listCommentsForCommit: ["GET /repos/{owner}/{repo}/commits/{commit_sha}/comments"], - listCommitCommentsForRepo: ["GET /repos/{owner}/{repo}/comments"], - listCommitStatusesForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/statuses"], - listCommits: ["GET /repos/{owner}/{repo}/commits"], - listContributors: ["GET /repos/{owner}/{repo}/contributors"], - listDeployKeys: ["GET /repos/{owner}/{repo}/keys"], - listDeploymentStatuses: ["GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses"], - listDeployments: ["GET /repos/{owner}/{repo}/deployments"], - listForAuthenticatedUser: ["GET /user/repos"], - listForOrg: ["GET /orgs/{org}/repos"], - listForUser: ["GET /users/{username}/repos"], - listForks: ["GET /repos/{owner}/{repo}/forks"], - listInvitations: ["GET /repos/{owner}/{repo}/invitations"], - listInvitationsForAuthenticatedUser: ["GET /user/repository_invitations"], - listLanguages: ["GET /repos/{owner}/{repo}/languages"], - listPagesBuilds: ["GET /repos/{owner}/{repo}/pages/builds"], - listPublic: ["GET /repositories"], - listPullRequestsAssociatedWithCommit: ["GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls", { - mediaType: { - previews: ["groot"] - } - }], - listReleaseAssets: ["GET /repos/{owner}/{repo}/releases/{release_id}/assets"], - listReleases: ["GET /repos/{owner}/{repo}/releases"], - listTags: ["GET /repos/{owner}/{repo}/tags"], - listTeams: ["GET /repos/{owner}/{repo}/teams"], - listWebhooks: ["GET /repos/{owner}/{repo}/hooks"], - merge: ["POST /repos/{owner}/{repo}/merges"], - pingWebhook: ["POST /repos/{owner}/{repo}/hooks/{hook_id}/pings"], - removeAppAccessRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", {}, { - mapToData: "apps" - }], - removeCollaborator: ["DELETE /repos/{owner}/{repo}/collaborators/{username}"], - removeStatusCheckContexts: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", {}, { - mapToData: "contexts" - }], - removeStatusCheckProtection: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks"], - removeTeamAccessRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", {}, { - mapToData: "teams" - }], - removeUserAccessRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", {}, { - mapToData: "users" - }], - replaceAllTopics: ["PUT /repos/{owner}/{repo}/topics", { - mediaType: { - previews: ["mercy"] - } - }], - requestPagesBuild: ["POST /repos/{owner}/{repo}/pages/builds"], - setAdminBranchProtection: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins"], - setAppAccessRestrictions: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", {}, { - mapToData: "apps" - }], - setStatusCheckContexts: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", {}, { - mapToData: "contexts" - }], - setTeamAccessRestrictions: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", {}, { - mapToData: "teams" - }], - setUserAccessRestrictions: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", {}, { - mapToData: "users" - }], - testPushWebhook: ["POST /repos/{owner}/{repo}/hooks/{hook_id}/tests"], - transfer: ["POST /repos/{owner}/{repo}/transfer"], - update: ["PATCH /repos/{owner}/{repo}"], - updateBranchProtection: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection"], - updateCommitComment: ["PATCH /repos/{owner}/{repo}/comments/{comment_id}"], - updateInformationAboutPagesSite: ["PUT /repos/{owner}/{repo}/pages"], - updateInvitation: ["PATCH /repos/{owner}/{repo}/invitations/{invitation_id}"], - updatePullRequestReviewProtection: ["PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews"], - updateRelease: ["PATCH /repos/{owner}/{repo}/releases/{release_id}"], - updateReleaseAsset: ["PATCH /repos/{owner}/{repo}/releases/assets/{asset_id}"], - updateStatusCheckPotection: ["PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks", {}, { - renamed: ["repos", "updateStatusCheckProtection"] - }], - updateStatusCheckProtection: ["PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks"], - updateWebhook: ["PATCH /repos/{owner}/{repo}/hooks/{hook_id}"], - updateWebhookConfigForRepo: ["PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config"], - uploadReleaseAsset: ["POST /repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}", { - baseUrl: "https://uploads.github.com" - }] - }, - search: { - code: ["GET /search/code"], - commits: ["GET /search/commits", { - mediaType: { - previews: ["cloak"] - } - }], - issuesAndPullRequests: ["GET /search/issues"], - labels: ["GET /search/labels"], - repos: ["GET /search/repositories"], - topics: ["GET /search/topics", { - mediaType: { - previews: ["mercy"] - } - }], - users: ["GET /search/users"] - }, - secretScanning: { - getAlert: ["GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}"], - listAlertsForRepo: ["GET /repos/{owner}/{repo}/secret-scanning/alerts"], - updateAlert: ["PATCH /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}"] - }, - teams: { - addOrUpdateMembershipForUserInOrg: ["PUT /orgs/{org}/teams/{team_slug}/memberships/{username}"], - addOrUpdateProjectPermissionsInOrg: ["PUT /orgs/{org}/teams/{team_slug}/projects/{project_id}", { - mediaType: { - previews: ["inertia"] - } - }], - addOrUpdateRepoPermissionsInOrg: ["PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}"], - checkPermissionsForProjectInOrg: ["GET /orgs/{org}/teams/{team_slug}/projects/{project_id}", { - mediaType: { - previews: ["inertia"] - } - }], - checkPermissionsForRepoInOrg: ["GET /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}"], - create: ["POST /orgs/{org}/teams"], - createDiscussionCommentInOrg: ["POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments"], - createDiscussionInOrg: ["POST /orgs/{org}/teams/{team_slug}/discussions"], - deleteDiscussionCommentInOrg: ["DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}"], - deleteDiscussionInOrg: ["DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}"], - deleteInOrg: ["DELETE /orgs/{org}/teams/{team_slug}"], - getByName: ["GET /orgs/{org}/teams/{team_slug}"], - getDiscussionCommentInOrg: ["GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}"], - getDiscussionInOrg: ["GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}"], - getMembershipForUserInOrg: ["GET /orgs/{org}/teams/{team_slug}/memberships/{username}"], - list: ["GET /orgs/{org}/teams"], - listChildInOrg: ["GET /orgs/{org}/teams/{team_slug}/teams"], - listDiscussionCommentsInOrg: ["GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments"], - listDiscussionsInOrg: ["GET /orgs/{org}/teams/{team_slug}/discussions"], - listForAuthenticatedUser: ["GET /user/teams"], - listMembersInOrg: ["GET /orgs/{org}/teams/{team_slug}/members"], - listPendingInvitationsInOrg: ["GET /orgs/{org}/teams/{team_slug}/invitations"], - listProjectsInOrg: ["GET /orgs/{org}/teams/{team_slug}/projects", { - mediaType: { - previews: ["inertia"] - } - }], - listReposInOrg: ["GET /orgs/{org}/teams/{team_slug}/repos"], - removeMembershipForUserInOrg: ["DELETE /orgs/{org}/teams/{team_slug}/memberships/{username}"], - removeProjectInOrg: ["DELETE /orgs/{org}/teams/{team_slug}/projects/{project_id}"], - removeRepoInOrg: ["DELETE /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}"], - updateDiscussionCommentInOrg: ["PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}"], - updateDiscussionInOrg: ["PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}"], - updateInOrg: ["PATCH /orgs/{org}/teams/{team_slug}"] - }, - users: { - addEmailForAuthenticated: ["POST /user/emails"], - block: ["PUT /user/blocks/{username}", { - mediaType: { - previews: ["giant-sentry-fist"] - } - }], - checkBlocked: ["GET /user/blocks/{username}", { - mediaType: { - previews: ["giant-sentry-fist"] - } - }], - checkFollowingForUser: ["GET /users/{username}/following/{target_user}"], - checkPersonIsFollowedByAuthenticated: ["GET /user/following/{username}"], - createGpgKeyForAuthenticated: ["POST /user/gpg_keys"], - createPublicSshKeyForAuthenticated: ["POST /user/keys"], - deleteEmailForAuthenticated: ["DELETE /user/emails"], - deleteGpgKeyForAuthenticated: ["DELETE /user/gpg_keys/{gpg_key_id}"], - deletePublicSshKeyForAuthenticated: ["DELETE /user/keys/{key_id}"], - follow: ["PUT /user/following/{username}"], - getAuthenticated: ["GET /user"], - getByUsername: ["GET /users/{username}"], - getContextForUser: ["GET /users/{username}/hovercard"], - getGpgKeyForAuthenticated: ["GET /user/gpg_keys/{gpg_key_id}"], - getPublicSshKeyForAuthenticated: ["GET /user/keys/{key_id}"], - list: ["GET /users"], - listBlockedByAuthenticated: ["GET /user/blocks", { - mediaType: { - previews: ["giant-sentry-fist"] - } - }], - listEmailsForAuthenticated: ["GET /user/emails"], - listFollowedByAuthenticated: ["GET /user/following"], - listFollowersForAuthenticatedUser: ["GET /user/followers"], - listFollowersForUser: ["GET /users/{username}/followers"], - listFollowingForUser: ["GET /users/{username}/following"], - listGpgKeysForAuthenticated: ["GET /user/gpg_keys"], - listGpgKeysForUser: ["GET /users/{username}/gpg_keys"], - listPublicEmailsForAuthenticated: ["GET /user/public_emails"], - listPublicKeysForUser: ["GET /users/{username}/keys"], - listPublicSshKeysForAuthenticated: ["GET /user/keys"], - setPrimaryEmailVisibilityForAuthenticated: ["PATCH /user/email/visibility"], - unblock: ["DELETE /user/blocks/{username}", { - mediaType: { - previews: ["giant-sentry-fist"] - } - }], - unfollow: ["DELETE /user/following/{username}"], - updateAuthenticated: ["PATCH /user"] - } -}; - -const VERSION = "4.4.3"; - -function endpointsToMethods(octokit, endpointsMap) { - const newMethods = {}; - - for (const [scope, endpoints] of Object.entries(endpointsMap)) { - for (const [methodName, endpoint] of Object.entries(endpoints)) { - const [route, defaults, decorations] = endpoint; - const [method, url] = route.split(/ /); - const endpointDefaults = Object.assign({ - method, - url - }, defaults); - - if (!newMethods[scope]) { - newMethods[scope] = {}; - } - - const scopeMethods = newMethods[scope]; - - if (decorations) { - scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations); - continue; - } - - scopeMethods[methodName] = octokit.request.defaults(endpointDefaults); - } - } - - return newMethods; -} - -function decorate(octokit, scope, methodName, defaults, decorations) { - const requestWithDefaults = octokit.request.defaults(defaults); - /* istanbul ignore next */ - - function withDecorations(...args) { - // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488 - let options = requestWithDefaults.endpoint.merge(...args); // There are currently no other decorations than `.mapToData` - - if (decorations.mapToData) { - options = Object.assign({}, options, { - data: options[decorations.mapToData], - [decorations.mapToData]: undefined - }); - return requestWithDefaults(options); - } - - if (decorations.renamed) { - const [newScope, newMethodName] = decorations.renamed; - octokit.log.warn(`octokit.${scope}.${methodName}() has been renamed to octokit.${newScope}.${newMethodName}()`); - } - - if (decorations.deprecated) { - octokit.log.warn(decorations.deprecated); - } - - if (decorations.renamedParameters) { - // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488 - const options = requestWithDefaults.endpoint.merge(...args); - - for (const [name, alias] of Object.entries(decorations.renamedParameters)) { - if (name in options) { - octokit.log.warn(`"${name}" parameter is deprecated for "octokit.${scope}.${methodName}()". Use "${alias}" instead`); - - if (!(alias in options)) { - options[alias] = options[name]; - } - - delete options[name]; - } - } - - return requestWithDefaults(options); - } // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488 - - - return requestWithDefaults(...args); - } - - return Object.assign(withDecorations, requestWithDefaults); -} - +exports.lefts = exports.rights = exports.reverse = exports.modifyAt = exports.deleteAt = exports.updateAt = exports.insertAt = exports.copy = exports.findLastIndex = exports.findLastMap = exports.findLast = exports.findFirstMap = exports.findFirst = exports.findIndex = exports.dropLeftWhile = exports.dropRight = exports.dropLeft = exports.spanLeft = exports.takeLeftWhile = exports.takeRight = exports.takeLeft = exports.init = exports.tail = exports.last = exports.head = exports.lookup = exports.isOutOfBound = exports.size = exports.scanRight = exports.scanLeft = exports.chainWithIndex = exports.foldRight = exports.matchRight = exports.matchRightW = exports.foldLeft = exports.matchLeft = exports.matchLeftW = exports.match = exports.matchW = exports.fromEither = exports.fromOption = exports.fromPredicate = exports.replicate = exports.makeBy = exports.appendW = exports.append = exports.prependW = exports.prepend = exports.isNonEmpty = exports.isEmpty = void 0; +exports.traverseWithIndex = exports.sequence = exports.traverse = exports.reduceRightWithIndex = exports.reduceRight = exports.reduceWithIndex = exports.reduce = exports.foldMapWithIndex = exports.foldMap = exports.duplicate = exports.extend = exports.filterWithIndex = exports.alt = exports.altW = exports.partitionMapWithIndex = exports.partitionMap = exports.partitionWithIndex = exports.partition = exports.filter = exports.separate = exports.compact = exports.filterMap = exports.filterMapWithIndex = exports.mapWithIndex = exports.flatten = exports.flatMap = exports.ap = exports.map = exports.zero = exports.of = exports.difference = exports.intersection = exports.union = exports.concat = exports.concatW = exports.comprehension = exports.fromOptionK = exports.chunksOf = exports.splitAt = exports.chop = exports.sortBy = exports.uniq = exports.elem = exports.rotate = exports.intersperse = exports.prependAll = exports.unzip = exports.zip = exports.zipWith = exports.sort = void 0; +exports.some = exports.every = exports.unsafeDeleteAt = exports.unsafeUpdateAt = exports.unsafeInsertAt = exports.fromEitherK = exports.FromEither = exports.filterE = exports.ChainRecBreadthFirst = exports.chainRecBreadthFirst = exports.ChainRecDepthFirst = exports.chainRecDepthFirst = exports.Witherable = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.FilterableWithIndex = exports.Filterable = exports.Compactable = exports.Extend = exports.Alternative = exports.guard = exports.Zero = exports.Alt = exports.Unfoldable = exports.Monad = exports.chainFirst = exports.Chain = exports.Applicative = exports.apSecond = exports.apFirst = exports.Apply = exports.FunctorWithIndex = exports.Pointed = exports.flap = exports.Functor = exports.getDifferenceMagma = exports.getIntersectionSemigroup = exports.getUnionMonoid = exports.getUnionSemigroup = exports.getOrd = exports.getEq = exports.getMonoid = exports.getSemigroup = exports.getShow = exports.URI = exports.unfold = exports.wilt = exports.wither = void 0; +exports.array = exports.prependToAll = exports.snoc = exports.cons = exports.empty = exports.range = exports.chain = exports.apS = exports.bind = exports["let"] = exports.bindTo = exports.Do = exports.intercalate = exports.exists = void 0; +var Apply_1 = __nccwpck_require__(205); +var Chain_1 = __nccwpck_require__(2372); +var FromEither_1 = __nccwpck_require__(1964); +var function_1 = __nccwpck_require__(6985); +var Functor_1 = __nccwpck_require__(5533); +var _ = __importStar(__nccwpck_require__(1840)); +var NEA = __importStar(__nccwpck_require__(240)); +var RA = __importStar(__nccwpck_require__(4234)); +var Separated_1 = __nccwpck_require__(5877); +var Witherable_1 = __nccwpck_require__(4384); +var Zero_1 = __nccwpck_require__(9734); +// ------------------------------------------------------------------------------------- +// refinements +// ------------------------------------------------------------------------------------- +/** + * Test whether an array is empty + * + * @example + * import { isEmpty } from 'fp-ts/Array' + * + * assert.strictEqual(isEmpty([]), true) + * assert.strictEqual(isEmpty(['a']), false) + * + * @category refinements + * @since 2.0.0 + */ +var isEmpty = function (as) { return as.length === 0; }; +exports.isEmpty = isEmpty; /** - * This plugin is a 1:1 copy of internal @octokit/rest plugins. The primary - * goal is to rebuild @octokit/rest on top of @octokit/core. Once that is - * done, we will remove the registerEndpoints methods and return the methods - * directly as with the other plugins. At that point we will also remove the - * legacy workarounds and deprecations. + * Test whether an array is non empty narrowing down the type to `NonEmptyArray` + * + * @example + * import { isNonEmpty } from 'fp-ts/Array' * - * See the plan at - * https://github.com/octokit/plugin-rest-endpoint-methods.js/pull/1 + * assert.strictEqual(isNonEmpty([]), false) + * assert.strictEqual(isNonEmpty(['a']), true) + * + * @category refinements + * @since 2.0.0 */ - -function restEndpointMethods(octokit) { - return endpointsToMethods(octokit, Endpoints); +exports.isNonEmpty = NEA.isNonEmpty; +// ------------------------------------------------------------------------------------- +// constructors +// ------------------------------------------------------------------------------------- +/** + * Prepend an element to the front of a `Array`, creating a new `NonEmptyArray`. + * + * @example + * import { prepend } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe([2, 3, 4], prepend(1)), [1, 2, 3, 4]) + * + * @since 2.10.0 + */ +exports.prepend = NEA.prepend; +/** + * Less strict version of [`prepend`](#prepend). + * + * @example + * import { prependW } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe([2, 3, 4], prependW("a")), ["a", 2, 3, 4]); + * + * @since 2.11.0 + */ +exports.prependW = NEA.prependW; +/** + * Append an element to the end of a `Array`, creating a new `NonEmptyArray`. + * + * @example + * import { append } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe([1, 2, 3], append(4)), [1, 2, 3, 4]) + * + * @since 2.10.0 + */ +exports.append = NEA.append; +/** + * Less strict version of [`append`](#append). + * + * @example + * import { appendW } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe([1, 2, 3], appendW("d")), [1, 2, 3, "d"]); + * + * @since 2.11.0 + */ +exports.appendW = NEA.appendW; +/** + * Return a `Array` of length `n` with element `i` initialized with `f(i)`. + * + * **Note**. `n` is normalized to a non negative integer. + * + * @example + * import { makeBy } from 'fp-ts/Array' + * + * const double = (i: number): number => i * 2 + * assert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8]) + * assert.deepStrictEqual(makeBy(-3, double), []) + * assert.deepStrictEqual(makeBy(4.32164, double), [0, 2, 4, 6]) + * + * @category constructors + * @since 2.0.0 + */ +var makeBy = function (n, f) { return (n <= 0 ? [] : NEA.makeBy(f)(n)); }; +exports.makeBy = makeBy; +/** + * Create a `Array` containing a value repeated the specified number of times. + * + * **Note**. `n` is normalized to a non negative integer. + * + * @example + * import { replicate } from 'fp-ts/Array' + * + * assert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a']) + * assert.deepStrictEqual(replicate(-3, 'a'), []) + * assert.deepStrictEqual(replicate(2.985647, 'a'), ['a', 'a']) + * + * @category constructors + * @since 2.0.0 + */ +var replicate = function (n, a) { return (0, exports.makeBy)(n, function () { return a; }); }; +exports.replicate = replicate; +function fromPredicate(predicate) { + return function (a) { return (predicate(a) ? [a] : []); }; } -restEndpointMethods.VERSION = VERSION; - -exports.restEndpointMethods = restEndpointMethods; -//# sourceMappingURL=index.js.map - - -/***/ }), - -/***/ 537: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); - -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } - -var deprecation = __nccwpck_require__(8932); -var once = _interopDefault(__nccwpck_require__(1223)); - -const logOnce = once(deprecation => console.warn(deprecation)); +exports.fromPredicate = fromPredicate; +// ------------------------------------------------------------------------------------- +// conversions +// ------------------------------------------------------------------------------------- /** - * Error with extra properties to help with debugging + * Create an array from an `Option`. The resulting array will contain the content of the + * `Option` if it is `Some` and it will be empty if the `Option` is `None`. + * + * @example + * import { fromOption } from 'fp-ts/Array' + * import { option } from "fp-ts"; + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe(option.some("a"), fromOption),["a"]) + * assert.deepStrictEqual(pipe(option.none, fromOption),[]) + * + * @category conversions + * @since 2.11.0 */ - -class RequestError extends Error { - constructor(message, statusCode, options) { - super(message); // Maintains proper stack trace (only available on V8) - - /* istanbul ignore next */ - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } - - this.name = "HttpError"; - this.status = statusCode; - Object.defineProperty(this, "code", { - get() { - logOnce(new deprecation.Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`.")); - return statusCode; - } - - }); - this.headers = options.headers || {}; // redact request credentials without mutating original request options - - const requestCopy = Object.assign({}, options.request); - - if (options.request.headers.authorization) { - requestCopy.headers = Object.assign({}, options.request.headers, { - authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]") - }); - } - - requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit - // see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications - .replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]") // OAuth tokens can be passed as URL query parameters, although it is not recommended - // see https://developer.github.com/v3/#oauth2-token-sent-in-a-header - .replace(/\baccess_token=\w+/g, "access_token=[REDACTED]"); - this.request = requestCopy; - } - -} - -exports.RequestError = RequestError; -//# sourceMappingURL=index.js.map - - -/***/ }), - -/***/ 6234: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); - -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } - -var endpoint = __nccwpck_require__(9440); -var universalUserAgent = __nccwpck_require__(5030); -var isPlainObject = __nccwpck_require__(9062); -var nodeFetch = _interopDefault(__nccwpck_require__(467)); -var requestError = __nccwpck_require__(537); - -const VERSION = "5.4.12"; - -function getBufferResponse(response) { - return response.arrayBuffer(); -} - -function fetchWrapper(requestOptions) { - if (isPlainObject.isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) { - requestOptions.body = JSON.stringify(requestOptions.body); - } - - let headers = {}; - let status; - let url; - const fetch = requestOptions.request && requestOptions.request.fetch || nodeFetch; - return fetch(requestOptions.url, Object.assign({ - method: requestOptions.method, - body: requestOptions.body, - headers: requestOptions.headers, - redirect: requestOptions.redirect - }, requestOptions.request)).then(response => { - url = response.url; - status = response.status; - - for (const keyAndValue of response.headers) { - headers[keyAndValue[0]] = keyAndValue[1]; - } - - if (status === 204 || status === 205) { - return; - } // GitHub API returns 200 for HEAD requests - - - if (requestOptions.method === "HEAD") { - if (status < 400) { - return; - } - - throw new requestError.RequestError(response.statusText, status, { - headers, - request: requestOptions - }); - } - - if (status === 304) { - throw new requestError.RequestError("Not modified", status, { - headers, - request: requestOptions - }); - } - - if (status >= 400) { - return response.text().then(message => { - const error = new requestError.RequestError(message, status, { - headers, - request: requestOptions - }); - - try { - let responseBody = JSON.parse(error.message); - Object.assign(error, responseBody); - let errors = responseBody.errors; // Assumption `errors` would always be in Array format - - error.message = error.message + ": " + errors.map(JSON.stringify).join(", "); - } catch (e) {// ignore, see octokit/rest.js#684 +var fromOption = function (ma) { return (_.isNone(ma) ? [] : [ma.value]); }; +exports.fromOption = fromOption; +/** + * Create an array from an `Either`. The resulting array will contain the content of the + * `Either` if it is `Right` and it will be empty if the `Either` is `Left`. + * + * @example + * import { fromEither } from 'fp-ts/Array' + * import { either } from "fp-ts"; + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe(either.right("r"), fromEither), ["r"]); + * assert.deepStrictEqual(pipe(either.left("l"), fromEither), []); + * + * @category conversions + * @since 2.11.0 + */ +var fromEither = function (e) { return (_.isLeft(e) ? [] : [e.right]); }; +exports.fromEither = fromEither; +/** + * Less strict version of [`match`](#match). + * + * The `W` suffix (short for **W**idening) means that the handler return types will be merged. + * + * @example + * import { matchW } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * + * const matcherW = matchW( + * () => "No elements", + * (as) => as.length + * ); + * assert.deepStrictEqual(pipe([1, 2, 3, 4], matcherW), 4); + * assert.deepStrictEqual(pipe([], matcherW), "No elements"); + * + * @category pattern matching + * @since 2.11.0 + */ +var matchW = function (onEmpty, onNonEmpty) { + return function (as) { + return (0, exports.isNonEmpty)(as) ? onNonEmpty(as) : onEmpty(); + }; +}; +exports.matchW = matchW; +/** + * Takes an array, if the array is empty it returns the result of `onEmpty`, otherwise + * it passes the array to `onNonEmpty` and returns the result. + * + * @example + * import { match } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * + * const matcher = match( + * () => "No elements", + * (as) => `Found ${as.length} element(s)` + * ); + * assert.deepStrictEqual(pipe([1, 2, 3, 4], matcher), "Found 4 element(s)"); + * assert.deepStrictEqual(pipe([], matcher), "No elements"); + * + * @category pattern matching + * @since 2.11.0 + */ +exports.match = exports.matchW; +/** + * Less strict version of [`matchLeft`](#matchleft). It will work when `onEmpty` and + * `onNonEmpty` have different return types. + * + * @example + * import { matchLeftW } from 'fp-ts/Array' + * + * const f = matchLeftW( + * () => 0, + * (head: string, tail: string[]) => `Found "${head}" followed by ${tail.length} elements` + * ); + * assert.strictEqual(f(["a", "b", "c"]), 'Found "a" followed by 2 elements'); + * assert.strictEqual(f([]), 0); + * + * @category pattern matching + * @since 2.11.0 + */ +var matchLeftW = function (onEmpty, onNonEmpty) { + return function (as) { + return (0, exports.isNonEmpty)(as) ? onNonEmpty(NEA.head(as), NEA.tail(as)) : onEmpty(); + }; +}; +exports.matchLeftW = matchLeftW; +/** + * Takes an array, if the array is empty it returns the result of `onEmpty`, otherwise + * it passes the array to `onNonEmpty` broken into its first element and remaining elements. + * + * @example + * import { matchLeft } from 'fp-ts/Array' + * + * const len: (as: Array) => number = matchLeft(() => 0, (_, tail) => 1 + len(tail)) + * assert.strictEqual(len([1, 2, 3]), 3) + * + * @category pattern matching + * @since 2.10.0 + */ +exports.matchLeft = exports.matchLeftW; +/** + * Alias of [`matchLeft`](#matchleft). + * + * @category pattern matching + * @since 2.0.0 + */ +exports.foldLeft = exports.matchLeft; +/** + * Less strict version of [`matchRight`](#matchright). It will work when `onEmpty` and + * `onNonEmpty` have different return types. + * + * @example + * import { matchRightW } from 'fp-ts/Array' + * + * const f = matchRightW( + * () => 0, + * (head: string[], tail: string) => `Found ${head.length} elements folllowed by "${tail}"` + * ); + * assert.strictEqual(f(["a", "b", "c"]), 'Found 2 elements folllowed by "c"'); + * assert.strictEqual(f([]), 0); + * + * @category pattern matching + * @since 2.11.0 + */ +var matchRightW = function (onEmpty, onNonEmpty) { + return function (as) { + return (0, exports.isNonEmpty)(as) ? onNonEmpty(NEA.init(as), NEA.last(as)) : onEmpty(); + }; +}; +exports.matchRightW = matchRightW; +/** + * Takes an array, if the array is empty it returns the result of `onEmpty`, otherwise + * it passes the array to `onNonEmpty` broken into its initial elements and the last element. + * + * @example + * import { matchRight } from 'fp-ts/Array' + * + * const len: (as: Array) => number = matchRight( + * () => 0, + * (head, _) => 1 + len(head) + * ); + * assert.strictEqual(len([1, 2, 3]), 3); + * + * @category pattern matching + * @since 2.10.0 + */ +exports.matchRight = exports.matchRightW; +/** + * Alias of [`matchRight`](#matchright). + * + * @category pattern matching + * @since 2.0.0 + */ +exports.foldRight = exports.matchRight; +// ------------------------------------------------------------------------------------- +// combinators +// ------------------------------------------------------------------------------------- +/** + * Same as [`chain`](#chain), but passing also the index to the iterating function. + * + * @example + * import { chainWithIndex, replicate } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * + * const f = (index: number, x: string) => replicate(2, `${x}${index}`); + * assert.deepStrictEqual(pipe(["a", "b", "c"], chainWithIndex(f)), ["a0", "a0", "b1", "b1", "c2", "c2"]); + * + * @category sequencing + * @since 2.7.0 + */ +var chainWithIndex = function (f) { + return function (as) { + var out = []; + for (var i = 0; i < as.length; i++) { + out.push.apply(out, f(i, as[i])); } - - throw error; - }); - } - - const contentType = response.headers.get("content-type"); - - if (/application\/json/.test(contentType)) { - return response.json(); - } - - if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) { - return response.text(); - } - - return getBufferResponse(response); - }).then(data => { - return { - status, - url, - headers, - data + return out; }; - }).catch(error => { - if (error instanceof requestError.RequestError) { - throw error; - } - - throw new requestError.RequestError(error.message, 500, { - headers, - request: requestOptions - }); - }); -} - -function withDefaults(oldEndpoint, newDefaults) { - const endpoint = oldEndpoint.defaults(newDefaults); - - const newApi = function (route, parameters) { - const endpointOptions = endpoint.merge(route, parameters); - - if (!endpointOptions.request || !endpointOptions.request.hook) { - return fetchWrapper(endpoint.parse(endpointOptions)); - } - - const request = (route, parameters) => { - return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters))); +}; +exports.chainWithIndex = chainWithIndex; +/** + * Same as `reduce` but it carries over the intermediate steps + * + * @example + * import { scanLeft } from 'fp-ts/Array' + * + * assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4]) + * + * @since 2.0.0 + */ +var scanLeft = function (b, f) { + return function (as) { + var len = as.length; + var out = new Array(len + 1); + out[0] = b; + for (var i = 0; i < len; i++) { + out[i + 1] = f(out[i], as[i]); + } + return out; }; - - Object.assign(request, { - endpoint, - defaults: withDefaults.bind(null, endpoint) - }); - return endpointOptions.request.hook(request, endpointOptions); - }; - - return Object.assign(newApi, { - endpoint, - defaults: withDefaults.bind(null, endpoint) - }); -} - -const request = withDefaults(endpoint.endpoint, { - headers: { - "user-agent": `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}` - } -}); - -exports.request = request; -//# sourceMappingURL=index.js.map - - -/***/ }), - -/***/ 9062: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); - -/*! - * is-plain-object +}; +exports.scanLeft = scanLeft; +/** + * Fold an array from the right, keeping all intermediate results instead of only the final result + * + * @example + * import { scanRight } from 'fp-ts/Array' + * + * assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10]) * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. + * @since 2.0.0 */ - -function isObject(o) { - return Object.prototype.toString.call(o) === '[object Object]'; -} - -function isPlainObject(o) { - var ctor,prot; - - if (isObject(o) === false) return false; - - // If has modified constructor - ctor = o.constructor; - if (ctor === undefined) return true; - - // If has modified prototype - prot = ctor.prototype; - if (isObject(prot) === false) return false; - - // If constructor does not have an Object-specific method - if (prot.hasOwnProperty('isPrototypeOf') === false) { - return false; - } - - // Most likely a plain Object - return true; -} - -exports.isPlainObject = isPlainObject; - - -/***/ }), - -/***/ 9417: -/***/ ((module) => { - -"use strict"; - -module.exports = balanced; -function balanced(a, b, str) { - if (a instanceof RegExp) a = maybeMatch(a, str); - if (b instanceof RegExp) b = maybeMatch(b, str); - - var r = range(a, b, str); - - return r && { - start: r[0], - end: r[1], - pre: str.slice(0, r[0]), - body: str.slice(r[0] + a.length, r[1]), - post: str.slice(r[1] + b.length) - }; -} - -function maybeMatch(reg, str) { - var m = str.match(reg); - return m ? m[0] : null; +var scanRight = function (b, f) { + return function (as) { + var len = as.length; + var out = new Array(len + 1); + out[len] = b; + for (var i = len - 1; i >= 0; i--) { + out[i] = f(as[i], out[i + 1]); + } + return out; + }; +}; +exports.scanRight = scanRight; +/** + * Calculate the number of elements in a `Array`. + * + * @example + * import { size } from 'fp-ts/Array' + * + * assert.strictEqual(size(["a","b","c"]),3) + * + * @since 2.10.0 + */ +var size = function (as) { return as.length; }; +exports.size = size; +/** + * Test whether an array contains a particular index + * + * @example + * import { isOutOfBound } from 'fp-ts/Array' + * + * assert.strictEqual(isOutOfBound(1,["a","b","c"]),false) + * assert.strictEqual(isOutOfBound(-1,["a","b","c"]),true) + * assert.strictEqual(isOutOfBound(3,["a","b","c"]),true) + * + * @since 2.0.0 + */ +exports.isOutOfBound = NEA.isOutOfBound; +// TODO: remove non-curried overloading in v3 +/** + * This function provides a safe way to read a value at a particular index from an array. + * It returns a `none` if the index is out of bounds, and a `some` of the element if the + * index is valid. + * + * @example + * import { lookup } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2)) + * assert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none) + * + * @since 2.0.0 + */ +exports.lookup = RA.lookup; +/** + * Get the first element in an array, or `None` if the array is empty + * + * @example + * import { head } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' + * + * assert.deepStrictEqual(head([1, 2, 3]), some(1)) + * assert.deepStrictEqual(head([]), none) + * + * @since 2.0.0 + */ +exports.head = RA.head; +/** + * Get the last element in an array, or `None` if the array is empty + * + * @example + * import { last } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' + * + * assert.deepStrictEqual(last([1, 2, 3]), some(3)) + * assert.deepStrictEqual(last([]), none) + * + * @since 2.0.0 + */ +exports.last = RA.last; +/** + * Get all but the first element of an array, creating a new array, or `None` if the array is empty + * + * @example + * import { tail } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' + * + * assert.deepStrictEqual(tail([1, 2, 3]), some([2, 3])) + * assert.deepStrictEqual(tail([]), none) + * + * @since 2.0.0 + */ +var tail = function (as) { return ((0, exports.isNonEmpty)(as) ? _.some(NEA.tail(as)) : _.none); }; +exports.tail = tail; +/** + * Get all but the last element of an array, creating a new array, or `None` if the array is empty + * + * @example + * import { init } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' + * + * assert.deepStrictEqual(init([1, 2, 3]), some([1, 2])) + * assert.deepStrictEqual(init([]), none) + * + * @since 2.0.0 + */ +var init = function (as) { return ((0, exports.isNonEmpty)(as) ? _.some(NEA.init(as)) : _.none); }; +exports.init = init; +/** + * Keep only a max number of elements from the start of an `Array`, creating a new `Array`. + * + * **Note**. `n` is normalized to a non negative integer. + * + * @example + * import { takeLeft } from 'fp-ts/Array' + * + * assert.deepStrictEqual(takeLeft(2)([1, 2, 3, 4, 5]), [1, 2]); + * assert.deepStrictEqual(takeLeft(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]); + * assert.deepStrictEqual(takeLeft(0)([1, 2, 3, 4, 5]), []); + * assert.deepStrictEqual(takeLeft(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]); + * + * @since 2.0.0 + */ +var takeLeft = function (n) { + return function (as) { + return (0, exports.isOutOfBound)(n, as) ? (0, exports.copy)(as) : as.slice(0, n); + }; +}; +exports.takeLeft = takeLeft; +/** + * Keep only a max number of elements from the end of an `Array`, creating a new `Array`. + * + * **Note**. `n` is normalized to a non negative integer. + * + * @example + * import { takeRight } from 'fp-ts/Array' + * + * assert.deepStrictEqual(takeRight(2)([1, 2, 3, 4, 5]), [4, 5]); + * assert.deepStrictEqual(takeRight(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]); + * assert.deepStrictEqual(takeRight(0)([1, 2, 3, 4, 5]), []); + * assert.deepStrictEqual(takeRight(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]); + * + * @since 2.0.0 + */ +var takeRight = function (n) { + return function (as) { + return (0, exports.isOutOfBound)(n, as) ? (0, exports.copy)(as) : n === 0 ? [] : as.slice(-n); + }; +}; +exports.takeRight = takeRight; +function takeLeftWhile(predicate) { + return function (as) { + var out = []; + for (var _i = 0, as_1 = as; _i < as_1.length; _i++) { + var a = as_1[_i]; + if (!predicate(a)) { + break; + } + out.push(a); + } + return out; + }; } - -balanced.range = range; -function range(a, b, str) { - var begs, beg, left, right, result; - var ai = str.indexOf(a); - var bi = str.indexOf(b, ai + 1); - var i = ai; - - if (ai >= 0 && bi > 0) { - if(a===b) { - return [ai, bi]; - } - begs = []; - left = str.length; - - while (i >= 0 && !result) { - if (i == ai) { - begs.push(i); - ai = str.indexOf(a, i + 1); - } else if (begs.length == 1) { - result = [ begs.pop(), bi ]; - } else { - beg = begs.pop(); - if (beg < left) { - left = beg; - right = bi; +exports.takeLeftWhile = takeLeftWhile; +var spanLeftIndex = function (as, predicate) { + var l = as.length; + var i = 0; + for (; i < l; i++) { + if (!predicate(as[i])) { + break; } - - bi = str.indexOf(b, i + 1); - } - - i = ai < bi && ai >= 0 ? ai : bi; - } - - if (begs.length) { - result = [ left, right ]; } - } - - return result; + return i; +}; +function spanLeft(predicate) { + return function (as) { + var _a = (0, exports.splitAt)(spanLeftIndex(as, predicate))(as), init = _a[0], rest = _a[1]; + return { init: init, rest: rest }; + }; } - - -/***/ }), - -/***/ 3682: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -var register = __nccwpck_require__(4670) -var addHook = __nccwpck_require__(5549) -var removeHook = __nccwpck_require__(6819) - -// bind with array of arguments: https://stackoverflow.com/a/21792913 -var bind = Function.bind -var bindable = bind.bind(bind) - -function bindApi (hook, state, name) { - var removeHookRef = bindable(removeHook, null).apply(null, name ? [state, name] : [state]) - hook.api = { remove: removeHookRef } - hook.remove = removeHookRef - - ;['before', 'error', 'after', 'wrap'].forEach(function (kind) { - var args = name ? [state, kind, name] : [state, kind] - hook[kind] = hook.api[kind] = bindable(addHook, null).apply(null, args) - }) +exports.spanLeft = spanLeft; +/** + * Creates a new `Array` which is a copy of the input dropping a max number of elements from the start. + * + * **Note**. `n` is normalized to a non negative integer. + * + * @example + * import { dropLeft } from 'fp-ts/Array' + * + * assert.deepStrictEqual(dropLeft(2)([1, 2, 3]), [3]); + * assert.deepStrictEqual(dropLeft(5)([1, 2, 3]), []); + * assert.deepStrictEqual(dropLeft(0)([1, 2, 3]), [1, 2, 3]); + * assert.deepStrictEqual(dropLeft(-2)([1, 2, 3]), [1, 2, 3]); + * + * @since 2.0.0 + */ +var dropLeft = function (n) { + return function (as) { + return n <= 0 || (0, exports.isEmpty)(as) ? (0, exports.copy)(as) : n >= as.length ? [] : as.slice(n, as.length); + }; +}; +exports.dropLeft = dropLeft; +/** + * Creates a new `Array` which is a copy of the input dropping a max number of elements from the end. + * + * **Note**. `n` is normalized to a non negative integer. + * + * @example + * import { dropRight } from 'fp-ts/Array' + * + * assert.deepStrictEqual(dropRight(2)([1, 2, 3]), [1]); + * assert.deepStrictEqual(dropRight(5)([1, 2, 3]), []); + * assert.deepStrictEqual(dropRight(0)([1, 2, 3]), [1, 2, 3]); + * assert.deepStrictEqual(dropRight(-2)([1, 2, 3]), [1, 2, 3]); + * + * @since 2.0.0 + */ +var dropRight = function (n) { + return function (as) { + return n <= 0 || (0, exports.isEmpty)(as) ? (0, exports.copy)(as) : n >= as.length ? [] : as.slice(0, as.length - n); + }; +}; +exports.dropRight = dropRight; +function dropLeftWhile(predicate) { + return function (as) { return as.slice(spanLeftIndex(as, predicate)); }; } - -function HookSingular () { - var singularHookName = 'h' - var singularHookState = { - registry: {} - } - var singularHook = register.bind(null, singularHookState, singularHookName) - bindApi(singularHook, singularHookState, singularHookName) - return singularHook +exports.dropLeftWhile = dropLeftWhile; +/** + * `findIndex` returns an `Option` containing the first index for which a predicate holds. + * It returns `None` if no element satisfies the predicate. + * Similar to [`findFirst`](#findFirst) but returning the index instead of the element. + * + * @example + * import { findIndex } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' + * + * assert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1)) + * assert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none) + * + * @since 2.0.0 + */ +exports.findIndex = RA.findIndex; +function findFirst(predicate) { + return RA.findFirst(predicate); } - -function HookCollection () { - var state = { - registry: {} - } - - var hook = register.bind(null, state) - bindApi(hook, state) - - return hook -} - -var collectionHookDeprecationMessageDisplayed = false -function Hook () { - if (!collectionHookDeprecationMessageDisplayed) { - console.warn('[before-after-hook]: "Hook()" repurposing warning, use "Hook.Collection()". Read more: https://git.io/upgrade-before-after-hook-to-1.4') - collectionHookDeprecationMessageDisplayed = true - } - return HookCollection() -} - -Hook.Singular = HookSingular.bind() -Hook.Collection = HookCollection.bind() - -module.exports = Hook -// expose constructors as a named property for TypeScript -module.exports.Hook = Hook -module.exports.Singular = Hook.Singular -module.exports.Collection = Hook.Collection - - -/***/ }), - -/***/ 5549: -/***/ ((module) => { - -module.exports = addHook - -function addHook (state, kind, name, hook) { - var orig = hook - if (!state.registry[name]) { - state.registry[name] = [] - } - - if (kind === 'before') { - hook = function (method, options) { - return Promise.resolve() - .then(orig.bind(null, options)) - .then(method.bind(null, options)) - } - } - - if (kind === 'after') { - hook = function (method, options) { - var result - return Promise.resolve() - .then(method.bind(null, options)) - .then(function (result_) { - result = result_ - return orig(result, options) - }) - .then(function () { - return result - }) - } - } - - if (kind === 'error') { - hook = function (method, options) { - return Promise.resolve() - .then(method.bind(null, options)) - .catch(function (error) { - return orig(error, options) - }) - } - } - - state.registry[name].push({ - hook: hook, - orig: orig - }) -} - - -/***/ }), - -/***/ 4670: -/***/ ((module) => { - -module.exports = register - -function register (state, name, method, options) { - if (typeof method !== 'function') { - throw new Error('method for before hook must be a function') - } - - if (!options) { - options = {} - } - - if (Array.isArray(name)) { - return name.reverse().reduce(function (callback, name) { - return register.bind(null, state, name, callback, options) - }, method)() - } - - return Promise.resolve() - .then(function () { - if (!state.registry[name]) { - return method(options) - } - - return (state.registry[name]).reduce(function (method, registered) { - return registered.hook.bind(null, method, options) - }, method)() - }) -} - - -/***/ }), - -/***/ 6819: -/***/ ((module) => { - -module.exports = removeHook - -function removeHook (state, name, method) { - if (!state.registry[name]) { - return - } - - var index = state.registry[name] - .map(function (registered) { return registered.orig }) - .indexOf(method) - - if (index === -1) { - return - } - - state.registry[name].splice(index, 1) -} - - -/***/ }), - -/***/ 3717: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -var concatMap = __nccwpck_require__(6891); -var balanced = __nccwpck_require__(9417); - -module.exports = expandTop; - -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; - -function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); -} - -function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); -} - -function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); -} - - -// Basically just str.split(","), but handling cases -// where we have nested braced sections, which should be -// treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; - - var parts = []; - var m = balanced('{', '}', str); - - if (!m) - return str.split(','); - - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); - - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } - - parts.push.apply(parts, p); - - return parts; -} - -function expandTop(str) { - if (!str) - return []; - - // I don't know why Bash 4.3 does this, but it does. - // Anything starting with {} will have the first two bytes preserved - // but *only* at the top level, so {},a}b will not expand to anything, - // but a{},b}c will be expanded to [a}c,abc]. - // One could argue that this is a bug in Bash, but since the goal of - // this module is to match Bash's rules, we escape a leading {} - if (str.substr(0, 2) === '{}') { - str = '\\{\\}' + str.substr(2); - } - - return expand(escapeBraces(str), true).map(unescapeBraces); -} - -function identity(e) { - return e; -} - -function embrace(str) { - return '{' + str + '}'; -} -function isPadded(el) { - return /^-?0\d/.test(el); -} - -function lte(i, y) { - return i <= y; -} -function gte(i, y) { - return i >= y; -} - -function expand(str, isTop) { - var expansions = []; - - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; - - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = m.body.indexOf(',') >= 0; - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*\}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); - } - return [str]; - } - - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0], false).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand(m.post, false) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } - - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. - - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post, false) - : ['']; - - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length) - var incr = n.length == 3 - ? Math.abs(numeric(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); - - N = []; - - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } - } - } - N.push(c); - } - } else { - N = concatMap(n, function(el) { return expand(el, false) }); - } - - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) - expansions.push(expansion); - } - } - - return expansions; -} - - - -/***/ }), - -/***/ 6891: -/***/ ((module) => { - -module.exports = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x); - else res.push(x); - } - return res; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - - -/***/ }), - -/***/ 8932: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); - -class Deprecation extends Error { - constructor(message) { - super(message); // Maintains proper stack trace (only available on V8) - - /* istanbul ignore next */ - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } - - this.name = 'Deprecation'; - } - -} - -exports.Deprecation = Deprecation; - - -/***/ }), - -/***/ 3834: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.rotate = exports.intersperse = exports.prependToAll = exports.unzip = exports.zip = exports.zipWith = exports.sort = exports.lefts = exports.rights = exports.reverse = exports.modifyAt = exports.deleteAt = exports.updateAt = exports.insertAt = exports.copy = exports.findLastIndex = exports.findLastMap = exports.findLast = exports.findFirstMap = exports.findFirst = exports.findIndex = exports.dropLeftWhile = exports.dropRight = exports.dropLeft = exports.spanLeft = exports.takeLeftWhile = exports.takeRight = exports.takeLeft = exports.init = exports.tail = exports.last = exports.head = exports.snoc = exports.cons = exports.lookup = exports.isOutOfBound = exports.isNonEmpty = exports.isEmpty = exports.scanRight = exports.scanLeft = exports.foldRight = exports.foldLeft = exports.flatten = exports.replicate = exports.range = exports.makeBy = exports.getOrd = exports.getEq = exports.getMonoid = exports.getShow = void 0; -exports.Applicative = exports.FunctorWithIndex = exports.Functor = exports.URI = exports.zero = exports.unfold = exports.wilt = exports.wither = exports.traverseWithIndex = exports.sequence = exports.traverse = exports.reduceRightWithIndex = exports.reduceRight = exports.reduceWithIndex = exports.reduce = exports.foldMapWithIndex = exports.foldMap = exports.duplicate = exports.extend = exports.filterWithIndex = exports.filterMapWithIndex = exports.alt = exports.altW = exports.partitionMapWithIndex = exports.partitionMap = exports.partitionWithIndex = exports.partition = exports.filterMap = exports.filter = exports.separate = exports.compact = exports.mapWithIndex = exports.chainFirst = exports.chainWithIndex = exports.chain = exports.apSecond = exports.apFirst = exports.ap = exports.map = exports.of = exports.difference = exports.intersection = exports.union = exports.comprehension = exports.chunksOf = exports.splitAt = exports.chop = exports.sortBy = exports.uniq = exports.elem = void 0; -exports.apS = exports.bind = exports.bindTo = exports.Do = exports.some = exports.every = exports.empty = exports.unsafeDeleteAt = exports.unsafeUpdateAt = exports.unsafeInsertAt = exports.array = exports.Witherable = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.FilterableWithIndex = exports.Filterable = exports.Compactable = exports.Extend = exports.Alternative = exports.Alt = exports.Unfoldable = exports.Monad = void 0; -var RA = __importStar(__nccwpck_require__(4234)); -// ------------------------------------------------------------------------------------- -// model -// ------------------------------------------------------------------------------------- -/* tslint:disable:readonly-array */ -/** - * @category instances - * @since 2.0.0 - */ -exports.getShow = RA.getShow; +exports.findFirst = findFirst; /** - * Returns a `Monoid` for `Array` + * Given a selector function which takes an element and returns an option, + * this function applies the selector to each element of the array and + * returns the first `Some` result. Otherwise it returns `None`. * * @example - * import { getMonoid } from 'fp-ts/Array' + * import { findFirstMap } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' * - * const M = getMonoid() - * assert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4]) + * interface Person { + * readonly name: string; + * readonly age: number; + * } + * + * const persons: Array = [ + * { name: "John", age: 16 }, + * { name: "Mary", age: 45 }, + * { name: "Joey", age: 28 }, + * ]; + * + * const nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name)); + * const nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name)); + * assert.deepStrictEqual(findFirstMap(nameOfPersonAbove18)(persons), some("Mary")); + * assert.deepStrictEqual(findFirstMap(nameOfPersonAbove70)(persons), none); * - * @category instances * @since 2.0.0 */ -exports.getMonoid = RA.getMonoid; +exports.findFirstMap = RA.findFirstMap; +function findLast(predicate) { + return RA.findLast(predicate); +} +exports.findLast = findLast; /** - * Derives an `Eq` over the `Array` of a given element type from the `Eq` of that type. The derived `Eq` defines two - * arrays as equal if all elements of both arrays are compared equal pairwise with the given `E`. In case of arrays of - * different lengths, the result is non equality. + * Given a selector function which takes an element and returns an option, + * this function applies the selector to each element of the array starting from the + * end and returns the last `Some` result. Otherwise it returns `None`. * * @example - * import { eqString } from 'fp-ts/Eq' - * import { getEq } from 'fp-ts/Array' + * import { findLastMap } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' * - * const E = getEq(eqString) - * assert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true) - * assert.strictEqual(E.equals(['a'], []), false) + * interface Person { + * readonly name: string; + * readonly age: number; + * } + * + * const persons: Array = [ + * { name: "John", age: 16 }, + * { name: "Mary", age: 45 }, + * { name: "Joey", age: 28 }, + * ]; + * + * const nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name)); + * const nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name)); + * assert.deepStrictEqual(findLastMap(nameOfPersonAbove18)(persons), some("Joey")); + * assert.deepStrictEqual(findLastMap(nameOfPersonAbove70)(persons), none); * - * @category instances * @since 2.0.0 */ -exports.getEq = RA.getEq; +exports.findLastMap = RA.findLastMap; /** - * Derives an `Ord` over the `Array` of a given element type from the `Ord` of that type. The ordering between two such - * arrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in - * case of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have - * the same length, the result is equality. + * Returns the index of the last element of the list which matches the predicate. + * It returns an `Option` containing the index or `None` if not found. * * @example - * import { getOrd } from 'fp-ts/Array' - * import { ordString } from 'fp-ts/Ord' + * import { findLastIndex } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' * - * const O = getOrd(ordString) - * assert.strictEqual(O.compare(['b'], ['a']), 1) - * assert.strictEqual(O.compare(['a'], ['a']), 0) - * assert.strictEqual(O.compare(['a'], ['b']), -1) + * interface X { + * readonly a: number + * readonly b: number + * } + * const xs: Array = [{ a: 1, b: 0 }, { a: 1, b: 1 }] + * assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 1)(xs), some(1)) + * assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 4)(xs), none) * - * @category instances * @since 2.0.0 */ -exports.getOrd = RA.getOrd; -// ------------------------------------------------------------------------------------- -// constructors -// ------------------------------------------------------------------------------------- +exports.findLastIndex = RA.findLastIndex; /** - * Return a list of length `n` with element `i` initialized with `f(i)` - * - * @example - * import { makeBy } from 'fp-ts/Array' - * - * const double = (n: number): number => n * 2 - * assert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8]) + * This function takes an array and makes a new array containing the same elements. * - * @category constructors * @since 2.0.0 */ -exports.makeBy = RA.makeBy; +var copy = function (as) { return as.slice(); }; +exports.copy = copy; /** - * Create an array containing a range of integers, including both endpoints + * Insert an element at the specified index, creating a new array, + * or returning `None` if the index is out of bounds. * * @example - * import { range } from 'fp-ts/Array' + * import { insertAt } from 'fp-ts/Array' + * import { some } from 'fp-ts/Option' * - * assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5]) + * assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4])) * - * @category constructors * @since 2.0.0 */ -exports.range = RA.range; +var insertAt = function (i, a) { + return function (as) { + return i < 0 || i > as.length ? _.none : _.some((0, exports.unsafeInsertAt)(i, a, as)); + }; +}; +exports.insertAt = insertAt; /** - * Create an array containing a value repeated the specified number of times + * Change the element at the specified index, creating a new array, + * or returning `None` if the index is out of bounds. * * @example - * import { replicate } from 'fp-ts/Array' + * import { updateAt } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' * - * assert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a']) + * assert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3])) + * assert.deepStrictEqual(updateAt(1, 1)([]), none) * - * @category constructors * @since 2.0.0 */ -exports.replicate = RA.replicate; +var updateAt = function (i, a) { return (0, exports.modifyAt)(i, function () { return a; }); }; +exports.updateAt = updateAt; /** - * Removes one level of nesting. - * - * Derivable from `Monad`. + * Delete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds. * * @example - * import { flatten } from 'fp-ts/Array' + * import { deleteAt } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' * - * assert.deepStrictEqual(flatten([[1], [2], [3]]), [1, 2, 3]) + * assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3])) + * assert.deepStrictEqual(deleteAt(1)([]), none) * - * @category combinators * @since 2.0.0 */ -exports.flatten = RA.flatten; +var deleteAt = function (i) { + return function (as) { + return (0, exports.isOutOfBound)(i, as) ? _.none : _.some((0, exports.unsafeDeleteAt)(i, as)); + }; +}; +exports.deleteAt = deleteAt; /** - * Break an array into its first element and remaining elements + * Apply a function to the element at the specified index, creating a new array, or returning `None` if the index is out + * of bounds. * * @example - * import { foldLeft } from 'fp-ts/Array' + * import { modifyAt } from 'fp-ts/Array' + * import { some, none } from 'fp-ts/Option' * - * const len: (as: Array) => number = foldLeft(() => 0, (_, tail) => 1 + len(tail)) - * assert.strictEqual(len([1, 2, 3]), 3) + * const double = (x: number): number => x * 2 + * assert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3])) + * assert.deepStrictEqual(modifyAt(1, double)([]), none) * - * @category destructors * @since 2.0.0 */ -exports.foldLeft = RA.foldLeft; +var modifyAt = function (i, f) { + return function (as) { + return (0, exports.isOutOfBound)(i, as) ? _.none : _.some((0, exports.unsafeUpdateAt)(i, f(as[i]), as)); + }; +}; +exports.modifyAt = modifyAt; /** - * Break an array into its initial elements and the last element + * Reverse an array, creating a new array + * + * @example + * import { reverse } from 'fp-ts/Array' + * + * assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1]) * - * @category destructors * @since 2.0.0 */ -exports.foldRight = RA.foldRight; +var reverse = function (as) { return ((0, exports.isEmpty)(as) ? [] : as.slice().reverse()); }; +exports.reverse = reverse; /** - * Same as `reduce` but it carries over the intermediate steps + * Takes an `Array` of `Either` and produces a new `Array` containing + * the values of all the `Right` elements in the same order. * * @example - * import { scanLeft } from 'fp-ts/Array' + * import { rights } from 'fp-ts/Array' + * import { right, left } from 'fp-ts/Either' * - * assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4]) + * assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2]) * - * @category combinators * @since 2.0.0 */ -exports.scanLeft = RA.scanLeft; +var rights = function (as) { + var r = []; + for (var i = 0; i < as.length; i++) { + var a = as[i]; + if (a._tag === 'Right') { + r.push(a.right); + } + } + return r; +}; +exports.rights = rights; /** - * Fold an array from the right, keeping all intermediate results instead of only the final result + * Takes an `Array` of `Either` and produces a new `Array` containing + * the values of all the `Left` elements in the same order. * * @example - * import { scanRight } from 'fp-ts/Array' + * import { lefts } from 'fp-ts/Array' + * import { left, right } from 'fp-ts/Either' * - * assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10]) + * assert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo']) * - * @category combinators * @since 2.0.0 */ -exports.scanRight = RA.scanRight; +var lefts = function (as) { + var r = []; + for (var i = 0; i < as.length; i++) { + var a = as[i]; + if (a._tag === 'Left') { + r.push(a.left); + } + } + return r; +}; +exports.lefts = lefts; /** - * Test whether an array is empty + * Sort the elements of an array in increasing order, creating a new array * * @example - * import { isEmpty } from 'fp-ts/Array' + * import { sort } from 'fp-ts/Array' + * import * as N from 'fp-ts/number' * - * assert.strictEqual(isEmpty([]), true) + * assert.deepStrictEqual(sort(N.Ord)([3, 2, 1]), [1, 2, 3]) * * @since 2.0.0 */ -exports.isEmpty = RA.isEmpty; +var sort = function (O) { + return function (as) { + return as.length <= 1 ? (0, exports.copy)(as) : as.slice().sort(O.compare); + }; +}; +exports.sort = sort; /** - * Test whether an array is non empty narrowing down the type to `NonEmptyArray` + * Apply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one + * input array is short, excess elements of the longer array are discarded. * - * @category guards - * @since 2.0.0 - */ -exports.isNonEmpty = RA.isNonEmpty; -/** - * Test whether an array contains a particular index + * @example + * import { zipWith } from 'fp-ts/Array' + * + * assert.deepStrictEqual(zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n), ['a1', 'b2', 'c3']) * * @since 2.0.0 */ -exports.isOutOfBound = RA.isOutOfBound; -// TODO: remove non-curried overloading in v3 +var zipWith = function (fa, fb, f) { + var fc = []; + var len = Math.min(fa.length, fb.length); + for (var i = 0; i < len; i++) { + fc[i] = f(fa[i], fb[i]); + } + return fc; +}; +exports.zipWith = zipWith; +function zip(as, bs) { + if (bs === undefined) { + return function (bs) { return zip(bs, as); }; + } + return (0, exports.zipWith)(as, bs, function (a, b) { return [a, b]; }); +} +exports.zip = zip; /** - * This function provides a safe way to read a value at a particular index from an array + * The function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays * * @example - * import { lookup } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' - * import { pipe } from 'fp-ts/function' + * import { unzip } from 'fp-ts/Array' * - * assert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2)) - * assert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none) + * assert.deepStrictEqual(unzip([[1, 'a'], [2, 'b'], [3, 'c']]), [[1, 2, 3], ['a', 'b', 'c']]) * * @since 2.0.0 */ -exports.lookup = RA.lookup; -// TODO: remove non-curried overloading in v3 +var unzip = function (as) { + var fa = []; + var fb = []; + for (var i = 0; i < as.length; i++) { + fa[i] = as[i][0]; + fb[i] = as[i][1]; + } + return [fa, fb]; +}; +exports.unzip = unzip; /** - * Attaches an element to the front of an array, creating a new non empty array + * Creates a new `Array`, prepending an element to every member of the input `Array`. * * @example - * import { cons } from 'fp-ts/Array' - * import { pipe } from 'fp-ts/function' + * import { prependAll } from 'fp-ts/Array' * - * assert.deepStrictEqual(pipe([1, 2, 3], cons(0)), [0, 1, 2, 3]) + * assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4]) * - * @category constructors - * @since 2.0.0 + * @since 2.10.0 */ -exports.cons = RA.cons; -// TODO: curry in v3 +var prependAll = function (middle) { + var f = NEA.prependAll(middle); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : []); }; +}; +exports.prependAll = prependAll; /** - * Append an element to the end of an array, creating a new non empty array + * Creates a new `Array` placing an element in between members of the input `Array`. * * @example - * import { snoc } from 'fp-ts/Array' + * import { intersperse } from 'fp-ts/Array' * - * assert.deepStrictEqual(snoc([1, 2, 3], 4), [1, 2, 3, 4]) + * assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4]) * - * @category constructors - * @since 2.0.0 + * @since 2.9.0 */ -exports.snoc = RA.snoc; +var intersperse = function (middle) { + var f = NEA.intersperse(middle); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : (0, exports.copy)(as)); }; +}; +exports.intersperse = intersperse; /** - * Get the first element in an array, or `None` if the array is empty + * Creates a new `Array` rotating the input `Array` by `n` steps. * * @example - * import { head } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' + * import { rotate } from 'fp-ts/Array' * - * assert.deepStrictEqual(head([1, 2, 3]), some(1)) - * assert.deepStrictEqual(head([]), none) + * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3]) * - * @category destructors * @since 2.0.0 */ -exports.head = RA.head; +var rotate = function (n) { + var f = NEA.rotate(n); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : (0, exports.copy)(as)); }; +}; +exports.rotate = rotate; +// TODO: remove non-curried overloading in v3 /** - * Get the last element in an array, or `None` if the array is empty + * Test if a value is a member of an `Array`. Takes a `Eq` as a single + * argument which returns the function to use to search for a value of type `A` in + * an `Array`. * * @example - * import { last } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' + * import { elem } from 'fp-ts/Array' + * import * as N from 'fp-ts/number' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(last([1, 2, 3]), some(3)) - * assert.deepStrictEqual(last([]), none) + * assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(2)), true) + * assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(0)), false) * - * @category destructors * @since 2.0.0 */ -exports.last = RA.last; +exports.elem = RA.elem; /** - * Get all but the first element of an array, creating a new array, or `None` if the array is empty + * Creates a new `Array` removing duplicate elements, keeping the first occurrence of an element, + * based on a `Eq`. * * @example - * import { tail } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' + * import { uniq } from 'fp-ts/Array' + * import * as N from 'fp-ts/number' * - * assert.deepStrictEqual(tail([1, 2, 3]), some([2, 3])) - * assert.deepStrictEqual(tail([]), none) + * assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2]) * - * @category destructors * @since 2.0.0 */ -exports.tail = RA.tail; +var uniq = function (E) { + var f = NEA.uniq(E); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : (0, exports.copy)(as)); }; +}; +exports.uniq = uniq; /** - * Get all but the last element of an array, creating a new array, or `None` if the array is empty + * Sort the elements of an array in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`, + * etc... * * @example - * import { init } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' - * - * assert.deepStrictEqual(init([1, 2, 3]), some([1, 2])) - * assert.deepStrictEqual(init([]), none) + * import { sortBy } from 'fp-ts/Array' + * import { contramap } from 'fp-ts/Ord' + * import * as S from 'fp-ts/string' + * import * as N from 'fp-ts/number' + * import { pipe } from 'fp-ts/function' * - * @category destructors - * @since 2.0.0 - */ -exports.init = RA.init; -/** - * Keep only a number of elements from the start of an array, creating a new array. - * `n` must be a natural number + * interface Person { + * readonly name: string + * readonly age: number + * } + * const byName = pipe(S.Ord, contramap((p: Person) => p.name)) + * const byAge = pipe(N.Ord, contramap((p: Person) => p.age)) * - * @example - * import { takeLeft } from 'fp-ts/Array' + * const sortByNameByAge = sortBy([byName, byAge]) * - * assert.deepStrictEqual(takeLeft(2)([1, 2, 3]), [1, 2]) + * const persons = [{ name: 'a', age: 1 }, { name: 'b', age: 3 }, { name: 'c', age: 2 }, { name: 'b', age: 2 }] + * assert.deepStrictEqual(sortByNameByAge(persons), [ + * { name: 'a', age: 1 }, + * { name: 'b', age: 2 }, + * { name: 'b', age: 3 }, + * { name: 'c', age: 2 } + * ]) * - * @category combinators * @since 2.0.0 */ -exports.takeLeft = RA.takeLeft; +var sortBy = function (ords) { + var f = NEA.sortBy(ords); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : (0, exports.copy)(as)); }; +}; +exports.sortBy = sortBy; /** - * Keep only a number of elements from the end of an array, creating a new array. - * `n` must be a natural number + * A useful recursion pattern for processing an array to produce a new array, often used for "chopping" up the input + * array. Typically chop is called with some function that will consume an initial prefix of the array and produce a + * value and the rest of the array. * * @example - * import { takeRight } from 'fp-ts/Array' + * import { Eq } from 'fp-ts/Eq' + * import * as A from 'fp-ts/Array' + * import * as N from 'fp-ts/number' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(takeRight(2)([1, 2, 3, 4, 5]), [4, 5]) + * const group = (S: Eq): ((as: Array) => Array>) => { + * return A.chop(as => { + * const { init, rest } = pipe(as, A.spanLeft((a: A) => S.equals(a, as[0]))) + * return [init, rest] + * }) + * } + * assert.deepStrictEqual(group(N.Eq)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]]) * - * @category combinators * @since 2.0.0 */ -exports.takeRight = RA.takeRight; -function takeLeftWhile(predicate) { - return RA.takeLeftWhile(predicate); -} -exports.takeLeftWhile = takeLeftWhile; -function spanLeft(predicate) { - return RA.spanLeft(predicate); -} -exports.spanLeft = spanLeft; -/* tslint:enable:readonly-keyword */ +var chop = function (f) { + var g = NEA.chop(f); + return function (as) { return ((0, exports.isNonEmpty)(as) ? g(as) : []); }; +}; +exports.chop = chop; /** - * Drop a number of elements from the start of an array, creating a new array + * Splits an `Array` into two pieces, the first piece has max `n` elements. * * @example - * import { dropLeft } from 'fp-ts/Array' + * import { splitAt } from 'fp-ts/Array' * - * assert.deepStrictEqual(dropLeft(2)([1, 2, 3]), [3]) + * assert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4, 5]]) * - * @category combinators * @since 2.0.0 */ -exports.dropLeft = RA.dropLeft; +var splitAt = function (n) { + return function (as) { + return n >= 1 && (0, exports.isNonEmpty)(as) ? NEA.splitAt(n)(as) : (0, exports.isEmpty)(as) ? [(0, exports.copy)(as), []] : [[], (0, exports.copy)(as)]; + }; +}; +exports.splitAt = splitAt; /** - * Drop a number of elements from the end of an array, creating a new array + * Splits an array into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of + * the array. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive + * definition of `chunksOf`; it satisfies the property that + * + * ```ts + * chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys))) + * ``` + * + * whenever `n` evenly divides the length of `xs`. * * @example - * import { dropRight } from 'fp-ts/Array' + * import { chunksOf } from 'fp-ts/Array' * - * assert.deepStrictEqual(dropRight(2)([1, 2, 3, 4, 5]), [1, 2, 3]) + * assert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]]) * - * @category combinators * @since 2.0.0 */ -exports.dropRight = RA.dropRight; +var chunksOf = function (n) { + var f = NEA.chunksOf(n); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : []); }; +}; +exports.chunksOf = chunksOf; +/** + * @category lifting + * @since 2.11.0 + */ +var fromOptionK = function (f) { + return function () { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } + return (0, exports.fromOption)(f.apply(void 0, a)); + }; +}; +exports.fromOptionK = fromOptionK; +function comprehension(input, f, g) { + if (g === void 0) { g = function () { return true; }; } + var go = function (scope, input) { + return (0, exports.isNonEmpty)(input) + ? (0, exports.flatMap)(NEA.head(input), function (a) { return go((0, function_1.pipe)(scope, (0, exports.append)(a)), NEA.tail(input)); }) + : g.apply(void 0, scope) ? [f.apply(void 0, scope)] + : []; + }; + return go([], input); +} +exports.comprehension = comprehension; +/** + * @since 2.11.0 + */ +var concatW = function (second) { + return function (first) { + return (0, exports.isEmpty)(first) ? (0, exports.copy)(second) : (0, exports.isEmpty)(second) ? (0, exports.copy)(first) : first.concat(second); + }; +}; +exports.concatW = concatW; +/** + * @since 2.11.0 + */ +exports.concat = exports.concatW; +function union(E) { + var unionE = NEA.union(E); + return function (first, second) { + if (second === undefined) { + var unionE_1 = union(E); + return function (second) { return unionE_1(second, first); }; + } + return (0, exports.isNonEmpty)(first) && (0, exports.isNonEmpty)(second) + ? unionE(second)(first) + : (0, exports.isNonEmpty)(first) + ? (0, exports.copy)(first) + : (0, exports.copy)(second); + }; +} +exports.union = union; +function intersection(E) { + var elemE = (0, exports.elem)(E); + return function (xs, ys) { + if (ys === undefined) { + var intersectionE_1 = intersection(E); + return function (ys) { return intersectionE_1(ys, xs); }; + } + return xs.filter(function (a) { return elemE(a, ys); }); + }; +} +exports.intersection = intersection; +function difference(E) { + var elemE = (0, exports.elem)(E); + return function (xs, ys) { + if (ys === undefined) { + var differenceE_1 = difference(E); + return function (ys) { return differenceE_1(ys, xs); }; + } + return xs.filter(function (a) { return !elemE(a, ys); }); + }; +} +exports.difference = difference; +var _map = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }; +/* istanbul ignore next */ +var _mapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.mapWithIndex)(f)); }; +var _ap = function (fab, fa) { return (0, function_1.pipe)(fab, (0, exports.ap)(fa)); }; +/* istanbul ignore next */ +var _filter = function (fa, predicate) { return (0, function_1.pipe)(fa, (0, exports.filter)(predicate)); }; +/* istanbul ignore next */ +var _filterMap = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.filterMap)(f)); }; +/* istanbul ignore next */ +var _partition = function (fa, predicate) { + return (0, function_1.pipe)(fa, (0, exports.partition)(predicate)); +}; +/* istanbul ignore next */ +var _partitionMap = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.partitionMap)(f)); }; +/* istanbul ignore next */ +var _partitionWithIndex = function (fa, predicateWithIndex) { return (0, function_1.pipe)(fa, (0, exports.partitionWithIndex)(predicateWithIndex)); }; +/* istanbul ignore next */ +var _partitionMapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.partitionMapWithIndex)(f)); }; +/* istanbul ignore next */ +var _alt = function (fa, that) { return (0, function_1.pipe)(fa, (0, exports.alt)(that)); }; +var _reduce = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduce)(b, f)); }; +/* istanbul ignore next */ +var _foldMap = function (M) { + var foldMapM = (0, exports.foldMap)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapM(f)); }; +}; +/* istanbul ignore next */ +var _reduceRight = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduceRight)(b, f)); }; +/* istanbul ignore next */ +var _reduceWithIndex = function (fa, b, f) { + return (0, function_1.pipe)(fa, (0, exports.reduceWithIndex)(b, f)); +}; +/* istanbul ignore next */ +var _foldMapWithIndex = function (M) { + var foldMapWithIndexM = (0, exports.foldMapWithIndex)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapWithIndexM(f)); }; +}; +/* istanbul ignore next */ +var _reduceRightWithIndex = function (fa, b, f) { + return (0, function_1.pipe)(fa, (0, exports.reduceRightWithIndex)(b, f)); +}; +/* istanbul ignore next */ +var _filterMapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.filterMapWithIndex)(f)); }; +/* istanbul ignore next */ +var _filterWithIndex = function (fa, predicateWithIndex) { return (0, function_1.pipe)(fa, (0, exports.filterWithIndex)(predicateWithIndex)); }; +/* istanbul ignore next */ +var _extend = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.extend)(f)); }; +/* istanbul ignore next */ +var _traverse = function (F) { + var traverseF = (0, exports.traverse)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseF(f)); }; +}; +/* istanbul ignore next */ +var _traverseWithIndex = function (F) { + var traverseWithIndexF = (0, exports.traverseWithIndex)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseWithIndexF(f)); }; +}; +var _chainRecDepthFirst = RA._chainRecDepthFirst; +var _chainRecBreadthFirst = RA._chainRecBreadthFirst; /** - * Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new array + * Given an element of the base type, `of` builds an `Array` containing just that + * element of the base type (this is useful for building a `Monad`). * * @example - * import { dropLeftWhile } from 'fp-ts/Array' + * import { of } from 'fp-ts/Array' * - * assert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5]) + * assert.deepStrictEqual(of("a"), ["a"]); * - * @category combinators + * @category constructors * @since 2.0.0 */ -exports.dropLeftWhile = RA.dropLeftWhile; +exports.of = NEA.of; /** - * Find the first index for which a predicate holds - * - * @example - * import { findIndex } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' + * Makes an empty `Array`, useful for building a [`Monoid`](#Monoid) * - * assert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1)) - * assert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none) - * - * @since 2.0.0 + * @since 2.7.0 */ -exports.findIndex = RA.findIndex; -function findFirst(predicate) { - return RA.findFirst(predicate); -} -exports.findFirst = findFirst; +var zero = function () { return []; }; +exports.zero = zero; /** - * Find the first element returned by an option based selector function + * `map` can be used to turn functions `(a: A) => B` into functions `(fa: Array) => Array`. + * In practice it applies the base function to each element of the array and collects the + * results in a new array. * * @example - * import { findFirstMap } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' - * - * interface Person { - * name: string - * age?: number - * } - * - * const persons: Array = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }] + * import { map } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' * - * // returns the name of the first person that has an age - * assert.deepStrictEqual(findFirstMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Mary')) + * const f = (n: number) => n * 2; + * assert.deepStrictEqual(pipe([1, 2, 3], map(f)), [2, 4, 6]); * - * @category destructors + * @category mapping * @since 2.0.0 */ -exports.findFirstMap = RA.findFirstMap; -function findLast(predicate) { - return RA.findLast(predicate); -} -exports.findLast = findLast; +var map = function (f) { return function (fa) { return fa.map(function (a) { return f(a); }); }; }; +exports.map = map; /** - * Find the last element returned by an option based selector function - * * @example - * import { findLastMap } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' + * import { ap, map, of } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' * - * interface Person { - * name: string - * age?: number - * } + * // a curried function with 3 input parameteres + * const f = (s1: string) => (n: number) => (s2: string) => s1 + n + s2; * - * const persons: Array = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }] + * // let's use `ap` to iterate `f` over an array for each input parameter + * assert.deepStrictEqual(pipe(["a", "b"], map(f), ap([1, 2]), ap(["😀", "😫", "😎"])), [ + * "a1😀", "a1😫", "a1😎", + * "a2😀", "a2😫", "a2😎", + * "b1😀", "b1😫", "b1😎", + * "b2😀", "b2😫", "b2😎", + * ]); * - * // returns the name of the last person that has an age - * assert.deepStrictEqual(findLastMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Joey')) + * // given Array implements the Applicative interface with the `of` method, + * // we can write exactly the same thing in a more symmetric way + * // using `of` on `f` and `ap` on each array in input + * assert.deepStrictEqual( + * pipe(of(f), ap(["a", "b"]), ap([1, 2]), ap(["😀", "😫", "😎"])), + * pipe(["a", "b"], map(f), ap([1, 2]), ap(["😀", "😫", "😎"])) + * ); * - * @category destructors * @since 2.0.0 */ -exports.findLastMap = RA.findLastMap; +var ap = function (fa) { + return (0, exports.flatMap)(function (f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }); +}; +exports.ap = ap; /** - * Returns the index of the last element of the list which matches the predicate + * Composes computations in sequence, using the return value of one computation to + * determine the next computation. * - * @example - * import { findLastIndex } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' + * In other words it takes a function `f` that produces an array from a single element of + * the base type `A` and returns a new function which applies `f` to each element of the + * input array (like [`map`](#map)) and, instead of returning an array of arrays, concatenates the + * results into a single array (like [`flatten`](#flatten)). * - * interface X { - * a: number - * b: number - * } - * const xs: Array = [{ a: 1, b: 0 }, { a: 1, b: 1 }] - * assert.deepStrictEqual(findLastIndex((x: { a: number }) => x.a === 1)(xs), some(1)) - * assert.deepStrictEqual(findLastIndex((x: { a: number }) => x.a === 4)(xs), none) + * @example + * import { flatMap, map, replicate } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' * + * const f = (n: number) => replicate(n, `${n}`); + * assert.deepStrictEqual(pipe([1, 2, 3], map(f)), [["1"], ["2", "2"], ["3", "3", "3"]]); + * assert.deepStrictEqual(pipe([1, 2, 3], flatMap(f)), ["1", "2", "2", "3", "3", "3"]); * - * @since 2.0.0 - */ -exports.findLastIndex = RA.findLastIndex; -/** - * @category combinators - * @since 2.0.0 + * @category sequencing + * @since 2.14.0 */ -exports.copy = RA.toArray; +exports.flatMap = (0, function_1.dual)(2, function (ma, f) { + return (0, function_1.pipe)(ma, (0, exports.chainWithIndex)(function (i, a) { return f(a, i); })); +}); /** - * Insert an element at the specified index, creating a new array, or returning `None` if the index is out of bounds + * Takes an array of arrays of `A` and flattens them into an array of `A` + * by concatenating the elements of each array in order. * * @example - * import { insertAt } from 'fp-ts/Array' - * import { some } from 'fp-ts/Option' + * import { flatten } from 'fp-ts/Array' * - * assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4])) + * assert.deepStrictEqual(flatten([["a"], ["b", "c"], ["d", "e", "f"]]), ["a", "b", "c", "d", "e", "f"]); * - * @since 2.0.0 + * @category sequencing + * @since 2.5.0 */ -exports.insertAt = RA.insertAt; +exports.flatten = (0, exports.flatMap)(function_1.identity); /** - * Change the element at the specified index, creating a new array, or returning `None` if the index is out of bounds + * Same as [`map`](#map), but the iterating function takes both the index and the value + * of the element. * * @example - * import { updateAt } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' + * import { mapWithIndex } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3])) - * assert.deepStrictEqual(updateAt(1, 1)([]), none) + * const f = (i: number, s: string) => `${s} - ${i}`; + * assert.deepStrictEqual(pipe(["a", "b", "c"], mapWithIndex(f)), ["a - 0", "b - 1", "c - 2"]); * + * @category mapping * @since 2.0.0 */ -exports.updateAt = RA.updateAt; +var mapWithIndex = function (f) { return function (fa) { + return fa.map(function (a, i) { return f(i, a); }); +}; }; +exports.mapWithIndex = mapWithIndex; /** - * Delete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds + * Maps an array with an iterating function that takes the index and the value of + * each element and returns an `Option`. It keeps only the `Some` values discarding + * the `None`s. + * + * Same as [`filterMap`](#filterMap), but with an iterating function which takes also + * the index as input. * * @example - * import { deleteAt } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' + * import { filterMapWithIndex } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * import { option } from "fp-ts"; * - * assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3])) - * assert.deepStrictEqual(deleteAt(1)([]), none) + * const f = (i: number, s: string) => (i % 2 === 1 ? option.some(s.toUpperCase()) : option.none); + * assert.deepStrictEqual(pipe(["a", "no", "neither", "b"], filterMapWithIndex(f)), ["NO", "B"]); * + * @category filtering * @since 2.0.0 */ -exports.deleteAt = RA.deleteAt; +var filterMapWithIndex = function (f) { + return function (fa) { + var out = []; + for (var i = 0; i < fa.length; i++) { + var optionB = f(i, fa[i]); + if (_.isSome(optionB)) { + out.push(optionB.value); + } + } + return out; + }; +}; +exports.filterMapWithIndex = filterMapWithIndex; /** - * Apply a function to the element at the specified index, creating a new array, or returning `None` if the index is out - * of bounds + * Maps an array with an iterating function that returns an `Option` + * and it keeps only the `Some` values discarding the `None`s. * * @example - * import { modifyAt } from 'fp-ts/Array' - * import { some, none } from 'fp-ts/Option' + * import { filterMap } from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * import { option } from "fp-ts"; * - * const double = (x: number): number => x * 2 - * assert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3])) - * assert.deepStrictEqual(modifyAt(1, double)([]), none) + * const f = (s: string) => s.length === 1 ? option.some(s.toUpperCase()) : option.none; + * assert.deepStrictEqual(pipe(["a", "no", "neither", "b"], filterMap(f)), ["A", "B"]); * + * @category filtering * @since 2.0.0 */ -exports.modifyAt = RA.modifyAt; +var filterMap = function (f) { + return (0, exports.filterMapWithIndex)(function (_, a) { return f(a); }); +}; +exports.filterMap = filterMap; /** - * Reverse an array, creating a new array + * Compact an array of `Option`s discarding the `None` values and + * keeping the `Some` values. It returns a new array containing the values of + * the `Some` options. * * @example - * import { reverse } from 'fp-ts/Array' + * import { compact } from 'fp-ts/Array' + * import { option } from "fp-ts"; * - * assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1]) + * assert.deepStrictEqual(compact([option.some("a"), option.none, option.some("b")]), ["a", "b"]); * - * @category combinators + * @category filtering * @since 2.0.0 */ -exports.reverse = RA.reverse; +exports.compact = (0, exports.filterMap)(function_1.identity); /** - * Extracts from an array of `Either` all the `Right` elements. All the `Right` elements are extracted in order + * Separate an array of `Either`s into `Left`s and `Right`s, creating two new arrays: + * one containing all the left values and one containing all the right values. * * @example - * import { rights } from 'fp-ts/Array' - * import { right, left } from 'fp-ts/Either' + * import { separate } from 'fp-ts/Array' + * import { either } from "fp-ts"; * - * assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2]) + * assert.deepStrictEqual(separate([either.right("r1"), either.left("l1"), either.right("r2")]), { + * left: ["l1"], + * right: ["r1", "r2"], + * }); * - * @category combinators + * @category filtering * @since 2.0.0 */ -exports.rights = RA.rights; +var separate = function (fa) { + var left = []; + var right = []; + for (var _i = 0, fa_1 = fa; _i < fa_1.length; _i++) { + var e = fa_1[_i]; + if (e._tag === 'Left') { + left.push(e.left); + } + else { + right.push(e.right); + } + } + return (0, Separated_1.separated)(left, right); +}; +exports.separate = separate; /** - * Extracts from an array of `Either` all the `Left` elements. All the `Left` elements are extracted in order + * Given an iterating function that is a `Predicate` or a `Refinement`, + * `filter` creates a new `Array` containing the elements of the original + * `Array` for which the iterating function is `true`. * * @example - * import { lefts } from 'fp-ts/Array' - * import { left, right } from 'fp-ts/Either' + * import { filter } from 'fp-ts/Array' + * import { isString } from "fp-ts/string"; * - * assert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo']) + * assert.deepStrictEqual(filter(isString)(["a", 1, {}, "b", 5]), ["a", "b"]); + * assert.deepStrictEqual(filter((x:number) => x > 0)([-3, 1, -2, 5]), [1, 5]); * - * @category combinators + * @category filtering * @since 2.0.0 */ -exports.lefts = RA.lefts; +var filter = function (predicate) { + return function (as) { + return as.filter(predicate); + }; +}; +exports.filter = filter; /** - * Sort the elements of an array in increasing order, creating a new array + * Given an iterating function that is a `Predicate` or a `Refinement`, + * `partition` creates two new `Array`s: `right` containing the elements of the original + * `Array` for which the iterating function is `true`, `left` containing the elements + * for which it is false. * * @example - * import { sort } from 'fp-ts/Array' - * import { ordNumber } from 'fp-ts/Ord' + * import { partition } from 'fp-ts/Array' + * import { isString } from "fp-ts/string"; * - * assert.deepStrictEqual(sort(ordNumber)([3, 2, 1]), [1, 2, 3]) + * assert.deepStrictEqual(partition(isString)(["a", 1, {}, "b", 5]), { left: [1, {}, 5], right: ["a", "b"] }); + * assert.deepStrictEqual(partition((x: number) => x > 0)([-3, 1, -2, 5]), { left: [-3, -2], right: [1, 5] }); * - * @category combinators + * @category filtering * @since 2.0.0 */ -exports.sort = RA.sort; +var partition = function (predicate) { + return (0, exports.partitionWithIndex)(function (_, a) { return predicate(a); }); +}; +exports.partition = partition; /** - * Apply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one - * input array is short, excess elements of the longer array are discarded. + * Same as [`partition`](#partition), but passing also the index to the iterating function. * * @example - * import { zipWith } from 'fp-ts/Array' + * import { partitionWithIndex } from 'fp-ts/Array' * - * assert.deepStrictEqual(zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n), ['a1', 'b2', 'c3']) + * assert.deepStrictEqual(partitionWithIndex((index, x: number) => index < 3 && x > 0)([-2, 5, 6, 7]), { + * left: [-2, 7], + * right: [5, 6], + * }); * - * @category combinators + * @category filtering * @since 2.0.0 */ -exports.zipWith = RA.zipWith; -// TODO: remove non-curried overloading in v3 +var partitionWithIndex = function (predicateWithIndex) { + return function (as) { + var left = []; + var right = []; + for (var i = 0; i < as.length; i++) { + var b = as[i]; + if (predicateWithIndex(i, b)) { + right.push(b); + } + else { + left.push(b); + } + } + return (0, Separated_1.separated)(left, right); + }; +}; +exports.partitionWithIndex = partitionWithIndex; /** - * Takes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the - * longer array are discarded + * Given an iterating function that returns an `Either`, + * `partitionMap` applies the iterating function to each element and it creates two `Array`s: + * `right` containing the values of `Right` results, `left` containing the values of `Left` results. * * @example - * import { zip } from 'fp-ts/Array' - * import { pipe } from 'fp-ts/function' + * import { partitionMap } from 'fp-ts/Array' + * import { Either, left, right } from "fp-ts/Either"; * - * assert.deepStrictEqual(pipe([1, 2, 3], zip(['a', 'b', 'c', 'd'])), [[1, 'a'], [2, 'b'], [3, 'c']]) + * const upperIfString = (x: B): Either => + * typeof x === "string" ? right(x.toUpperCase()) : left(x); + * assert.deepStrictEqual(partitionMap(upperIfString)([-2, "hello", 6, 7, "world"]), { + * left: [-2, 6, 7], + * right: [ 'HELLO', 'WORLD' ], + * }); * - * @category combinators + * @category filtering * @since 2.0.0 */ -exports.zip = RA.zip; +var partitionMap = function (f) { return (0, exports.partitionMapWithIndex)(function (_, a) { return f(a); }); }; +exports.partitionMap = partitionMap; /** - * The function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays + * Same as [`partitionMap`](#partitionMap), but passing also the index to the iterating function. * * @example - * import { unzip } from 'fp-ts/Array' + * import { partitionMapWithIndex } from 'fp-ts/Array' + * import { Either, left, right } from "fp-ts/Either"; * - * assert.deepStrictEqual(unzip([[1, 'a'], [2, 'b'], [3, 'c']]), [[1, 2, 3], ['a', 'b', 'c']]) + * const upperIfStringBefore3 = (index: number, x: B): Either => + * index < 3 && typeof x === "string" ? right(x.toUpperCase()) : left(x); + * assert.deepStrictEqual(partitionMapWithIndex(upperIfStringBefore3)([-2, "hello", 6, 7, "world"]), { + * left: [-2, 6, 7, "world"], + * right: ["HELLO"], + * }); * + * @category filtering * @since 2.0.0 */ -exports.unzip = RA.unzip; +var partitionMapWithIndex = function (f) { + return function (fa) { + var left = []; + var right = []; + for (var i = 0; i < fa.length; i++) { + var e = f(i, fa[i]); + if (e._tag === 'Left') { + left.push(e.left); + } + else { + right.push(e.right); + } + } + return (0, Separated_1.separated)(left, right); + }; +}; +exports.partitionMapWithIndex = partitionMapWithIndex; /** - * Prepend an element to every member of an array - * - * @example - * import { prependToAll } from 'fp-ts/Array' - * - * assert.deepStrictEqual(prependToAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4]) + * Less strict version of [`alt`](#alt). * - * @category combinators - * @since 2.9.0 - */ -exports.prependToAll = RA.prependToAll; -/** - * Places an element in between members of an array + * The `W` suffix (short for **W**idening) means that the return types will be merged. * * @example - * import { intersperse } from 'fp-ts/Array' + * import * as A from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4]) + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * A.altW(() => ['a', 'b']) + * ), + * [1, 2, 3, 'a', 'b'] + * ) * - * @category combinators + * @category error handling * @since 2.9.0 */ -exports.intersperse = RA.intersperse; +var altW = function (that) { + return function (fa) { + return fa.concat(that()); + }; +}; +exports.altW = altW; /** - * Rotate an array to the right by `n` steps + * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to + * types of kind `* -> *`. + * + * In case of `Array` concatenates the inputs into a single array. * * @example - * import { rotate } from 'fp-ts/Array' + * import * as A from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3]) + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * A.alt(() => [4, 5]) + * ), + * [1, 2, 3, 4, 5] + * ) * - * @category combinators + * @category error handling * @since 2.0.0 */ -exports.rotate = RA.rotate; -// TODO: remove non-curried overloading in v3 +exports.alt = exports.altW; /** - * Test if a value is a member of an array. Takes a `Eq` as a single - * argument which returns the function to use to search for a value of type `A` in - * an array of type `Array`. + * Same as [`filter`](#filter), but passing also the index to the iterating function. * * @example - * import { elem } from 'fp-ts/Array' - * import { eqNumber } from 'fp-ts/Eq' - * import { pipe } from 'fp-ts/function' + * import { filterWithIndex } from 'fp-ts/Array'; * - * assert.strictEqual(pipe([1, 2, 3], elem(eqNumber)(2)), true) - * assert.strictEqual(pipe([1, 2, 3], elem(eqNumber)(0)), false) + * const f = (index: number, x: number) => x > 0 && index <= 2; + * assert.deepStrictEqual(filterWithIndex(f)([-3, 1, -2, 5]), [1]); * + * @category filtering * @since 2.0.0 */ -exports.elem = RA.elem; +var filterWithIndex = function (predicateWithIndex) { + return function (as) { + return as.filter(function (b, i) { return predicateWithIndex(i, b); }); + }; +}; +exports.filterWithIndex = filterWithIndex; /** - * Remove duplicates from an array, keeping the first occurrence of an element. + * Given an iterating function that takes `Array` as input, `extend` returns + * an array containing the results of the iterating function applied to the whole input + * `Array`, then to the input `Array` without the first element, then to the input + * `Array` without the first two elements, etc. * * @example - * import { uniq } from 'fp-ts/Array' - * import { eqNumber } from 'fp-ts/Eq' + * import { extend } from 'fp-ts/Array' * - * assert.deepStrictEqual(uniq(eqNumber)([1, 2, 1]), [1, 2]) + * const f = (a: string[]) => a.join(","); + * assert.deepStrictEqual(extend(f)(["a", "b", "c"]), ["a,b,c", "b,c", "c"]); * - * @category combinators * @since 2.0.0 */ -exports.uniq = RA.uniq; +var extend = function (f) { return function (wa) { + return wa.map(function (_, i) { return f(wa.slice(i)); }); +}; }; +exports.extend = extend; /** - * Sort the elements of an array in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`, - * etc... + * `duplicate` returns an array containing the whole input `Array`, + * then to the input `Array` dropping the first element, then to the input + * `Array` dropping the first two elements, etc. * * @example - * import { sortBy } from 'fp-ts/Array' - * import { ord, ordString, ordNumber } from 'fp-ts/Ord' - * - * interface Person { - * name: string - * age: number - * } - * const byName = ord.contramap(ordString, (p: Person) => p.name) - * const byAge = ord.contramap(ordNumber, (p: Person) => p.age) - * - * const sortByNameByAge = sortBy([byName, byAge]) + * import { duplicate } from 'fp-ts/Array' * - * const persons = [{ name: 'a', age: 1 }, { name: 'b', age: 3 }, { name: 'c', age: 2 }, { name: 'b', age: 2 }] - * assert.deepStrictEqual(sortByNameByAge(persons), [ - * { name: 'a', age: 1 }, - * { name: 'b', age: 2 }, - * { name: 'b', age: 3 }, - * { name: 'c', age: 2 } - * ]) + * assert.deepStrictEqual(duplicate(["a", "b", "c"]), [["a", "b", "c"], ["b", "c"], ["c"]]); * - * @category combinators * @since 2.0.0 */ -exports.sortBy = RA.sortBy; +exports.duplicate = (0, exports.extend)(function_1.identity); /** - * A useful recursion pattern for processing an array to produce a new array, often used for "chopping" up the input - * array. Typically chop is called with some function that will consume an initial prefix of the array and produce a - * value and the rest of the array. + * Map and fold an `Array`. + * Map the `Array` passing each value to the iterating function. + * Then fold the results using the provided `Monoid`. * * @example - * import { Eq, eqNumber } from 'fp-ts/Eq' - * import { chop, spanLeft } from 'fp-ts/Array' + * import { foldMap } from 'fp-ts/Array' * - * const group = (S: Eq): ((as: Array) => Array>) => { - * return chop(as => { - * const { init, rest } = spanLeft((a: A) => S.equals(a, as[0]))(as) - * return [init, rest] - * }) - * } - * assert.deepStrictEqual(group(eqNumber)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]]) + * const monoid = { concat: (a: string, b: string) => a + b, empty: "" }; + * const f = (s: string) => s.toUpperCase() + * assert.deepStrictEqual(foldMap(monoid)(f)(["a", "b", "c"]), "ABC"); * - * @category combinators + * @category folding * @since 2.0.0 */ -exports.chop = RA.chop; +exports.foldMap = RA.foldMap; /** - * Splits an array into two pieces, the first piece has `n` elements. + * Same as [`foldMap`](#foldMap) but passing also the index to the iterating function. * * @example - * import { splitAt } from 'fp-ts/Array' + * import { foldMapWithIndex } from 'fp-ts/Array' * - * assert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4, 5]]) + * const monoid = { concat: (a: string, b: string) => a + b, empty: "" }; + * const f = (index:number, s: string) => `${s.toUpperCase()}(${index})` + * assert.deepStrictEqual(foldMapWithIndex(monoid)(f)(["a", "b", "c"]), "A(0)B(1)C(2)"); * + * @category folding * @since 2.0.0 */ -exports.splitAt = RA.splitAt; +exports.foldMapWithIndex = RA.foldMapWithIndex; /** - * Splits an array into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of - * the array. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive - * definition of `chunksOf`; it satisfies the property that + * Reduces an `Array`. * - * ```ts - * chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys))) - * ``` + * `reduce` executes the supplied iterating function on each element of the array, + * in order, passing in the element and the return value from the calculation on the preceding element. * - * whenever `n` evenly divides the length of `xs`. + * The first time that the iterating function is called there is no "return value of the + * previous calculation", the initial value is used in its place. * * @example - * import { chunksOf } from 'fp-ts/Array' + * import { reduce } from 'fp-ts/Array' * - * assert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]]) + * assert.deepStrictEqual(reduce(5, (acc: number, cur: number) => acc * cur)([2, 3]), 5 * 2 * 3); * + * @category folding * @since 2.0.0 */ -exports.chunksOf = RA.chunksOf; -function comprehension(input, f, g) { - if (g === void 0) { g = function () { return true; }; } - return RA.comprehension(input, f, g); -} -exports.comprehension = comprehension; -// TODO: remove non-curried overloading in v3 +exports.reduce = RA.reduce; /** - * Creates an array of unique values, in order, from all given arrays using a `Eq` for equality comparisons + * Same as [`reduce`](#reduce) but passing also the index to the iterating function. * * @example - * import { union } from 'fp-ts/Array' - * import { eqNumber } from 'fp-ts/Eq' - * import { pipe } from 'fp-ts/function' + * import { reduceWithIndex } from 'fp-ts/Array' * - * assert.deepStrictEqual(pipe([1, 2], union(eqNumber)([2, 3])), [1, 2, 3]) + * const f = (index: number, acc: string, cur: unknown) => + * acc + (typeof cur === "string" ? cur.toUpperCase() + index : ""); + * assert.deepStrictEqual(reduceWithIndex("", f)([2, "a", "b", null]), "A1B2"); * - * @category combinators + * @category folding * @since 2.0.0 */ -exports.union = RA.union; -// TODO: remove non-curried overloading in v3 +exports.reduceWithIndex = RA.reduceWithIndex; /** - * Creates an array of unique values that are included in all given arrays using a `Eq` for equality - * comparisons. The order and references of result values are determined by the first array. + * Same as [`reduce`](#reduce) but applied from the end to the start. + * + * *Note*: the iterating function in this case takes the accumulator as the last argument. * * @example - * import { intersection } from 'fp-ts/Array' - * import { eqNumber } from 'fp-ts/Eq' - * import { pipe } from 'fp-ts/function' + * import { reduceRight } from 'fp-ts/Array' * - * assert.deepStrictEqual(pipe([1, 2], intersection(eqNumber)([2, 3])), [2]) + * assert.deepStrictEqual(reduceRight("", (cur: string, acc: string) => acc + cur)(["a", "b", "c"]), "cba"); * - * @category combinators + * @category folding * @since 2.0.0 */ -exports.intersection = RA.intersection; -// TODO: remove non-curried overloading in v3 +exports.reduceRight = RA.reduceRight; /** - * Creates an array of array values not included in the other given array using a `Eq` for equality - * comparisons. The order and references of result values are determined by the first array. + * Same as [`reduceRight`](#reduceRight) but passing also the index to the iterating function. * * @example - * import { difference } from 'fp-ts/Array' - * import { eqNumber } from 'fp-ts/Eq' - * import { pipe } from 'fp-ts/function' + * import { reduceRightWithIndex } from 'fp-ts/Array' * - * assert.deepStrictEqual(pipe([1, 2], difference(eqNumber)([2, 3])), [1]) + * const f = (index: number, cur: unknown, acc: string) => + * acc + (typeof cur === "string" ? cur.toUpperCase() + index : ""); + * assert.deepStrictEqual(reduceRightWithIndex("", f)([2, "a", "b", null]), "B2A1"); * - * @category combinators + * @category folding * @since 2.0.0 */ -exports.difference = RA.difference; +exports.reduceRightWithIndex = RA.reduceRightWithIndex; /** - * Wrap a value into the type constructor. + * Given an iterating function that returns a `HKT` (higher kinded type), `traverse` + * applies the iterating function to each element of the `Array` and then [`sequence`](#sequence)-s + * the results using the provided `Applicative`. * - * @category Applicative - * @since 2.0.0 - */ -exports.of = RA.of; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -var map_ = RA.Monad.map; -var ap_ = RA.Monad.ap; -var chain_ = RA.Monad.chain; -var mapWithIndex_ = RA.FunctorWithIndex.mapWithIndex; -var filter_ = RA.Filterable.filter; -var filterMap_ = RA.Filterable.filterMap; -var partition_ = RA.Filterable.partition; -var partitionMap_ = RA.Filterable.partitionMap; -var filterWithIndex_ = RA.FilterableWithIndex - .filterWithIndex; -var filterMapWithIndex_ = RA.FilterableWithIndex - .filterMapWithIndex; -var partitionWithIndex_ = RA.FilterableWithIndex - .partitionWithIndex; -var partitionMapWithIndex_ = RA.FilterableWithIndex - .partitionMapWithIndex; -var reduce_ = RA.Foldable.reduce; -var foldMap_ = RA.Foldable.foldMap; -var reduceRight_ = RA.Foldable.reduceRight; -var traverse_ = RA.Traversable.traverse; -var alt_ = RA.Alternative.alt; -var reduceWithIndex_ = RA.FoldableWithIndex.reduceWithIndex; -var foldMapWithIndex_ = RA.FoldableWithIndex.foldMapWithIndex; -var reduceRightWithIndex_ = RA.FoldableWithIndex.reduceRightWithIndex; -var traverseWithIndex_ = RA.TraversableWithIndex - .traverseWithIndex; -var extend_ = RA.Extend.extend; -var wither_ = RA.Witherable.wither; -var wilt_ = RA.Witherable.wilt; -// ------------------------------------------------------------------------------------- -// pipeables -// ------------------------------------------------------------------------------------- -/** - * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types - * use the type constructor `F` to represent some computational context. + * E.g. suppose you have an `Array` and you want to format each element with a function + * that returns a result or an error as `f = (a: A) => Either`, using `traverse` + * you can apply `f` to all elements and directly obtain as a result an `Either>` + * i.e. an `Array` if all the results are `B`, or an `Error` if some of the results + * are `Error`s. * - * @category Functor - * @since 2.0.0 - */ -exports.map = RA.map; -/** - * Apply a function to an argument under a type constructor. + * @example + * import { traverse } from 'fp-ts/Array' + * import { Applicative, left, right } from "fp-ts/Either"; * - * @category Apply - * @since 2.0.0 + * const f = (x: unknown) => + * typeof x === "string" ? right(x.toUpperCase()) : left(new Error("not a string")); + * assert.deepStrictEqual(traverse(Applicative)(f)(["a", "b"]), right(["A", "B"])); + * assert.deepStrictEqual(traverse(Applicative)(f)(["a", 5]), left(new Error("not a string"))); + * + * @category traversing + * @since 2.6.3 */ -exports.ap = RA.ap; +var traverse = function (F) { + var traverseWithIndexF = (0, exports.traverseWithIndex)(F); + return function (f) { return traverseWithIndexF(function (_, a) { return f(a); }); }; +}; +exports.traverse = traverse; /** - * Combine two effectful actions, keeping only the result of the first. + * `sequence` takes an `Array` where elements are `HKT` (higher kinded type) and, + * using an applicative of that `HKT`, returns an `HKT` of `Array`. + * E.g. it can turn an `Array>` into an `Either>`. * - * Derivable from `Apply`. + * `sequence` requires an `Applicative` of the `HKT` you are targeting, e.g. to turn an + * `Array>` into an `Either>`, it needs an + * `Applicative` for `Either`, to to turn an `Array>` into an `Option>`, + * it needs an `Applicative` for `Option`. * - * @category combinators - * @since 2.0.0 - */ -exports.apFirst = RA.apFirst; -/** - * Combine two effectful actions, keeping only the result of the second. + * @example + * import { sequence } from 'fp-ts/Array' + * import { Applicative, left, right } from "fp-ts/Either"; * - * Derivable from `Apply`. + * assert.deepStrictEqual(sequence(Applicative)([right("a"), right("b")]), right(["a", "b"])); + * assert.deepStrictEqual( + * sequence(Applicative)([right("a"), left(new Error("not a string"))]), + * left(new Error("not a string")) + * ); * - * @category combinators - * @since 2.0.0 + * @category traversing + * @since 2.6.3 */ -exports.apSecond = RA.apSecond; +var sequence = function (F) { + return function (ta) { + return _reduce(ta, F.of((0, exports.zero)()), function (fas, fa) { + return F.ap(F.map(fas, function (as) { return function (a) { return (0, function_1.pipe)(as, (0, exports.append)(a)); }; }), fa); + }); + }; +}; +exports.sequence = sequence; /** - * Composes computations in sequence, using the return value of one computation to determine the next computation. + * Same as [`traverse`](#traverse) but passing also the index to the iterating function. * - * @category Monad - * @since 2.0.0 - */ -exports.chain = RA.chain; -/** - * @since 2.7.0 - */ -exports.chainWithIndex = RA.chainWithIndex; -/** - * Composes computations in sequence, using the return value of one computation to determine the next computation and - * keeping only the result of the first. + * @example + * import { traverseWithIndex } from 'fp-ts/Array' + * import { Applicative, left, right } from "fp-ts/Either"; * - * Derivable from `Monad`. + * const f = (index:number, x:unknown) => + * typeof x === "string" ? right(x.toUpperCase() + index) : left(new Error("not a string")); + * assert.deepStrictEqual(traverseWithIndex(Applicative)(f)(["a", "b"]), right(["A0", "B1"])); + * assert.deepStrictEqual(traverseWithIndex(Applicative)(f)(["a", 5]), left(new Error("not a string"))); * - * @category combinators - * @since 2.0.0 + * @category sequencing + * @since 2.6.3 */ -exports.chainFirst = RA.chainFirst; +var traverseWithIndex = function (F) { + return function (f) { + return (0, exports.reduceWithIndex)(F.of((0, exports.zero)()), function (i, fbs, a) { + return F.ap(F.map(fbs, function (bs) { return function (b) { return (0, function_1.pipe)(bs, (0, exports.append)(b)); }; }), f(i, a)); + }); + }; +}; +exports.traverseWithIndex = traverseWithIndex; /** - * @category FunctorWithIndex - * @since 2.0.0 + * @category filtering + * @since 2.6.5 */ -exports.mapWithIndex = RA.mapWithIndex; +var wither = function (F) { + var _witherF = _wither(F); + return function (f) { return function (fa) { return _witherF(fa, f); }; }; +}; +exports.wither = wither; /** - * @category Compactable - * @since 2.0.0 + * @category filtering + * @since 2.6.5 */ -exports.compact = RA.compact; -/** - * @category Compactable - * @since 2.0.0 - */ -exports.separate = RA.separate; -/** - * @category Filterable - * @since 2.0.0 - */ -exports.filter = RA.filter; -/** - * @category Filterable - * @since 2.0.0 - */ -exports.filterMap = RA.filterMap; -/** - * @category Filterable - * @since 2.0.0 - */ -exports.partition = RA.partition; -/** - * @category FilterableWithIndex - * @since 2.0.0 - */ -exports.partitionWithIndex = RA.partitionWithIndex; -/** - * @category Filterable - * @since 2.0.0 - */ -exports.partitionMap = RA.partitionMap; -/** - * @category FilterableWithIndex - * @since 2.0.0 - */ -exports.partitionMapWithIndex = RA.partitionMapWithIndex; +var wilt = function (F) { + var _wiltF = _wilt(F); + return function (f) { return function (fa) { return _wiltF(fa, f); }; }; +}; +exports.wilt = wilt; /** - * Less strict version of [`alt`](#alt). + * `unfold` takes a function `f` which returns an `Option` of a tuple containing an outcome + * value and an input for the following iteration. + * `unfold` applies `f` to the initial value `b` and then recursively to the second + * element of the tuple contained in the returned `option` of the previous + * calculation until `f` returns `Option.none`. * - * @category Alt - * @since 2.9.0 - */ -exports.altW = RA.altW; -/** - * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to - * types of kind `* -> *`. + * @example + * import { unfold } from 'fp-ts/Array' + * import { option } from 'fp-ts' * - * @category Alt - * @since 2.0.0 - */ -exports.alt = RA.alt; -/** - * @category FilterableWithIndex - * @since 2.0.0 + * const f = (n: number) => { + * if (n <= 0) return option.none; + * const returnValue = n * 2; + * const inputForNextRound = n - 1; + * return option.some([returnValue, inputForNextRound] as const); + * }; + * assert.deepStrictEqual(unfold(5, f), [10, 8, 6, 4, 2]); + * + * @since 2.6.6 */ -exports.filterMapWithIndex = RA.filterMapWithIndex; +var unfold = function (b, f) { + var out = []; + var bb = b; + // eslint-disable-next-line no-constant-condition + while (true) { + var mt = f(bb); + if (_.isSome(mt)) { + var _a = mt.value, a = _a[0], b_1 = _a[1]; + out.push(a); + bb = b_1; + } + else { + break; + } + } + return out; +}; +exports.unfold = unfold; /** - * @category FilterableWithIndex + * @category type lambdas * @since 2.0.0 */ -exports.filterWithIndex = RA.filterWithIndex; +exports.URI = 'Array'; /** - * @category Extend + * `getShow` makes a `Show` for an `Array` from a `Show` for + * an `A`. + * + * @example + * import { getShow } from 'fp-ts/Array' + * + * const numShow = { show: (n: number) => (n >= 0 ? `${n}` : `(${-n})`) }; + * assert.deepStrictEqual(getShow(numShow).show([-2, -1, 0, 1]), "[(2), (1), 0, 1]"); + * + * @category instances * @since 2.0.0 */ -exports.extend = RA.extend; +exports.getShow = RA.getShow; /** - * Derivable from `Extend`. + * Get a `Semigroup` based on the concatenation of `Array`s. + * See also [`getMonoid`](#getMonoid). * - * @category combinators - * @since 2.0.0 + * @example + * import { getSemigroup } from 'fp-ts/Array' + * + * const S = getSemigroup(); + * assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1, 2, 2, 3]); + * + * @category instances + * @since 2.10.0 */ -exports.duplicate = RA.duplicate; +var getSemigroup = function () { return ({ + concat: function (first, second) { return first.concat(second); } +}); }; +exports.getSemigroup = getSemigroup; /** - * @category Foldable + * Returns a `Monoid` for `Array` based on the concatenation of `Array`s. + * + * @example + * import { getMonoid } from 'fp-ts/Array' + * + * const M = getMonoid() + * assert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4]) + * + * @category instances * @since 2.0.0 */ -exports.foldMap = RA.foldMap; +var getMonoid = function () { return ({ + concat: (0, exports.getSemigroup)().concat, + empty: [] +}); }; +exports.getMonoid = getMonoid; /** - * @category FoldableWithIndex + * Derives an `Eq` over the `Array` of a given element type from the `Eq` of that type. The derived `Eq` defines two + * arrays as equal if all elements of both arrays are compared equal pairwise with the given `E`. In case of arrays of + * different lengths, the result is non equality. + * + * @example + * import * as S from 'fp-ts/string' + * import { getEq } from 'fp-ts/Array' + * + * const E = getEq(S.Eq) + * assert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true) + * assert.strictEqual(E.equals(['a'], []), false) + * + * @category instances * @since 2.0.0 */ -exports.foldMapWithIndex = RA.foldMapWithIndex; +exports.getEq = RA.getEq; /** - * @category Foldable + * Derives an `Ord` over the `Array` of a given element type from the `Ord` of that type. The ordering between two such + * arrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in + * case of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have + * the same length, the result is equality. + * + * @example + * import { getOrd } from 'fp-ts/Array' + * import * as S from 'fp-ts/string' + * + * const O = getOrd(S.Ord) + * assert.strictEqual(O.compare(['b'], ['a']), 1) + * assert.strictEqual(O.compare(['a'], ['a']), 0) + * assert.strictEqual(O.compare(['a'], ['b']), -1) + * + * @category instances * @since 2.0.0 */ -exports.reduce = RA.reduce; +exports.getOrd = RA.getOrd; /** - * @category FoldableWithIndex - * @since 2.0.0 + * Get a `Semigroup` based on the union of the elements of `Array`s. + * Elements which equal according to the provided `Eq` are included + * only once in the result. + * See also [`getUnionMonoid`](#getUnionMonoid). + * + * @example + * import { getUnionSemigroup } from 'fp-ts/Array'; + * import { Eq } from 'fp-ts/number'; + * + * const S = getUnionSemigroup(Eq); + * assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1, 2, 3]); + * + * @category instances + * @since 2.11.0 */ -exports.reduceWithIndex = RA.reduceWithIndex; +var getUnionSemigroup = function (E) { + var unionE = union(E); + return { + concat: function (first, second) { return unionE(second)(first); } + }; +}; +exports.getUnionSemigroup = getUnionSemigroup; /** - * @category Foldable - * @since 2.0.0 + * Get a `Monoid` based on the union of the elements of `Array`s. + * Elements which equal according to the provided `Eq` are included + * only once in the result. + * + * @example + * import { getUnionMonoid } from 'fp-ts/Array' + * import { Eq } from 'fp-ts/number'; + * + * const M = getUnionMonoid(Eq); + * assert.deepStrictEqual(M.concat([1, 2], [2, 3]), [1, 2, 3]); + * assert.deepStrictEqual(M.empty,[]); + * + * @category instances + * @since 2.11.0 */ -exports.reduceRight = RA.reduceRight; +var getUnionMonoid = function (E) { return ({ + concat: (0, exports.getUnionSemigroup)(E).concat, + empty: [] +}); }; +exports.getUnionMonoid = getUnionMonoid; /** - * @category FoldableWithIndex - * @since 2.0.0 + * Get a `Semigroup` based on the intersection of the elements of `Array`s. + * Only elements present in the two arrays which are equal according to the + * provided `Eq` are included in the result. + * + * @example + * import { getIntersectionSemigroup } from 'fp-ts/Array' + * import { Eq } from 'fp-ts/number'; + * + * const S = getIntersectionSemigroup(Eq); + * assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [2]); + * + * @category instances + * @since 2.11.0 */ -exports.reduceRightWithIndex = RA.reduceRightWithIndex; +var getIntersectionSemigroup = function (E) { + var intersectionE = intersection(E); + return { + concat: function (first, second) { return intersectionE(second)(first); } + }; +}; +exports.getIntersectionSemigroup = getIntersectionSemigroup; /** - * **for optimized and stack safe version check the data types `traverseArray` function** - * @category Traversable - * @since 2.6.3 + * Get a `Magma` for `Array` where the `concat` function is the differnce between + * the first and the second array, i.e. the result contains all the elements of the + * first array for which their is no equal element in the second array according + * to the `Eq` provided. + * + * + * @example + * import { getDifferenceMagma } from 'fp-ts/Array' + * import { Eq } from 'fp-ts/number'; + * + * const S = getDifferenceMagma(Eq); + * assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1]); + * + * @category instances + * @since 2.11.0 */ -exports.traverse = RA.traverse; +var getDifferenceMagma = function (E) { + var differenceE = difference(E); + return { + concat: function (first, second) { return differenceE(second)(first); } + }; +}; +exports.getDifferenceMagma = getDifferenceMagma; /** - * **for optimized and stack safe version check the data types `sequenceArray` function** - * @category Traversable - * @since 2.6.3 + * @category instances + * @since 2.7.0 */ -exports.sequence = RA.sequence; +exports.Functor = { + URI: exports.URI, + map: _map +}; /** - * **for optimized and stack safe version check the data types `traverseArrayWithIndex` function** - * @category TraversableWithIndex - * @since 2.6.3 + * Given an input an `Array` of functions, `flap` returns an `Array` containing + * the results of applying each function to the given input. + * + * @example + * import { flap } from 'fp-ts/Array' + * + * const funs = [ + * (n: number) => `Double: ${n * 2}`, + * (n: number) => `Triple: ${n * 3}`, + * (n: number) => `Square: ${n * n}`, + * ]; + * assert.deepStrictEqual(flap(4)(funs), ['Double: 8', 'Triple: 12', 'Square: 16']); + * + * @category mapping + * @since 2.10.0 */ -exports.traverseWithIndex = RA.traverseWithIndex; +exports.flap = (0, Functor_1.flap)(exports.Functor); /** - * @category Witherable - * @since 2.6.5 + * @category instances + * @since 2.10.0 */ -exports.wither = RA.wither; +exports.Pointed = { + URI: exports.URI, + of: exports.of +}; /** - * @category Witherable - * @since 2.6.5 + * @category instances + * @since 2.7.0 */ -exports.wilt = RA.wilt; +exports.FunctorWithIndex = { + URI: exports.URI, + map: _map, + mapWithIndex: _mapWithIndex +}; /** - * @category Unfoldable - * @since 2.6.6 + * @category instances + * @since 2.10.0 */ -exports.unfold = RA.unfold; +exports.Apply = { + URI: exports.URI, + map: _map, + ap: _ap +}; /** - * @category Alternative - * @since 2.7.0 + * Combine two effectful actions, keeping only the result of the first. + * + * @since 2.5.0 */ -exports.zero = RA.Alternative.zero; -// ------------------------------------------------------------------------------------- -// instances -// ------------------------------------------------------------------------------------- +exports.apFirst = (0, Apply_1.apFirst)(exports.Apply); /** - * @category instances - * @since 2.0.0 + * Combine two effectful actions, keeping only the result of the second. + * + * @since 2.5.0 */ -exports.URI = 'Array'; +exports.apSecond = (0, Apply_1.apSecond)(exports.Apply); /** * @category instances * @since 2.7.0 */ -exports.Functor = { +exports.Applicative = { URI: exports.URI, - map: map_ + map: _map, + ap: _ap, + of: exports.of }; /** * @category instances - * @since 2.7.0 + * @since 2.10.0 */ -exports.FunctorWithIndex = { +exports.Chain = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_ + map: _map, + ap: _ap, + chain: exports.flatMap }; /** - * @category instances - * @since 2.7.0 + * Composes computations in sequence, using the return value of one computation to determine the next computation and + * keeping only the result of the first. + * + * @example + * import * as A from 'fp-ts/Array' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * A.chainFirst(() => ['a', 'b']) + * ), + * [1, 1, 2, 2, 3, 3] + * ) + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * A.chainFirst(() => []) + * ), + * [] + * ) + * + * @category sequencing + * @since 2.0.0 */ -exports.Applicative = { - URI: exports.URI, - map: map_, - ap: ap_, - of: exports.of -}; +exports.chainFirst = +/*#__PURE__*/ (0, Chain_1.chainFirst)(exports.Chain); /** * @category instances * @since 2.7.0 */ exports.Monad = { URI: exports.URI, - map: map_, - ap: ap_, + map: _map, + ap: _ap, of: exports.of, - chain: chain_ + chain: exports.flatMap }; /** * @category instances @@ -7561,19 +9736,32 @@ exports.Unfoldable = { */ exports.Alt = { URI: exports.URI, - map: map_, - alt: alt_ + map: _map, + alt: _alt +}; +/** + * @category instances + * @since 2.11.0 + */ +exports.Zero = { + URI: exports.URI, + zero: exports.zero }; +/** + * @category do notation + * @since 2.11.0 + */ +exports.guard = (0, Zero_1.guard)(exports.Zero, exports.Pointed); /** * @category instances * @since 2.7.0 */ exports.Alternative = { URI: exports.URI, - map: map_, - ap: ap_, + map: _map, + ap: _ap, of: exports.of, - alt: alt_, + alt: _alt, zero: exports.zero }; /** @@ -7582,8 +9770,8 @@ exports.Alternative = { */ exports.Extend = { URI: exports.URI, - map: map_, - extend: extend_ + map: _map, + extend: _extend }; /** * @category instances @@ -7600,13 +9788,13 @@ exports.Compactable = { */ exports.Filterable = { URI: exports.URI, - map: map_, + map: _map, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_ + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap }; /** * @category instances @@ -7614,18 +9802,18 @@ exports.Filterable = { */ exports.FilterableWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, + map: _map, + mapWithIndex: _mapWithIndex, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - partitionMapWithIndex: partitionMapWithIndex_, - partitionWithIndex: partitionWithIndex_, - filterMapWithIndex: filterMapWithIndex_, - filterWithIndex: filterWithIndex_ + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + partitionMapWithIndex: _partitionMapWithIndex, + partitionWithIndex: _partitionWithIndex, + filterMapWithIndex: _filterMapWithIndex, + filterWithIndex: _filterWithIndex }; /** * @category instances @@ -7633,9 +9821,9 @@ exports.FilterableWithIndex = { */ exports.Foldable = { URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_ + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight }; /** * @category instances @@ -7643,12 +9831,12 @@ exports.Foldable = { */ exports.FoldableWithIndex = { URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_ + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex }; /** * @category instances @@ -7656,11 +9844,11 @@ exports.FoldableWithIndex = { */ exports.Traversable = { URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: _map, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, sequence: exports.sequence }; /** @@ -7669,77 +9857,92 @@ exports.Traversable = { */ exports.TraversableWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverse: traverse_, + map: _map, + mapWithIndex: _mapWithIndex, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex, + traverse: _traverse, sequence: exports.sequence, - traverseWithIndex: traverseWithIndex_ + traverseWithIndex: _traverseWithIndex }; +var _wither = /*#__PURE__*/ (0, Witherable_1.witherDefault)(exports.Traversable, exports.Compactable); +var _wilt = /*#__PURE__*/ (0, Witherable_1.wiltDefault)(exports.Traversable, exports.Compactable); /** * @category instances * @since 2.7.0 */ exports.Witherable = { URI: exports.URI, - map: map_, + map: _map, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, sequence: exports.sequence, - wither: wither_, - wilt: wilt_ + wither: _wither, + wilt: _wilt }; -// TODO: remove in v3 +/** + * @category sequencing + * @since 2.11.0 + */ +exports.chainRecDepthFirst = RA.chainRecDepthFirst; /** * @category instances - * @since 2.0.0 + * @since 2.11.0 */ -exports.array = { +exports.ChainRecDepthFirst = { URI: exports.URI, - compact: exports.compact, - separate: exports.separate, - map: map_, - ap: ap_, - of: exports.of, - chain: chain_, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - mapWithIndex: mapWithIndex_, - partitionMapWithIndex: partitionMapWithIndex_, - partitionWithIndex: partitionWithIndex_, - filterMapWithIndex: filterMapWithIndex_, - filterWithIndex: filterWithIndex_, - alt: alt_, - zero: exports.zero, - unfold: exports.unfold, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: exports.sequence, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverseWithIndex: traverseWithIndex_, - extend: extend_, - wither: wither_, - wilt: wilt_ + map: _map, + ap: _ap, + chain: exports.flatMap, + chainRec: _chainRecDepthFirst +}; +/** + * @category sequencing + * @since 2.11.0 + */ +exports.chainRecBreadthFirst = RA.chainRecBreadthFirst; +/** + * @category instances + * @since 2.11.0 + */ +exports.ChainRecBreadthFirst = { + URI: exports.URI, + map: _map, + ap: _ap, + chain: exports.flatMap, + chainRec: _chainRecBreadthFirst +}; +/** + * Filter values inside a context. + * + * @since 2.11.0 + */ +exports.filterE = (0, Witherable_1.filterE)(exports.Witherable); +/** + * @category instances + * @since 2.11.0 + */ +exports.FromEither = { + URI: exports.URI, + fromEither: exports.fromEither }; +/** + * @category lifting + * @since 2.11.0 + */ +exports.fromEitherK = (0, FromEither_1.fromEitherK)(exports.FromEither); // ------------------------------------------------------------------------------------- // unsafe // ------------------------------------------------------------------------------------- @@ -7747,58 +9950,223 @@ exports.array = { * @category unsafe * @since 2.0.0 */ -exports.unsafeInsertAt = RA.unsafeInsertAt; +exports.unsafeInsertAt = NEA.unsafeInsertAt; /** * @category unsafe * @since 2.0.0 */ -exports.unsafeUpdateAt = RA.unsafeUpdateAt; +var unsafeUpdateAt = function (i, a, as) { + return (0, exports.isNonEmpty)(as) ? NEA.unsafeUpdateAt(i, a, as) : []; +}; +exports.unsafeUpdateAt = unsafeUpdateAt; /** * @category unsafe * @since 2.0.0 */ -exports.unsafeDeleteAt = RA.unsafeDeleteAt; +var unsafeDeleteAt = function (i, as) { + var xs = as.slice(); + xs.splice(i, 1); + return xs; +}; +exports.unsafeDeleteAt = unsafeDeleteAt; // ------------------------------------------------------------------------------------- // utils // ------------------------------------------------------------------------------------- /** - * An empty array + * `every` tells if the provided predicate holds true for every element in the `Array`. + * + * @example + * import { every } from 'fp-ts/Array' + * + * assert.equal(every((x: number) => x >= 0)([1, 2, 3]), true); + * assert.equal(every((x: number) => x >= 0)([-1, 2, 3]), false); * - * @since 2.0.0 - */ -exports.empty = []; -/** * @since 2.9.0 */ exports.every = RA.every; /** + * `some` tells if the provided predicate holds true at least for one element in the `Array`. + * + * @example + * import { some } from 'fp-ts/Array' + * + * assert.equal(some((x: number) => x >= 0)([1, 2, 3]), true); + * assert.equal(some((x: number) => x >= 10)([1, 2, 3]), false); + * * @since 2.9.0 */ -exports.some = RA.some; +var some = function (predicate) { + return function (as) { + return as.some(predicate); + }; +}; +exports.some = some; +/** + * Alias of [`some`](#some) + * + * @since 2.11.0 + */ +exports.exists = exports.some; +/** + * Places an element in between members of an `Array`, then folds the results using the provided `Monoid`. + * + * @example + * import * as S from 'fp-ts/string' + * import { intercalate } from 'fp-ts/Array' + * + * assert.deepStrictEqual(intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c') + * + * @since 2.12.0 + */ +exports.intercalate = RA.intercalate; // ------------------------------------------------------------------------------------- // do notation // ------------------------------------------------------------------------------------- /** + * @category do notation * @since 2.9.0 */ -exports.Do = -/*#__PURE__*/ -exports.of({}); +exports.Do = (0, exports.of)(_.emptyRecord); +/** + * @category do notation + * @since 2.8.0 + */ +exports.bindTo = (0, Functor_1.bindTo)(exports.Functor); +var let_ = /*#__PURE__*/ (0, Functor_1.let)(exports.Functor); +exports["let"] = let_; /** + * @category do notation * @since 2.8.0 */ -exports.bindTo = RA.bindTo; +exports.bind = (0, Chain_1.bind)(exports.Chain); /** + * @category do notation * @since 2.8.0 */ -exports.bind = RA.bind; +exports.apS = (0, Apply_1.apS)(exports.Apply); // ------------------------------------------------------------------------------------- -// pipeable sequence S +// legacy // ------------------------------------------------------------------------------------- /** - * @since 2.8.0 + * Alias of `flatMap`. + * + * @category legacy + * @since 2.0.0 + */ +exports.chain = exports.flatMap; +// ------------------------------------------------------------------------------------- +// deprecated +// ------------------------------------------------------------------------------------- +/** + * Use `NonEmptyArray` module instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.range = NEA.range; +/** + * Use a new `[]` instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.empty = []; +/** + * Use `prepend` instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.cons = NEA.cons; +/** + * Use `append` instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.snoc = NEA.snoc; +/** + * Use `prependAll` instead + * + * @category zone of death + * @since 2.9.0 + * @deprecated */ -exports.apS = RA.apS; +exports.prependToAll = exports.prependAll; +/** + * This instance is deprecated, use small, specific instances instead. + * For example if a function needs a `Functor` instance, pass `A.Functor` instead of `A.array` + * (where `A` is from `import A from 'fp-ts/Array'`) + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.array = { + URI: exports.URI, + compact: exports.compact, + separate: exports.separate, + map: _map, + ap: _ap, + of: exports.of, + chain: exports.flatMap, + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + mapWithIndex: _mapWithIndex, + partitionMapWithIndex: _partitionMapWithIndex, + partitionWithIndex: _partitionWithIndex, + filterMapWithIndex: _filterMapWithIndex, + filterWithIndex: _filterWithIndex, + alt: _alt, + zero: exports.zero, + unfold: exports.unfold, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, + sequence: exports.sequence, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex, + traverseWithIndex: _traverseWithIndex, + extend: _extend, + wither: _wither, + wilt: _wilt +}; + + +/***/ }), + +/***/ 2372: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.bind = exports.tap = exports.chainFirst = void 0; +function chainFirst(M) { + var tapM = tap(M); + return function (f) { return function (first) { return tapM(first, f); }; }; +} +exports.chainFirst = chainFirst; +/** @internal */ +function tap(M) { + return function (first, f) { return M.chain(first, function (a) { return M.map(f(a), function () { return a; }); }); }; +} +exports.tap = tap; +function bind(M) { + return function (name, f) { return function (ma) { return M.chain(ma, function (a) { return M.map(f(a), function (b) { + var _a; + return Object.assign({}, a, (_a = {}, _a[name] = b, _a)); + }); }); }; }; +} +exports.bind = bind; /***/ }), @@ -7813,47 +10181,60 @@ exports.tailRec = void 0; /** * @since 2.0.0 */ -function tailRec(a, f) { - var v = f(a); - while (v._tag === 'Left') { - v = f(v.left); +var tailRec = function (startWith, f) { + var ab = f(startWith); + while (ab._tag === 'Left') { + ab = f(ab.left); } - return v.right; -} + return ab.right; +}; exports.tailRec = tailRec; /***/ }), /***/ 7534: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getWitherable = exports.getFilterable = exports.getApplyMonoid = exports.getApplySemigroup = exports.getSemigroup = exports.getEq = exports.getShow = exports.URI = exports.throwError = exports.sequence = exports.traverse = exports.reduceRight = exports.foldMap = exports.reduce = exports.duplicate = exports.extend = exports.alt = exports.altW = exports.flatten = exports.chainFirst = exports.chainFirstW = exports.chain = exports.chainW = exports.of = exports.apSecond = exports.apFirst = exports.ap = exports.apW = exports.mapLeft = exports.bimap = exports.map = exports.filterOrElse = exports.filterOrElseW = exports.orElse = exports.swap = exports.chainNullableK = exports.fromNullableK = exports.getOrElse = exports.getOrElseW = exports.fold = exports.fromPredicate = exports.fromOption = exports.stringifyJSON = exports.parseJSON = exports.tryCatch = exports.fromNullable = exports.right = exports.left = exports.isRight = exports.isLeft = void 0; -exports.sequenceArray = exports.traverseArray = exports.traverseArrayWithIndex = exports.apS = exports.apSW = exports.bind = exports.bindW = exports.bindTo = exports.Do = exports.exists = exports.elem = exports.toError = exports.either = exports.getValidationMonoid = exports.MonadThrow = exports.ChainRec = exports.Extend = exports.Alt = exports.Bifunctor = exports.Traversable = exports.Foldable = exports.Monad = exports.Applicative = exports.Functor = exports.getValidationSemigroup = exports.getValidation = exports.getAltValidation = exports.getApplicativeValidation = void 0; +exports.match = exports.foldW = exports.matchW = exports.isRight = exports.isLeft = exports.fromOption = exports.fromPredicate = exports.FromEither = exports.MonadThrow = exports.throwError = exports.ChainRec = exports.Extend = exports.extend = exports.Alt = exports.alt = exports.altW = exports.Bifunctor = exports.mapLeft = exports.bimap = exports.Traversable = exports.sequence = exports.traverse = exports.Foldable = exports.reduceRight = exports.foldMap = exports.reduce = exports.Monad = exports.Chain = exports.Applicative = exports.Apply = exports.ap = exports.apW = exports.Pointed = exports.of = exports.asUnit = exports.as = exports.Functor = exports.map = exports.getAltValidation = exports.getApplicativeValidation = exports.getWitherable = exports.getFilterable = exports.getCompactable = exports.getSemigroup = exports.getEq = exports.getShow = exports.URI = exports.flatMap = exports.right = exports.left = void 0; +exports.chainFirstW = exports.chainFirst = exports.chain = exports.chainW = exports.sequenceArray = exports.traverseArray = exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndex = exports.traverseReadonlyNonEmptyArrayWithIndex = exports.ApT = exports.apSW = exports.apS = exports.bindW = exports.bind = exports["let"] = exports.bindTo = exports.Do = exports.exists = exports.elem = exports.toError = exports.toUnion = exports.chainNullableK = exports.fromNullableK = exports.tryCatchK = exports.tryCatch = exports.fromNullable = exports.orElse = exports.orElseW = exports.swap = exports.filterOrElseW = exports.filterOrElse = exports.flatMapOption = exports.flatMapNullable = exports.liftOption = exports.liftNullable = exports.chainOptionKW = exports.chainOptionK = exports.fromOptionK = exports.duplicate = exports.flatten = exports.flattenW = exports.tap = exports.apSecondW = exports.apSecond = exports.apFirstW = exports.apFirst = exports.flap = exports.getOrElse = exports.getOrElseW = exports.fold = void 0; +exports.getValidation = exports.getValidationMonoid = exports.getValidationSemigroup = exports.getApplyMonoid = exports.getApplySemigroup = exports.either = exports.stringifyJSON = exports.parseJSON = void 0; +var Applicative_1 = __nccwpck_require__(4766); +var Apply_1 = __nccwpck_require__(205); +var chainable = __importStar(__nccwpck_require__(2372)); var ChainRec_1 = __nccwpck_require__(5322); +var FromEither_1 = __nccwpck_require__(1964); var function_1 = __nccwpck_require__(6985); -// ------------------------------------------------------------------------------------- -// guards -// ------------------------------------------------------------------------------------- -/** - * Returns `true` if the either is an instance of `Left`, `false` otherwise. - * - * @category guards - * @since 2.0.0 - */ -var isLeft = function (ma) { return ma._tag === 'Left'; }; -exports.isLeft = isLeft; -/** - * Returns `true` if the either is an instance of `Right`, `false` otherwise. - * - * @category guards - * @since 2.0.0 - */ -var isRight = function (ma) { return ma._tag === 'Right'; }; -exports.isRight = isRight; +var Functor_1 = __nccwpck_require__(5533); +var _ = __importStar(__nccwpck_require__(1840)); +var Separated_1 = __nccwpck_require__(5877); +var Witherable_1 = __nccwpck_require__(4384); // ------------------------------------------------------------------------------------- // constructors // ------------------------------------------------------------------------------------- @@ -7864,8 +10245,7 @@ exports.isRight = isRight; * @category constructors * @since 2.0.0 */ -var left = function (e) { return ({ _tag: 'Left', left: e }); }; -exports.left = left; +exports.left = _.left; /** * Constructs a new `Either` holding a `Right` value. This usually represents a successful value due to the right bias * of this structure. @@ -7873,553 +10253,391 @@ exports.left = left; * @category constructors * @since 2.0.0 */ -var right = function (a) { return ({ _tag: 'Right', right: a }); }; -exports.right = right; -// TODO: make lazy in v3 +exports.right = _.right; /** - * Takes a default and a nullable value, if the value is not nully, turn it into a `Right`, if the value is nully use - * the provided default as a `Left`. - * - * @example - * import { fromNullable, left, right } from 'fp-ts/Either' - * - * const parse = fromNullable('nully') - * - * assert.deepStrictEqual(parse(1), right(1)) - * assert.deepStrictEqual(parse(null), left('nully')) - * - * @category constructors + * @category sequencing + * @since 2.14.0 + */ +exports.flatMap = (0, function_1.dual)(2, function (ma, f) { return ((0, exports.isLeft)(ma) ? ma : f(ma.right)); }); +var _map = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }; +var _ap = function (fab, fa) { return (0, function_1.pipe)(fab, (0, exports.ap)(fa)); }; +/* istanbul ignore next */ +var _reduce = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduce)(b, f)); }; +/* istanbul ignore next */ +var _foldMap = function (M) { return function (fa, f) { + var foldMapM = (0, exports.foldMap)(M); + return (0, function_1.pipe)(fa, foldMapM(f)); +}; }; +/* istanbul ignore next */ +var _reduceRight = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduceRight)(b, f)); }; +var _traverse = function (F) { + var traverseF = (0, exports.traverse)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseF(f)); }; +}; +var _bimap = function (fa, f, g) { return (0, function_1.pipe)(fa, (0, exports.bimap)(f, g)); }; +var _mapLeft = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.mapLeft)(f)); }; +/* istanbul ignore next */ +var _alt = function (fa, that) { return (0, function_1.pipe)(fa, (0, exports.alt)(that)); }; +/* istanbul ignore next */ +var _extend = function (wa, f) { return (0, function_1.pipe)(wa, (0, exports.extend)(f)); }; +var _chainRec = function (a, f) { + return (0, ChainRec_1.tailRec)(f(a), function (e) { + return (0, exports.isLeft)(e) ? (0, exports.right)((0, exports.left)(e.left)) : (0, exports.isLeft)(e.right) ? (0, exports.left)(f(e.right.left)) : (0, exports.right)((0, exports.right)(e.right.right)); + }); +}; +/** + * @category type lambdas * @since 2.0.0 */ -function fromNullable(e) { - return function (a) { return (a == null ? exports.left(e) : exports.right(a)); }; -} -exports.fromNullable = fromNullable; -// TODO: `onError => Lazy => Either` in v3 +exports.URI = 'Either'; /** - * Constructs a new `Either` from a function that might throw. - * - * @example - * import { Either, left, right, tryCatch } from 'fp-ts/Either' - * - * const unsafeHead = (as: Array): A => { - * if (as.length > 0) { - * return as[0] - * } else { - * throw new Error('empty array') - * } - * } - * - * const head = (as: Array): Either => { - * return tryCatch(() => unsafeHead(as), e => (e instanceof Error ? e : new Error('unknown error'))) - * } - * - * assert.deepStrictEqual(head([]), left(new Error('empty array'))) - * assert.deepStrictEqual(head([1, 2, 3]), right(1)) - * - * @category constructors + * @category instances * @since 2.0.0 */ -function tryCatch(f, onError) { - try { - return exports.right(f()); - } - catch (e) { - return exports.left(onError(e)); +var getShow = function (SE, SA) { return ({ + show: function (ma) { return ((0, exports.isLeft)(ma) ? "left(".concat(SE.show(ma.left), ")") : "right(".concat(SA.show(ma.right), ")")); } +}); }; +exports.getShow = getShow; +/** + * @category instances + * @since 2.0.0 + */ +var getEq = function (EL, EA) { return ({ + equals: function (x, y) { + return x === y || ((0, exports.isLeft)(x) ? (0, exports.isLeft)(y) && EL.equals(x.left, y.left) : (0, exports.isRight)(y) && EA.equals(x.right, y.right)); } -} -exports.tryCatch = tryCatch; -// TODO curry in v3 +}); }; +exports.getEq = getEq; /** - * Converts a JavaScript Object Notation (JSON) string into an object. + * Semigroup returning the left-most non-`Left` value. If both operands are `Right`s then the inner values are + * concatenated using the provided `Semigroup` * * @example - * import { parseJSON, toError, right, left } from 'fp-ts/Either' + * import { getSemigroup, left, right } from 'fp-ts/Either' + * import { SemigroupSum } from 'fp-ts/number' * - * assert.deepStrictEqual(parseJSON('{"a":1}', toError), right({ a: 1 })) - * assert.deepStrictEqual(parseJSON('{"a":}', toError), left(new SyntaxError('Unexpected token } in JSON at position 5'))) + * const S = getSemigroup(SemigroupSum) + * assert.deepStrictEqual(S.concat(left('a'), left('b')), left('a')) + * assert.deepStrictEqual(S.concat(left('a'), right(2)), right(2)) + * assert.deepStrictEqual(S.concat(right(1), left('b')), right(1)) + * assert.deepStrictEqual(S.concat(right(1), right(2)), right(3)) * - * @category constructors + * @category instances * @since 2.0.0 */ -function parseJSON(s, onError) { - return tryCatch(function () { return JSON.parse(s); }, onError); -} -exports.parseJSON = parseJSON; -// TODO curry in v3 +var getSemigroup = function (S) { return ({ + concat: function (x, y) { return ((0, exports.isLeft)(y) ? x : (0, exports.isLeft)(x) ? y : (0, exports.right)(S.concat(x.right, y.right))); } +}); }; +exports.getSemigroup = getSemigroup; /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * Builds a `Compactable` instance for `Either` given `Monoid` for the left side. * - * @example - * import * as E from 'fp-ts/Either' - * import { pipe } from 'fp-ts/function' + * @category filtering + * @since 2.10.0 + */ +var getCompactable = function (M) { + var empty = (0, exports.left)(M.empty); + return { + URI: exports.URI, + _E: undefined, + compact: function (ma) { return ((0, exports.isLeft)(ma) ? ma : ma.right._tag === 'None' ? empty : (0, exports.right)(ma.right.value)); }, + separate: function (ma) { + return (0, exports.isLeft)(ma) + ? (0, Separated_1.separated)(ma, ma) + : (0, exports.isLeft)(ma.right) + ? (0, Separated_1.separated)((0, exports.right)(ma.right.left), empty) + : (0, Separated_1.separated)(empty, (0, exports.right)(ma.right.right)); + } + }; +}; +exports.getCompactable = getCompactable; +/** + * Builds a `Filterable` instance for `Either` given `Monoid` for the left side * - * assert.deepStrictEqual(E.stringifyJSON({ a: 1 }, E.toError), E.right('{"a":1}')) - * const circular: any = { ref: null } - * circular.ref = circular - * assert.deepStrictEqual( - * pipe( - * E.stringifyJSON(circular, E.toError), - * E.mapLeft(e => e.message.includes('Converting circular structure to JSON')) - * ), - * E.left(true) - * ) + * @category filtering + * @since 2.10.0 + */ +var getFilterable = function (M) { + var empty = (0, exports.left)(M.empty); + var _a = (0, exports.getCompactable)(M), compact = _a.compact, separate = _a.separate; + var filter = function (ma, predicate) { + return (0, exports.isLeft)(ma) ? ma : predicate(ma.right) ? ma : empty; + }; + var partition = function (ma, p) { + return (0, exports.isLeft)(ma) + ? (0, Separated_1.separated)(ma, ma) + : p(ma.right) + ? (0, Separated_1.separated)(empty, (0, exports.right)(ma.right)) + : (0, Separated_1.separated)((0, exports.right)(ma.right), empty); + }; + return { + URI: exports.URI, + _E: undefined, + map: _map, + compact: compact, + separate: separate, + filter: filter, + filterMap: function (ma, f) { + if ((0, exports.isLeft)(ma)) { + return ma; + } + var ob = f(ma.right); + return ob._tag === 'None' ? empty : (0, exports.right)(ob.value); + }, + partition: partition, + partitionMap: function (ma, f) { + if ((0, exports.isLeft)(ma)) { + return (0, Separated_1.separated)(ma, ma); + } + var e = f(ma.right); + return (0, exports.isLeft)(e) ? (0, Separated_1.separated)((0, exports.right)(e.left), empty) : (0, Separated_1.separated)(empty, (0, exports.right)(e.right)); + } + }; +}; +exports.getFilterable = getFilterable; +/** + * Builds `Witherable` instance for `Either` given `Monoid` for the left side * - * @category constructors + * @category filtering * @since 2.0.0 */ -function stringifyJSON(u, onError) { - return tryCatch(function () { return JSON.stringify(u); }, onError); -} -exports.stringifyJSON = stringifyJSON; +var getWitherable = function (M) { + var F_ = (0, exports.getFilterable)(M); + var C = (0, exports.getCompactable)(M); + return { + URI: exports.URI, + _E: undefined, + map: _map, + compact: F_.compact, + separate: F_.separate, + filter: F_.filter, + filterMap: F_.filterMap, + partition: F_.partition, + partitionMap: F_.partitionMap, + traverse: _traverse, + sequence: exports.sequence, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + wither: (0, Witherable_1.witherDefault)(exports.Traversable, C), + wilt: (0, Witherable_1.wiltDefault)(exports.Traversable, C) + }; +}; +exports.getWitherable = getWitherable; /** - * Derivable from `MonadThrow`. + * The default [`Applicative`](#applicative) instance returns the first error, if you want to + * get all errors you need to provide a way to concatenate them via a `Semigroup`. * * @example - * import { fromOption, left, right } from 'fp-ts/Either' + * import * as A from 'fp-ts/Apply' + * import * as E from 'fp-ts/Either' * import { pipe } from 'fp-ts/function' - * import { none, some } from 'fp-ts/Option' + * import * as S from 'fp-ts/Semigroup' + * import * as string from 'fp-ts/string' * - * assert.deepStrictEqual( - * pipe( - * some(1), - * fromOption(() => 'error') - * ), - * right(1) - * ) - * assert.deepStrictEqual( - * pipe( - * none, - * fromOption(() => 'error') - * ), - * left('error') - * ) + * const parseString = (u: unknown): E.Either => + * typeof u === 'string' ? E.right(u) : E.left('not a string') * - * @category constructors - * @since 2.0.0 - */ -var fromOption = function (onNone) { return function (ma) { - return ma._tag === 'None' ? exports.left(onNone()) : exports.right(ma.value); -}; }; -exports.fromOption = fromOption; -/** - * Derivable from `MonadThrow`. + * const parseNumber = (u: unknown): E.Either => + * typeof u === 'number' ? E.right(u) : E.left('not a number') * - * @example - * import { fromPredicate, left, right } from 'fp-ts/Either' - * import { pipe } from 'fp-ts/function' + * interface Person { + * readonly name: string + * readonly age: number + * } * - * assert.deepStrictEqual( - * pipe( - * 1, - * fromPredicate( - * (n) => n > 0, - * () => 'error' - * ) - * ), - * right(1) - * ) - * assert.deepStrictEqual( + * const parsePerson = ( + * input: Record + * ): E.Either => * pipe( - * -1, - * fromPredicate( - * (n) => n > 0, - * () => 'error' - * ) - * ), - * left('error') - * ) - * - * @category constructors - * @since 2.0.0 - */ -var fromPredicate = function (predicate, onFalse) { return function (a) { return (predicate(a) ? exports.right(a) : exports.left(onFalse(a))); }; }; -exports.fromPredicate = fromPredicate; -// ------------------------------------------------------------------------------------- -// destructors -// ------------------------------------------------------------------------------------- -/** - * Takes two functions and an `Either` value, if the value is a `Left` the inner value is applied to the first function, - * if the value is a `Right` the inner value is applied to the second function. + * E.Do, + * E.apS('name', parseString(input.name)), + * E.apS('age', parseNumber(input.age)) + * ) * - * @example - * import { fold, left, right } from 'fp-ts/Either' - * import { pipe } from 'fp-ts/function' + * assert.deepStrictEqual(parsePerson({}), E.left('not a string')) // <= first error * - * function onLeft(errors: Array): string { - * return `Errors: ${errors.join(', ')}` - * } + * const Applicative = E.getApplicativeValidation( + * pipe(string.Semigroup, S.intercalate(', ')) + * ) * - * function onRight(value: number): string { - * return `Ok: ${value}` - * } + * const apS = A.apS(Applicative) * - * assert.strictEqual( - * pipe( - * right(1), - * fold(onLeft, onRight) - * ), - * 'Ok: 1' - * ) - * assert.strictEqual( + * const parsePersonAll = ( + * input: Record + * ): E.Either => * pipe( - * left(['error 1', 'error 2']), - * fold(onLeft, onRight) - * ), - * 'Errors: error 1, error 2' - * ) + * E.Do, + * apS('name', parseString(input.name)), + * apS('age', parseNumber(input.age)) + * ) * - * @category destructors - * @since 2.0.0 - */ -function fold(onLeft, onRight) { - return function (ma) { return (exports.isLeft(ma) ? onLeft(ma.left) : onRight(ma.right)); }; -} -exports.fold = fold; -/** - * Less strict version of [`getOrElse`](#getOrElse). + * assert.deepStrictEqual(parsePersonAll({}), E.left('not a string, not a number')) // <= all errors * - * @category destructors - * @since 2.6.0 + * @category error handling + * @since 2.7.0 */ -var getOrElseW = function (onLeft) { return function (ma) { - return exports.isLeft(ma) ? onLeft(ma.left) : ma.right; -}; }; -exports.getOrElseW = getOrElseW; +var getApplicativeValidation = function (SE) { return ({ + URI: exports.URI, + _E: undefined, + map: _map, + ap: function (fab, fa) { + return (0, exports.isLeft)(fab) + ? (0, exports.isLeft)(fa) + ? (0, exports.left)(SE.concat(fab.left, fa.left)) + : fab + : (0, exports.isLeft)(fa) + ? fa + : (0, exports.right)(fab.right(fa.right)); + }, + of: exports.of +}); }; +exports.getApplicativeValidation = getApplicativeValidation; /** - * Returns the wrapped value if it's a `Right` or a default value if is a `Left`. + * The default [`Alt`](#alt) instance returns the last error, if you want to + * get all errors you need to provide a way to concatenate them via a `Semigroup`. * * @example - * import { getOrElse, left, right } from 'fp-ts/Either' + * import * as E from 'fp-ts/Either' * import { pipe } from 'fp-ts/function' + * import * as S from 'fp-ts/Semigroup' + * import * as string from 'fp-ts/string' * - * assert.deepStrictEqual( - * pipe( - * right(1), - * getOrElse(() => 0) - * ), - * 1 - * ) - * assert.deepStrictEqual( - * pipe( - * left('error'), - * getOrElse(() => 0) - * ), - * 0 - * ) + * const parseString = (u: unknown): E.Either => + * typeof u === 'string' ? E.right(u) : E.left('not a string') * - * @category destructors - * @since 2.0.0 - */ -exports.getOrElse = exports.getOrElseW; -// ------------------------------------------------------------------------------------- -// combinators -// ------------------------------------------------------------------------------------- -/** - * @category combinators - * @since 2.9.0 - */ -function fromNullableK(e) { - var from = fromNullable(e); - return function (f) { return function () { - var a = []; - for (var _i = 0; _i < arguments.length; _i++) { - a[_i] = arguments[_i]; - } - return from(f.apply(void 0, a)); - }; }; -} -exports.fromNullableK = fromNullableK; -/** - * @category combinators - * @since 2.9.0 - */ -function chainNullableK(e) { - var from = fromNullableK(e); - return function (f) { return exports.chain(from(f)); }; -} -exports.chainNullableK = chainNullableK; -/** - * Returns a `Right` if is a `Left` (and vice versa). + * const parseNumber = (u: unknown): E.Either => + * typeof u === 'number' ? E.right(u) : E.left('not a number') * - * @category combinators - * @since 2.0.0 - */ -function swap(ma) { - return exports.isLeft(ma) ? exports.right(ma.left) : exports.left(ma.right); -} -exports.swap = swap; -/** - * Useful for recovering from errors. + * const parse = (u: unknown): E.Either => + * pipe( + * parseString(u), + * E.alt(() => parseNumber(u)) + * ) * - * @category combinators - * @since 2.0.0 - */ -function orElse(onLeft) { - return function (ma) { return (exports.isLeft(ma) ? onLeft(ma.left) : ma); }; -} -exports.orElse = orElse; -/** - * Less strict version of [`filterOrElse`](#filterOrElse). + * assert.deepStrictEqual(parse(true), E.left('not a number')) // <= last error * - * @since 2.9.0 - */ -var filterOrElseW = function (predicate, onFalse) { - return exports.chainW(function (a) { return (predicate(a) ? exports.right(a) : exports.left(onFalse(a))); }); -}; -exports.filterOrElseW = filterOrElseW; -/** - * Derivable from `MonadThrow`. + * const Alt = E.getAltValidation(pipe(string.Semigroup, S.intercalate(', '))) * - * @example - * import { filterOrElse, left, right } from 'fp-ts/Either' - * import { pipe } from 'fp-ts/function' + * const parseAll = (u: unknown): E.Either => + * Alt.alt(parseString(u), () => parseNumber(u)) * - * assert.deepStrictEqual( - * pipe( - * right(1), - * filterOrElse( - * (n) => n > 0, - * () => 'error' - * ) - * ), - * right(1) - * ) - * assert.deepStrictEqual( - * pipe( - * right(-1), - * filterOrElse( - * (n) => n > 0, - * () => 'error' - * ) - * ), - * left('error') - * ) - * assert.deepStrictEqual( - * pipe( - * left('a'), - * filterOrElse( - * (n) => n > 0, - * () => 'error' - * ) - * ), - * left('a') - * ) + * assert.deepStrictEqual(parseAll(true), E.left('not a string, not a number')) // <= all errors * - * @category combinators - * @since 2.0.0 + * @category error handling + * @since 2.7.0 */ -exports.filterOrElse = exports.filterOrElseW; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -var map_ = function (fa, f) { return function_1.pipe(fa, exports.map(f)); }; -var ap_ = function (fab, fa) { return function_1.pipe(fab, exports.ap(fa)); }; -/* istanbul ignore next */ -var chain_ = function (ma, f) { return function_1.pipe(ma, exports.chain(f)); }; -/* istanbul ignore next */ -var reduce_ = function (fa, b, f) { return function_1.pipe(fa, exports.reduce(b, f)); }; -/* istanbul ignore next */ -var foldMap_ = function (M) { return function (fa, f) { - var foldMapM = exports.foldMap(M); - return function_1.pipe(fa, foldMapM(f)); -}; }; -/* istanbul ignore next */ -var reduceRight_ = function (fa, b, f) { return function_1.pipe(fa, exports.reduceRight(b, f)); }; -var traverse_ = function (F) { - var traverseF = exports.traverse(F); - return function (ta, f) { return function_1.pipe(ta, traverseF(f)); }; -}; -var bimap_ = function (fa, f, g) { return function_1.pipe(fa, exports.bimap(f, g)); }; -var mapLeft_ = function (fa, f) { return function_1.pipe(fa, exports.mapLeft(f)); }; -/* istanbul ignore next */ -var alt_ = function (fa, that) { return function_1.pipe(fa, exports.alt(that)); }; -/* istanbul ignore next */ -var extend_ = function (wa, f) { return function_1.pipe(wa, exports.extend(f)); }; -var chainRec_ = function (a, f) { - return ChainRec_1.tailRec(f(a), function (e) { - return exports.isLeft(e) ? exports.right(exports.left(e.left)) : exports.isLeft(e.right) ? exports.left(f(e.right.left)) : exports.right(exports.right(e.right.right)); - }); -}; -// ------------------------------------------------------------------------------------- -// pipeables -// ------------------------------------------------------------------------------------- +var getAltValidation = function (SE) { return ({ + URI: exports.URI, + _E: undefined, + map: _map, + alt: function (me, that) { + if ((0, exports.isRight)(me)) { + return me; + } + var ea = that(); + return (0, exports.isLeft)(ea) ? (0, exports.left)(SE.concat(me.left, ea.left)) : ea; + } +}); }; +exports.getAltValidation = getAltValidation; /** - * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types - * use the type constructor `F` to represent some computational context. - * - * @category Functor + * @category mapping * @since 2.0.0 */ var map = function (f) { return function (fa) { - return exports.isLeft(fa) ? fa : exports.right(f(fa.right)); + return (0, exports.isLeft)(fa) ? fa : (0, exports.right)(f(fa.right)); }; }; exports.map = map; /** - * Map a pair of functions over the two type arguments of the bifunctor. - * - * @category Bifunctor - * @since 2.0.0 - */ -var bimap = function (f, g) { return function (fa) { return (exports.isLeft(fa) ? exports.left(f(fa.left)) : exports.right(g(fa.right))); }; }; -exports.bimap = bimap; -/** - * Map a function over the first type argument of a bifunctor. - * - * @category Bifunctor - * @since 2.0.0 - */ -var mapLeft = function (f) { return function (fa) { - return exports.isLeft(fa) ? exports.left(f(fa.left)) : fa; -}; }; -exports.mapLeft = mapLeft; -/** - * Less strict version of [`ap`](#ap). - * - * @category Apply - * @since 2.8.0 - */ -var apW = function (fa) { return function (fab) { - return exports.isLeft(fab) ? fab : exports.isLeft(fa) ? fa : exports.right(fab.right(fa.right)); -}; }; -exports.apW = apW; -/** - * Apply a function to an argument under a type constructor. - * - * @category Apply - * @since 2.0.0 + * @category instances + * @since 2.7.0 */ -exports.ap = exports.apW; +exports.Functor = { + URI: exports.URI, + map: _map +}; /** - * Combine two effectful actions, keeping only the result of the first. + * Maps the `Right` value of this `Either` to the specified constant value. * - * Derivable from `Apply`. - * - * @category combinators - * @since 2.0.0 + * @category mapping + * @since 2.16.0 */ -var apFirst = function (fb) { - return function_1.flow(exports.map(function (a) { return function () { return a; }; }), exports.ap(fb)); -}; -exports.apFirst = apFirst; +exports.as = (0, function_1.dual)(2, (0, Functor_1.as)(exports.Functor)); /** - * Combine two effectful actions, keeping only the result of the second. + * Maps the `Right` value of this `Either` to the void constant value. * - * Derivable from `Apply`. - * - * @category combinators - * @since 2.0.0 + * @category mapping + * @since 2.16.0 */ -var apSecond = function (fb) { - return function_1.flow(exports.map(function () { return function (b) { return b; }; }), exports.ap(fb)); -}; -exports.apSecond = apSecond; +exports.asUnit = (0, Functor_1.asUnit)(exports.Functor); /** - * Wrap a value into the type constructor. - * - * Equivalent to [`right`](#right). - * - * @example - * import * as E from 'fp-ts/Either' - * - * assert.deepStrictEqual(E.of('a'), E.right('a')) - * - * @category Applicative + * @category constructors * @since 2.7.0 */ exports.of = exports.right; /** - * Less strict version of [`chain`](#chain). - * - * @category Monad - * @since 2.6.0 - */ -var chainW = function (f) { return function (ma) { - return exports.isLeft(ma) ? ma : f(ma.right); -}; }; -exports.chainW = chainW; -/** - * Composes computations in sequence, using the return value of one computation to determine the next computation. - * - * @category Monad - * @since 2.0.0 + * @category instances + * @since 2.10.0 */ -exports.chain = exports.chainW; +exports.Pointed = { + URI: exports.URI, + of: exports.of +}; /** - * Less strict version of [`chainFirst`](#chainFirst) + * Less strict version of [`ap`](#ap). * - * Derivable from `Monad`. + * The `W` suffix (short for **W**idening) means that the error types will be merged. * - * @category combinators * @since 2.8.0 */ -var chainFirstW = function (f) { return function (ma) { - return function_1.pipe(ma, exports.chainW(function (a) { - return function_1.pipe(f(a), exports.map(function () { return a; })); - })); +var apW = function (fa) { return function (fab) { + return (0, exports.isLeft)(fab) ? fab : (0, exports.isLeft)(fa) ? fa : (0, exports.right)(fab.right(fa.right)); }; }; -exports.chainFirstW = chainFirstW; -/** - * Composes computations in sequence, using the return value of one computation to determine the next computation and - * keeping only the result of the first. - * - * Derivable from `Monad`. - * - * @category combinators - * @since 2.0.0 - */ -exports.chainFirst = exports.chainFirstW; +exports.apW = apW; /** - * The `flatten` function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level. - * - * Derivable from `Monad`. - * - * @example - * import * as E from 'fp-ts/Either' - * - * assert.deepStrictEqual(E.flatten(E.right(E.right('a'))), E.right('a')) - * assert.deepStrictEqual(E.flatten(E.right(E.left('e'))), E.left('e')) - * assert.deepStrictEqual(E.flatten(E.left('e')), E.left('e')) - * - * @category combinators * @since 2.0.0 */ -exports.flatten = -/*#__PURE__*/ -exports.chain(function_1.identity); +exports.ap = exports.apW; /** - * Less strict version of [`alt`](#alt). - * - * @category Alt - * @since 2.9.0 + * @category instances + * @since 2.10.0 */ -var altW = function (that) { return function (fa) { return (exports.isLeft(fa) ? that() : fa); }; }; -exports.altW = altW; +exports.Apply = { + URI: exports.URI, + map: _map, + ap: _ap +}; /** - * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to - * types of kind `* -> *`. - * - * @category Alt - * @since 2.0.0 + * @category instances + * @since 2.7.0 */ -exports.alt = exports.altW; +exports.Applicative = { + URI: exports.URI, + map: _map, + ap: _ap, + of: exports.of +}; /** - * @category Extend - * @since 2.0.0 + * @category instances + * @since 2.10.0 */ -var extend = function (f) { return function (wa) { - return exports.isLeft(wa) ? wa : exports.right(f(wa)); -}; }; -exports.extend = extend; +exports.Chain = { + URI: exports.URI, + map: _map, + ap: _ap, + chain: exports.flatMap +}; /** - * Derivable from `Extend`. - * - * @category combinators - * @since 2.0.0 + * @category instances + * @since 2.7.0 */ -exports.duplicate = -/*#__PURE__*/ -exports.extend(function_1.identity); +exports.Monad = { + URI: exports.URI, + map: _map, + ap: _ap, + of: exports.of, + chain: exports.flatMap +}; /** * Left-associative fold of a structure. * @@ -8432,46 +10650,46 @@ exports.extend(function_1.identity); * * assert.deepStrictEqual( * pipe(E.right('a'), E.reduce(startWith, concat)), - * 'prefix:a', + * 'prefix:a' * ) * * assert.deepStrictEqual( * pipe(E.left('e'), E.reduce(startWith, concat)), - * 'prefix', + * 'prefix' * ) * - * @category Foldable + * @category folding * @since 2.0.0 */ var reduce = function (b, f) { return function (fa) { - return exports.isLeft(fa) ? b : f(b, fa.right); + return (0, exports.isLeft)(fa) ? b : f(b, fa.right); }; }; exports.reduce = reduce; /** * Map each element of the structure to a monoid, and combine the results. * * @example - * import { pipe } from 'fp-ts/function'; + * import { pipe } from 'fp-ts/function' * import * as E from 'fp-ts/Either' - * import { monoidString } from 'fp-ts/Monoid' + * import * as S from 'fp-ts/string' * * const yell = (a: string) => `${a}!` * * assert.deepStrictEqual( - * pipe(E.right('a'), E.foldMap(monoidString)(yell)), - * 'a!', + * pipe(E.right('a'), E.foldMap(S.Monoid)(yell)), + * 'a!' * ) * * assert.deepStrictEqual( - * pipe(E.left('e'), E.foldMap(monoidString)(yell)), - * monoidString.empty, + * pipe(E.left('e'), E.foldMap(S.Monoid)(yell)), + * S.Monoid.empty * ) * - * @category Foldable + * @category folding * @since 2.0.0 */ var foldMap = function (M) { return function (f) { return function (fa) { - return exports.isLeft(fa) ? M.empty : f(fa.right); + return (0, exports.isLeft)(fa) ? M.empty : f(fa.right); }; }; }; exports.foldMap = foldMap; /** @@ -8486,44 +10704,60 @@ exports.foldMap = foldMap; * * assert.deepStrictEqual( * pipe(E.right('a'), E.reduceRight(startWith, concat)), - * 'a:postfix', + * 'a:postfix' * ) * * assert.deepStrictEqual( * pipe(E.left('e'), E.reduceRight(startWith, concat)), - * 'postfix', + * 'postfix' * ) * - * @category Foldable + * @category folding * @since 2.0.0 */ var reduceRight = function (b, f) { return function (fa) { - return exports.isLeft(fa) ? b : f(fa.right, b); + return (0, exports.isLeft)(fa) ? b : f(fa.right, b); }; }; exports.reduceRight = reduceRight; +/** + * @category instances + * @since 2.7.0 + */ +exports.Foldable = { + URI: exports.URI, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight +}; /** * Map each element of a structure to an action, evaluate these actions from left to right, and collect the results. * * @example * import { pipe } from 'fp-ts/function' - * import * as A from 'fp-ts/Array' + * import * as RA from 'fp-ts/ReadonlyArray' * import * as E from 'fp-ts/Either' * import * as O from 'fp-ts/Option' * * assert.deepStrictEqual( - * pipe(E.right(['a']), E.traverse(O.option)(A.head)), - * O.some(E.right('a')), + * pipe(E.right(['a']), E.traverse(O.Applicative)(RA.head)), + * O.some(E.right('a')) * ) * * assert.deepStrictEqual( - * pipe(E.right([]), E.traverse(O.option)(A.head)), - * O.none, + * pipe(E.right([]), E.traverse(O.Applicative)(RA.head)), + * O.none * ) * - * @category Traversable + * @category traversing * @since 2.6.3 */ -var traverse = function (F) { return function (f) { return function (ta) { return (exports.isLeft(ta) ? F.of(exports.left(ta.left)) : F.map(f(ta.right), exports.right)); }; }; }; +var traverse = function (F) { + return function (f) { + return function (ta) { + return (0, exports.isLeft)(ta) ? F.of((0, exports.left)(ta.left)) : F.map(f(ta.right), exports.right); + }; + }; +}; exports.traverse = traverse; /** * Evaluate each monadic action in the structure from left to right, and collect the results. @@ -8534,422 +10768,664 @@ exports.traverse = traverse; * import * as O from 'fp-ts/Option' * * assert.deepStrictEqual( - * pipe(E.right(O.some('a')), E.sequence(O.option)), - * O.some(E.right('a')), + * pipe(E.right(O.some('a')), E.sequence(O.Applicative)), + * O.some(E.right('a')) * ) * * assert.deepStrictEqual( - * pipe(E.right(O.none), E.sequence(O.option)), + * pipe(E.right(O.none), E.sequence(O.Applicative)), * O.none * ) * - * @category Traversable + * @category traversing * @since 2.6.3 */ -var sequence = function (F) { return function (ma) { - return exports.isLeft(ma) ? F.of(exports.left(ma.left)) : F.map(ma.right, exports.right); -}; }; +var sequence = function (F) { + return function (ma) { + return (0, exports.isLeft)(ma) ? F.of((0, exports.left)(ma.left)) : F.map(ma.right, exports.right); + }; +}; exports.sequence = sequence; /** - * @category MonadThrow - * @since 2.6.3 + * @category instances + * @since 2.7.0 */ -exports.throwError = exports.left; -// ------------------------------------------------------------------------------------- -// instances -// ------------------------------------------------------------------------------------- +exports.Traversable = { + URI: exports.URI, + map: _map, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, + sequence: exports.sequence +}; /** - * @category instances + * Map a pair of functions over the two type arguments of the bifunctor. + * + * @category mapping * @since 2.0.0 */ -exports.URI = 'Either'; +var bimap = function (f, g) { return function (fa) { + return (0, exports.isLeft)(fa) ? (0, exports.left)(f(fa.left)) : (0, exports.right)(g(fa.right)); +}; }; +exports.bimap = bimap; /** - * @category instances + * Map a function over the first type argument of a bifunctor. + * + * @category error handling * @since 2.0.0 */ -function getShow(SE, SA) { - return { - show: function (ma) { return (exports.isLeft(ma) ? "left(" + SE.show(ma.left) + ")" : "right(" + SA.show(ma.right) + ")"); } - }; -} -exports.getShow = getShow; +var mapLeft = function (f) { return function (fa) { + return (0, exports.isLeft)(fa) ? (0, exports.left)(f(fa.left)) : fa; +}; }; +exports.mapLeft = mapLeft; /** * @category instances - * @since 2.0.0 + * @since 2.7.0 */ -function getEq(EL, EA) { - return { - equals: function (x, y) { - return x === y || (exports.isLeft(x) ? exports.isLeft(y) && EL.equals(x.left, y.left) : exports.isRight(y) && EA.equals(x.right, y.right)); - } - }; -} -exports.getEq = getEq; +exports.Bifunctor = { + URI: exports.URI, + bimap: _bimap, + mapLeft: _mapLeft +}; /** - * Semigroup returning the left-most non-`Left` value. If both operands are `Right`s then the inner values are - * concatenated using the provided `Semigroup` - * - * @example - * import { getSemigroup, left, right } from 'fp-ts/Either' - * import { semigroupSum } from 'fp-ts/Semigroup' + * Less strict version of [`alt`](#alt). * - * const S = getSemigroup(semigroupSum) - * assert.deepStrictEqual(S.concat(left('a'), left('b')), left('a')) - * assert.deepStrictEqual(S.concat(left('a'), right(2)), right(2)) - * assert.deepStrictEqual(S.concat(right(1), left('b')), right(1)) - * assert.deepStrictEqual(S.concat(right(1), right(2)), right(3)) + * The `W` suffix (short for **W**idening) means that the error and the return types will be merged. * - * @category instances - * @since 2.0.0 + * @category error handling + * @since 2.9.0 */ -function getSemigroup(S) { - return { - concat: function (x, y) { return (exports.isLeft(y) ? x : exports.isLeft(x) ? y : exports.right(S.concat(x.right, y.right))); } - }; -} -exports.getSemigroup = getSemigroup; +var altW = function (that) { return function (fa) { + return (0, exports.isLeft)(fa) ? that() : fa; +}; }; +exports.altW = altW; /** - * Semigroup returning the left-most `Left` value. If both operands are `Right`s then the inner values - * are concatenated using the provided `Semigroup` + * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to + * types of kind `* -> *`. + * + * In case of `Either` returns the left-most non-`Left` value (or the right-most `Left` value if both values are `Left`). + * + * | x | y | pipe(x, alt(() => y) | + * | -------- | -------- | -------------------- | + * | left(a) | left(b) | left(b) | + * | left(a) | right(2) | right(2) | + * | right(1) | left(b) | right(1) | + * | right(1) | right(2) | right(1) | * * @example - * import { getApplySemigroup, left, right } from 'fp-ts/Either' - * import { semigroupSum } from 'fp-ts/Semigroup' + * import * as E from 'fp-ts/Either' + * import { pipe } from 'fp-ts/function' * - * const S = getApplySemigroup(semigroupSum) - * assert.deepStrictEqual(S.concat(left('a'), left('b')), left('a')) - * assert.deepStrictEqual(S.concat(left('a'), right(2)), left('a')) - * assert.deepStrictEqual(S.concat(right(1), left('b')), left('b')) - * assert.deepStrictEqual(S.concat(right(1), right(2)), right(3)) + * assert.deepStrictEqual( + * pipe( + * E.left('a'), + * E.alt(() => E.left('b')) + * ), + * E.left('b') + * ) + * assert.deepStrictEqual( + * pipe( + * E.left('a'), + * E.alt(() => E.right(2)) + * ), + * E.right(2) + * ) + * assert.deepStrictEqual( + * pipe( + * E.right(1), + * E.alt(() => E.left('b')) + * ), + * E.right(1) + * ) + * assert.deepStrictEqual( + * pipe( + * E.right(1), + * E.alt(() => E.right(2)) + * ), + * E.right(1) + * ) * - * @category instances + * @category error handling * @since 2.0.0 */ -function getApplySemigroup(S) { - return { - concat: function (x, y) { return (exports.isLeft(x) ? x : exports.isLeft(y) ? y : exports.right(S.concat(x.right, y.right))); } - }; -} -exports.getApplySemigroup = getApplySemigroup; +exports.alt = exports.altW; /** * @category instances - * @since 2.0.0 + * @since 2.7.0 */ -function getApplyMonoid(M) { - return { - concat: getApplySemigroup(M).concat, - empty: exports.right(M.empty) - }; -} -exports.getApplyMonoid = getApplyMonoid; +exports.Alt = { + URI: exports.URI, + map: _map, + alt: _alt +}; /** - * Builds a `Filterable` instance for `Either` given `Monoid` for the left side - * - * @category instances - * @since 3.0.0 + * @since 2.0.0 */ -function getFilterable(M) { - var empty = exports.left(M.empty); - var compact = function (ma) { - return exports.isLeft(ma) ? ma : ma.right._tag === 'None' ? empty : exports.right(ma.right.value); - }; - var separate = function (ma) { - return exports.isLeft(ma) - ? { left: ma, right: ma } - : exports.isLeft(ma.right) - ? { left: exports.right(ma.right.left), right: empty } - : { left: empty, right: exports.right(ma.right.right) }; - }; - var partitionMap = function (ma, f) { - if (exports.isLeft(ma)) { - return { left: ma, right: ma }; - } - var e = f(ma.right); - return exports.isLeft(e) ? { left: exports.right(e.left), right: empty } : { left: empty, right: exports.right(e.right) }; - }; - var partition = function (ma, p) { - return exports.isLeft(ma) - ? { left: ma, right: ma } - : p(ma.right) - ? { left: empty, right: exports.right(ma.right) } - : { left: exports.right(ma.right), right: empty }; - }; - var filterMap = function (ma, f) { - if (exports.isLeft(ma)) { - return ma; - } - var ob = f(ma.right); - return ob._tag === 'None' ? empty : exports.right(ob.value); - }; - var filter = function (ma, predicate) { - return exports.isLeft(ma) ? ma : predicate(ma.right) ? ma : empty; - }; - return { - URI: exports.URI, - _E: undefined, - map: map_, - compact: compact, - separate: separate, - filter: filter, - filterMap: filterMap, - partition: partition, - partitionMap: partitionMap - }; -} -exports.getFilterable = getFilterable; +var extend = function (f) { return function (wa) { + return (0, exports.isLeft)(wa) ? wa : (0, exports.right)(f(wa)); +}; }; +exports.extend = extend; /** - * Builds `Witherable` instance for `Either` given `Monoid` for the left side - * * @category instances - * @since 2.0.0 + * @since 2.7.0 */ -function getWitherable(M) { - var F_ = getFilterable(M); - var wither = function (F) { - var traverseF = traverse_(F); - return function (ma, f) { return F.map(traverseF(ma, f), F_.compact); }; - }; - var wilt = function (F) { - var traverseF = traverse_(F); - return function (ma, f) { return F.map(traverseF(ma, f), F_.separate); }; - }; - return { - URI: exports.URI, - _E: undefined, - map: map_, - compact: F_.compact, - separate: F_.separate, - filter: F_.filter, - filterMap: F_.filterMap, - partition: F_.partition, - partitionMap: F_.partitionMap, - traverse: traverse_, - sequence: exports.sequence, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - wither: wither, - wilt: wilt - }; -} -exports.getWitherable = getWitherable; +exports.Extend = { + URI: exports.URI, + map: _map, + extend: _extend +}; /** * @category instances * @since 2.7.0 */ -function getApplicativeValidation(SE) { - return { - URI: exports.URI, - _E: undefined, - map: map_, - ap: function (fab, fa) { - return exports.isLeft(fab) - ? exports.isLeft(fa) - ? exports.left(SE.concat(fab.left, fa.left)) - : fab - : exports.isLeft(fa) - ? fa - : exports.right(fab.right(fa.right)); - }, - of: exports.of - }; -} -exports.getApplicativeValidation = getApplicativeValidation; +exports.ChainRec = { + URI: exports.URI, + map: _map, + ap: _ap, + chain: exports.flatMap, + chainRec: _chainRec +}; +/** + * @since 2.6.3 + */ +exports.throwError = exports.left; /** * @category instances * @since 2.7.0 */ -function getAltValidation(SE) { - return { - URI: exports.URI, - _E: undefined, - map: map_, - alt: function (me, that) { - if (exports.isRight(me)) { - return me; - } - var ea = that(); - return exports.isLeft(ea) ? exports.left(SE.concat(me.left, ea.left)) : ea; - } - }; -} -exports.getAltValidation = getAltValidation; -// TODO: remove in v3 +exports.MonadThrow = { + URI: exports.URI, + map: _map, + ap: _ap, + of: exports.of, + chain: exports.flatMap, + throwError: exports.throwError +}; /** * @category instances - * @since 2.0.0 + * @since 2.10.0 */ -function getValidation(SE) { - var applicativeValidation = getApplicativeValidation(SE); - var altValidation = getAltValidation(SE); - return { - URI: exports.URI, - _E: undefined, - map: map_, - of: exports.of, - chain: chain_, - bimap: bimap_, - mapLeft: mapLeft_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - extend: extend_, - traverse: traverse_, - sequence: exports.sequence, - chainRec: chainRec_, - throwError: exports.throwError, - ap: applicativeValidation.ap, - alt: altValidation.alt - }; -} -exports.getValidation = getValidation; +exports.FromEither = { + URI: exports.URI, + fromEither: function_1.identity +}; /** - * @category instances + * @example + * import { fromPredicate, left, right } from 'fp-ts/Either' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * 1, + * fromPredicate( + * (n) => n > 0, + * () => 'error' + * ) + * ), + * right(1) + * ) + * assert.deepStrictEqual( + * pipe( + * -1, + * fromPredicate( + * (n) => n > 0, + * () => 'error' + * ) + * ), + * left('error') + * ) + * + * @category lifting * @since 2.0.0 */ -function getValidationSemigroup(SE, SA) { - return { - concat: function (x, y) { - return exports.isLeft(x) ? (exports.isLeft(y) ? exports.left(SE.concat(x.left, y.left)) : x) : exports.isLeft(y) ? y : exports.right(SA.concat(x.right, y.right)); - } - }; -} -exports.getValidationSemigroup = getValidationSemigroup; +exports.fromPredicate = (0, FromEither_1.fromPredicate)(exports.FromEither); +// ------------------------------------------------------------------------------------- +// conversions +// ------------------------------------------------------------------------------------- /** - * @category instances - * @since 2.7.0 + * @example + * import * as E from 'fp-ts/Either' + * import { pipe } from 'fp-ts/function' + * import * as O from 'fp-ts/Option' + * + * assert.deepStrictEqual( + * pipe( + * O.some(1), + * E.fromOption(() => 'error') + * ), + * E.right(1) + * ) + * assert.deepStrictEqual( + * pipe( + * O.none, + * E.fromOption(() => 'error') + * ), + * E.left('error') + * ) + * + * @category conversions + * @since 2.0.0 */ -exports.Functor = { - URI: exports.URI, - map: map_ -}; +exports.fromOption = +/*#__PURE__*/ (0, FromEither_1.fromOption)(exports.FromEither); +// ------------------------------------------------------------------------------------- +// refinements +// ------------------------------------------------------------------------------------- /** - * @category instances - * @since 2.7.0 + * Returns `true` if the either is an instance of `Left`, `false` otherwise. + * + * @category refinements + * @since 2.0.0 */ -exports.Applicative = { - URI: exports.URI, - map: map_, - ap: ap_, - of: exports.of -}; +exports.isLeft = _.isLeft; /** - * @category instances - * @since 2.7.0 + * Returns `true` if the either is an instance of `Right`, `false` otherwise. + * + * @category refinements + * @since 2.0.0 */ -exports.Monad = { - URI: exports.URI, - map: map_, - ap: ap_, - of: exports.of, - chain: chain_ -}; +exports.isRight = _.isRight; /** - * @category instances - * @since 2.7.0 + * Less strict version of [`match`](#match). + * + * The `W` suffix (short for **W**idening) means that the handler return types will be merged. + * + * @category pattern matching + * @since 2.10.0 */ -exports.Foldable = { - URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_ +var matchW = function (onLeft, onRight) { + return function (ma) { + return (0, exports.isLeft)(ma) ? onLeft(ma.left) : onRight(ma.right); + }; }; +exports.matchW = matchW; /** - * @category instances - * @since 2.7.0 + * Alias of [`matchW`](#matchw). + * + * @category pattern matching + * @since 2.10.0 */ -exports.Traversable = { - URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: exports.sequence -}; +exports.foldW = exports.matchW; /** - * @category instances - * @since 2.7.0 + * Takes two functions and an `Either` value, if the value is a `Left` the inner value is applied to the first function, + * if the value is a `Right` the inner value is applied to the second function. + * + * @example + * import { match, left, right } from 'fp-ts/Either' + * import { pipe } from 'fp-ts/function' + * + * function onLeft(errors: Array): string { + * return `Errors: ${errors.join(', ')}` + * } + * + * function onRight(value: number): string { + * return `Ok: ${value}` + * } + * + * assert.strictEqual( + * pipe( + * right(1), + * match(onLeft, onRight) + * ), + * 'Ok: 1' + * ) + * assert.strictEqual( + * pipe( + * left(['error 1', 'error 2']), + * match(onLeft, onRight) + * ), + * 'Errors: error 1, error 2' + * ) + * + * @category pattern matching + * @since 2.10.0 */ -exports.Bifunctor = { - URI: exports.URI, - bimap: bimap_, - mapLeft: mapLeft_ -}; +exports.match = exports.matchW; /** - * @category instances - * @since 2.7.0 + * Alias of [`match`](#match). + * + * @category pattern matching + * @since 2.0.0 */ -exports.Alt = { - URI: exports.URI, - map: map_, - alt: alt_ +exports.fold = exports.match; +/** + * Less strict version of [`getOrElse`](#getorelse). + * + * The `W` suffix (short for **W**idening) means that the handler return type will be merged. + * + * @category error handling + * @since 2.6.0 + */ +var getOrElseW = function (onLeft) { + return function (ma) { + return (0, exports.isLeft)(ma) ? onLeft(ma.left) : ma.right; + }; }; +exports.getOrElseW = getOrElseW; /** - * @category instances - * @since 2.7.0 + * Returns the wrapped value if it's a `Right` or a default value if is a `Left`. + * + * @example + * import { getOrElse, left, right } from 'fp-ts/Either' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * right(1), + * getOrElse(() => 0) + * ), + * 1 + * ) + * assert.deepStrictEqual( + * pipe( + * left('error'), + * getOrElse(() => 0) + * ), + * 0 + * ) + * + * @category error handling + * @since 2.0.0 */ -exports.Extend = { - URI: exports.URI, - map: map_, - extend: extend_ +exports.getOrElse = exports.getOrElseW; +// ------------------------------------------------------------------------------------- +// combinators +// ------------------------------------------------------------------------------------- +/** + * @category mapping + * @since 2.10.0 + */ +exports.flap = (0, Functor_1.flap)(exports.Functor); +/** + * Combine two effectful actions, keeping only the result of the first. + * + * @since 2.0.0 + */ +exports.apFirst = (0, Apply_1.apFirst)(exports.Apply); +/** + * Less strict version of [`apFirst`](#apfirst) + * + * The `W` suffix (short for **W**idening) means that the error types will be merged. + * + * @since 2.12.0 + */ +exports.apFirstW = exports.apFirst; +/** + * Combine two effectful actions, keeping only the result of the second. + * + * @since 2.0.0 + */ +exports.apSecond = (0, Apply_1.apSecond)(exports.Apply); +/** + * Less strict version of [`apSecond`](#apsecond) + * + * The `W` suffix (short for **W**idening) means that the error types will be merged. + * + * @since 2.12.0 + */ +exports.apSecondW = exports.apSecond; +/** + * Composes computations in sequence, using the return value of one computation to determine the next computation and + * keeping only the result of the first. + * + * @category combinators + * @since 2.15.0 + */ +exports.tap = (0, function_1.dual)(2, chainable.tap(exports.Chain)); +/** + * Less strict version of [`flatten`](#flatten). + * + * The `W` suffix (short for **W**idening) means that the error types will be merged. + * + * @category sequencing + * @since 2.11.0 + */ +exports.flattenW = +/*#__PURE__*/ (0, exports.flatMap)(function_1.identity); +/** + * The `flatten` function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level. + * + * @example + * import * as E from 'fp-ts/Either' + * + * assert.deepStrictEqual(E.flatten(E.right(E.right('a'))), E.right('a')) + * assert.deepStrictEqual(E.flatten(E.right(E.left('e'))), E.left('e')) + * assert.deepStrictEqual(E.flatten(E.left('e')), E.left('e')) + * + * @category sequencing + * @since 2.0.0 + */ +exports.flatten = exports.flattenW; +/** + * @since 2.0.0 + */ +exports.duplicate = (0, exports.extend)(function_1.identity); +/** + * Use `liftOption`. + * + * @category legacy + * @since 2.10.0 + */ +exports.fromOptionK = +/*#__PURE__*/ (0, FromEither_1.fromOptionK)(exports.FromEither); +/** + * Use `flatMapOption`. + * + * @category legacy + * @since 2.11.0 + */ +exports.chainOptionK = (0, FromEither_1.chainOptionK)(exports.FromEither, exports.Chain); +/** + * Use `flatMapOption`. + * + * @category legacy + * @since 2.13.2 + */ +exports.chainOptionKW = exports.chainOptionK; +/** @internal */ +var _FromEither = { + fromEither: exports.FromEither.fromEither }; /** - * @category instances - * @since 2.7.0 + * @category lifting + * @since 2.15.0 */ -exports.ChainRec = { - URI: exports.URI, - map: map_, - ap: ap_, - chain: chain_, - chainRec: chainRec_ +exports.liftNullable = _.liftNullable(_FromEither); +/** + * @category lifting + * @since 2.15.0 + */ +exports.liftOption = _.liftOption(_FromEither); +/** @internal */ +var _FlatMap = { + flatMap: exports.flatMap }; /** - * @category instances - * @since 2.7.0 + * @category sequencing + * @since 2.15.0 */ -exports.MonadThrow = { - URI: exports.URI, - map: map_, - ap: ap_, - of: exports.of, - chain: chain_, - throwError: exports.throwError +exports.flatMapNullable = _.flatMapNullable(_FromEither, _FlatMap); +/** + * @category sequencing + * @since 2.15.0 + */ +exports.flatMapOption = _.flatMapOption(_FromEither, _FlatMap); +/** + * @example + * import * as E from 'fp-ts/Either' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * E.right(1), + * E.filterOrElse( + * (n) => n > 0, + * () => 'error' + * ) + * ), + * E.right(1) + * ) + * assert.deepStrictEqual( + * pipe( + * E.right(-1), + * E.filterOrElse( + * (n) => n > 0, + * () => 'error' + * ) + * ), + * E.left('error') + * ) + * assert.deepStrictEqual( + * pipe( + * E.left('a'), + * E.filterOrElse( + * (n) => n > 0, + * () => 'error' + * ) + * ), + * E.left('a') + * ) + * + * @category filtering + * @since 2.0.0 + */ +exports.filterOrElse = (0, FromEither_1.filterOrElse)(exports.FromEither, exports.Chain); +/** + * Less strict version of [`filterOrElse`](#filterorelse). + * + * The `W` suffix (short for **W**idening) means that the error types will be merged. + * + * @category filtering + * @since 2.9.0 + */ +exports.filterOrElseW = exports.filterOrElse; +/** + * Returns a `Right` if is a `Left` (and vice versa). + * + * @since 2.0.0 + */ +var swap = function (ma) { return ((0, exports.isLeft)(ma) ? (0, exports.right)(ma.left) : (0, exports.left)(ma.right)); }; +exports.swap = swap; +/** + * Less strict version of [`orElse`](#orelse). + * + * The `W` suffix (short for **W**idening) means that the return types will be merged. + * + * @category error handling + * @since 2.10.0 + */ +var orElseW = function (onLeft) { + return function (ma) { + return (0, exports.isLeft)(ma) ? onLeft(ma.left) : ma; + }; }; +exports.orElseW = orElseW; /** - * @category instances + * Useful for recovering from errors. + * + * @category error handling * @since 2.0.0 */ -function getValidationMonoid(SE, SA) { - return { - concat: getValidationSemigroup(SE, SA).concat, - empty: exports.right(SA.empty) +exports.orElse = exports.orElseW; +/** + * Takes a default and a nullable value, if the value is not nully, turn it into a `Right`, if the value is nully use + * the provided default as a `Left`. + * + * @example + * import { fromNullable, left, right } from 'fp-ts/Either' + * + * const parse = fromNullable('nully') + * + * assert.deepStrictEqual(parse(1), right(1)) + * assert.deepStrictEqual(parse(null), left('nully')) + * + * @category conversions + * @since 2.0.0 + */ +var fromNullable = function (e) { + return function (a) { + return a == null ? (0, exports.left)(e) : (0, exports.right)(a); }; -} -exports.getValidationMonoid = getValidationMonoid; +}; +exports.fromNullable = fromNullable; /** - * @category instances + * Constructs a new `Either` from a function that might throw. + * + * See also [`tryCatchK`](#trycatchk). + * + * @example + * import * as E from 'fp-ts/Either' + * + * const unsafeHead = (as: ReadonlyArray): A => { + * if (as.length > 0) { + * return as[0] + * } else { + * throw new Error('empty array') + * } + * } + * + * const head = (as: ReadonlyArray): E.Either => + * E.tryCatch(() => unsafeHead(as), e => (e instanceof Error ? e : new Error('unknown error'))) + * + * assert.deepStrictEqual(head([]), E.left(new Error('empty array'))) + * assert.deepStrictEqual(head([1, 2, 3]), E.right(1)) + * + * @category interop * @since 2.0.0 */ -exports.either = { - URI: exports.URI, - map: map_, - of: exports.of, - ap: ap_, - chain: chain_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: exports.sequence, - bimap: bimap_, - mapLeft: mapLeft_, - alt: alt_, - extend: extend_, - chainRec: chainRec_, - throwError: exports.throwError +var tryCatch = function (f, onThrow) { + try { + return (0, exports.right)(f()); + } + catch (e) { + return (0, exports.left)(onThrow(e)); + } +}; +exports.tryCatch = tryCatch; +/** + * Converts a function that may throw to one returning a `Either`. + * + * @category interop + * @since 2.10.0 + */ +var tryCatchK = function (f, onThrow) { + return function () { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } + return (0, exports.tryCatch)(function () { return f.apply(void 0, a); }, onThrow); + }; +}; +exports.tryCatchK = tryCatchK; +/** + * Use `liftNullable`. + * + * @category legacy + * @since 2.9.0 + */ +var fromNullableK = function (e) { + var from = (0, exports.fromNullable)(e); + return function (f) { return (0, function_1.flow)(f, from); }; +}; +exports.fromNullableK = fromNullableK; +/** + * Use `flatMapNullable`. + * + * @category legacy + * @since 2.9.0 + */ +var chainNullableK = function (e) { + var from = (0, exports.fromNullableK)(e); + return function (f) { return (0, exports.flatMap)(from(f)); }; }; +exports.chainNullableK = chainNullableK; +/** + * @category conversions + * @since 2.10.0 + */ +exports.toUnion = (0, exports.foldW)(function_1.identity, function_1.identity); // ------------------------------------------------------------------------------------- // utils // ------------------------------------------------------------------------------------- @@ -8962,11 +11438,14 @@ function toError(e) { return e instanceof Error ? e : new Error(String(e)); } exports.toError = toError; -/** - * @since 2.0.0 - */ function elem(E) { - return function (a, ma) { return (exports.isLeft(ma) ? false : E.equals(a, ma.right)); }; + return function (a, ma) { + if (ma === undefined) { + var elemE_1 = elem(E); + return function (ma) { return elemE_1(a, ma); }; + } + return (0, exports.isLeft)(ma) ? false : E.equals(a, ma.right); + }; } exports.elem = elem; /** @@ -8983,730 +11462,1610 @@ exports.elem = elem; * * @since 2.0.0 */ -function exists(predicate) { - return function (ma) { return (exports.isLeft(ma) ? false : predicate(ma.right)); }; -} +var exists = function (predicate) { + return function (ma) { + return (0, exports.isLeft)(ma) ? false : predicate(ma.right); + }; +}; exports.exists = exists; // ------------------------------------------------------------------------------------- // do notation // ------------------------------------------------------------------------------------- /** + * @category do notation * @since 2.9.0 */ -exports.Do = -/*#__PURE__*/ -exports.of({}); +exports.Do = (0, exports.of)(_.emptyRecord); /** + * @category do notation * @since 2.8.0 */ -var bindTo = function (name) { - return exports.map(function_1.bindTo_(name)); -}; -exports.bindTo = bindTo; +exports.bindTo = (0, Functor_1.bindTo)(exports.Functor); +var let_ = /*#__PURE__*/ (0, Functor_1.let)(exports.Functor); +exports["let"] = let_; /** + * @category do notation * @since 2.8.0 */ -var bindW = function (name, f) { - return exports.chainW(function (a) { - return function_1.pipe(f(a), exports.map(function (b) { return function_1.bind_(a, name, b); })); - }); -}; -exports.bindW = bindW; +exports.bind = chainable.bind(exports.Chain); /** + * The `W` suffix (short for **W**idening) means that the error types will be merged. + * + * @category do notation * @since 2.8.0 */ -exports.bind = exports.bindW; -// ------------------------------------------------------------------------------------- -// pipeable sequence S -// ------------------------------------------------------------------------------------- +exports.bindW = exports.bind; /** + * @category do notation * @since 2.8.0 */ -var apSW = function (name, fb) { - return function_1.flow(exports.map(function (a) { return function (b) { return function_1.bind_(a, name, b); }; }), exports.apW(fb)); -}; -exports.apSW = apSW; +exports.apS = (0, Apply_1.apS)(exports.Apply); /** + * Less strict version of [`apS`](#aps). + * + * The `W` suffix (short for **W**idening) means that the error types will be merged. + * + * @category do notation * @since 2.8.0 */ -exports.apS = exports.apSW; +exports.apSW = exports.apS; +/** + * @since 2.11.0 + */ +exports.ApT = (0, exports.of)(_.emptyReadonlyArray); // ------------------------------------------------------------------------------------- // array utils // ------------------------------------------------------------------------------------- /** + * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`. * - * @since 2.9.0 + * @category traversing + * @since 2.11.0 */ -var traverseArrayWithIndex = function (f) { return function (arr) { - // tslint:disable-next-line: readonly-array - var result = []; - for (var i = 0; i < arr.length; i++) { - var e = f(i, arr[i]); - if (e._tag === 'Left') { +var traverseReadonlyNonEmptyArrayWithIndex = function (f) { + return function (as) { + var e = f(0, _.head(as)); + if ((0, exports.isLeft)(e)) { return e; } - result.push(e.right); - } - return exports.right(result); -}; }; -exports.traverseArrayWithIndex = traverseArrayWithIndex; + var out = [e.right]; + for (var i = 1; i < as.length; i++) { + var e_1 = f(i, as[i]); + if ((0, exports.isLeft)(e_1)) { + return e_1; + } + out.push(e_1.right); + } + return (0, exports.right)(out); + }; +}; +exports.traverseReadonlyNonEmptyArrayWithIndex = traverseReadonlyNonEmptyArrayWithIndex; /** - * map an array using provided function to Either then transform to Either of the array - * this function has the same behavior of `A.traverse(E.either)` but it's optimized and performs better - * - * @example + * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * + * @category traversing + * @since 2.11.0 + */ +var traverseReadonlyArrayWithIndex = function (f) { + var g = (0, exports.traverseReadonlyNonEmptyArrayWithIndex)(f); + return function (as) { return (_.isNonEmpty(as) ? g(as) : exports.ApT); }; +}; +exports.traverseReadonlyArrayWithIndex = traverseReadonlyArrayWithIndex; +/** + * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * - * import { traverseArray, left, right, fromPredicate } from 'fp-ts/Either' - * import { pipe } from 'fp-ts/function' - * import * as A from 'fp-ts/Array' + * @category traversing + * @since 2.9.0 + */ +exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndex; +/** + * Equivalent to `ReadonlyArray#traverse(Applicative)`. * - * const arr = A.range(0, 10) - * assert.deepStrictEqual( - * pipe( - * arr, - * traverseArray((x) => right(x)) - * ), - * right(arr) - * ) - * assert.deepStrictEqual( - * pipe( - * arr, - * traverseArray( - * fromPredicate( - * (x) => x > 5, - * () => 'a' - * ) - * ) - * ), - * left('a') - * ) + * @category traversing * @since 2.9.0 */ -var traverseArray = function (f) { return exports.traverseArrayWithIndex(function (_, a) { return f(a); }); }; +var traverseArray = function (f) { return (0, exports.traverseReadonlyArrayWithIndex)(function (_, a) { return f(a); }); }; exports.traverseArray = traverseArray; /** - * convert an array of either to an either of array - * this function has the same behavior of `A.sequence(E.either)` but it's optimized and performs better - * - * @example - * - * import { sequenceArray, left, right } from 'fp-ts/Either' - * import { pipe } from 'fp-ts/function' - * import * as A from 'fp-ts/Array' - * - * const arr = A.range(0, 10) - * assert.deepStrictEqual(pipe(arr, A.map(right), sequenceArray), right(arr)) - * assert.deepStrictEqual(pipe(arr, A.map(right), A.cons(left('Error')), sequenceArray), left('Error')) + * Equivalent to `ReadonlyArray#sequence(Applicative)`. * + * @category traversing * @since 2.9.0 */ exports.sequenceArray = -/*#__PURE__*/ -exports.traverseArray(function_1.identity); - - -/***/ }), - -/***/ 6964: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.eq = exports.Contravariant = exports.getMonoid = exports.eqDate = exports.getTupleEq = exports.getStructEq = exports.eqBoolean = exports.eqNumber = exports.eqString = exports.strictEqual = exports.eqStrict = exports.URI = exports.contramap = exports.fromEquals = void 0; -var function_1 = __nccwpck_require__(6985); +/*#__PURE__*/ (0, exports.traverseArray)(function_1.identity); // ------------------------------------------------------------------------------------- -// constructors +// legacy // ------------------------------------------------------------------------------------- /** - * @category constructors - * @since 2.0.0 + * Alias of `flatMap`. + * + * @category legacy + * @since 2.6.0 */ -function fromEquals(equals) { - return { - equals: function (x, y) { return x === y || equals(x, y); } - }; -} -exports.fromEquals = fromEquals; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -/* istanbul ignore next */ -var contramap_ = function (fa, f) { return function_1.pipe(fa, exports.contramap(f)); }; -// ------------------------------------------------------------------------------------- -// pipeables -// ------------------------------------------------------------------------------------- +exports.chainW = exports.flatMap; /** - * @category Contravariant + * Alias of `flatMap`. + * + * @category legacy * @since 2.0.0 */ -var contramap = function (f) { return function (fa) { - return fromEquals(function (x, y) { return fa.equals(f(x), f(y)); }); -}; }; -exports.contramap = contramap; -// ------------------------------------------------------------------------------------- -// instances -// ------------------------------------------------------------------------------------- +exports.chain = exports.flatMap; /** - * @category instances + * Alias of `tap`. + * + * @category legacy * @since 2.0.0 */ -exports.URI = 'Eq'; +exports.chainFirst = exports.tap; /** - * @category instances - * @since 2.5.0 + * Alias of `tap`. + * + * @category legacy + * @since 2.8.0 */ -exports.eqStrict = { - // tslint:disable-next-line: deprecation - equals: strictEqual -}; +exports.chainFirstW = exports.tap; /** - * Use `eqStrict` instead + * Use [`parse`](./Json.ts.html#parse) instead. * + * @category zone of death * @since 2.0.0 * @deprecated */ -function strictEqual(a, b) { - return a === b; +function parseJSON(s, onError) { + return (0, exports.tryCatch)(function () { return JSON.parse(s); }, onError); } -exports.strictEqual = strictEqual; +exports.parseJSON = parseJSON; /** - * @category instances + * Use [`stringify`](./Json.ts.html#stringify) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.eqString = exports.eqStrict; +var stringifyJSON = function (u, onError) { + return (0, exports.tryCatch)(function () { + var s = JSON.stringify(u); + if (typeof s !== 'string') { + throw new Error('Converting unsupported structure to JSON'); + } + return s; + }, onError); +}; +exports.stringifyJSON = stringifyJSON; /** - * @category instances + * This instance is deprecated, use small, specific instances instead. + * For example if a function needs a `Functor` instance, pass `E.Functor` instead of `E.either` + * (where `E` is from `import E from 'fp-ts/Either'`) + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.eqNumber = exports.eqStrict; +exports.either = { + URI: exports.URI, + map: _map, + of: exports.of, + ap: _ap, + chain: exports.flatMap, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, + sequence: exports.sequence, + bimap: _bimap, + mapLeft: _mapLeft, + alt: _alt, + extend: _extend, + chainRec: _chainRec, + throwError: exports.throwError +}; /** - * @category instances + * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. + * + * Semigroup returning the left-most `Left` value. If both operands are `Right`s then the inner values + * are concatenated using the provided `Semigroup` + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.eqBoolean = exports.eqStrict; +exports.getApplySemigroup = +/*#__PURE__*/ (0, Apply_1.getApplySemigroup)(exports.Apply); /** - * @category instances + * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function getStructEq(eqs) { - return fromEquals(function (x, y) { - for (var k in eqs) { - if (!eqs[k].equals(x[k], y[k])) { - return false; - } - } - return true; - }); -} -exports.getStructEq = getStructEq; +exports.getApplyMonoid = +/*#__PURE__*/ (0, Applicative_1.getApplicativeMonoid)(exports.Applicative); /** - * Given a tuple of `Eq`s returns a `Eq` for the tuple - * - * @example - * import { getTupleEq, eqString, eqNumber, eqBoolean } from 'fp-ts/Eq' + * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * - * const E = getTupleEq(eqString, eqNumber, eqBoolean) - * assert.strictEqual(E.equals(['a', 1, true], ['a', 1, true]), true) - * assert.strictEqual(E.equals(['a', 1, true], ['b', 1, true]), false) - * assert.strictEqual(E.equals(['a', 1, true], ['a', 2, true]), false) - * assert.strictEqual(E.equals(['a', 1, true], ['a', 1, false]), false) - * - * @category instances + * @category zone of death * @since 2.0.0 + * @deprecated */ -function getTupleEq() { - var eqs = []; - for (var _i = 0; _i < arguments.length; _i++) { - eqs[_i] = arguments[_i]; - } - return fromEquals(function (x, y) { return eqs.every(function (E, i) { return E.equals(x[i], y[i]); }); }); -} -exports.getTupleEq = getTupleEq; +var getValidationSemigroup = function (SE, SA) { + return (0, Apply_1.getApplySemigroup)((0, exports.getApplicativeValidation)(SE))(SA); +}; +exports.getValidationSemigroup = getValidationSemigroup; /** - * @category instances + * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.eqDate = { - equals: function (x, y) { return x.valueOf() === y.valueOf(); } -}; -var empty = { - equals: function () { return true; } +var getValidationMonoid = function (SE, MA) { + return (0, Applicative_1.getApplicativeMonoid)((0, exports.getApplicativeValidation)(SE))(MA); }; +exports.getValidationMonoid = getValidationMonoid; /** - * @category instances - * @since 2.6.0 + * Use [`getApplicativeValidation`](#getapplicativevalidation) and [`getAltValidation`](#getaltvalidation) instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated */ -function getMonoid() { +function getValidation(SE) { + var ap = (0, exports.getApplicativeValidation)(SE).ap; + var alt = (0, exports.getAltValidation)(SE).alt; return { - concat: function (x, y) { return fromEquals(function (a, b) { return x.equals(a, b) && y.equals(a, b); }); }, - empty: empty + URI: exports.URI, + _E: undefined, + map: _map, + of: exports.of, + chain: exports.flatMap, + bimap: _bimap, + mapLeft: _mapLeft, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + extend: _extend, + traverse: _traverse, + sequence: exports.sequence, + chainRec: _chainRec, + throwError: exports.throwError, + ap: ap, + alt: alt }; } -exports.getMonoid = getMonoid; -/** - * @category instances - * @since 2.7.0 - */ -exports.Contravariant = { - URI: exports.URI, - contramap: contramap_ -}; -// TODO: remove in v3 -/** - * @category instances - * @since 2.0.0 - */ -exports.eq = exports.Contravariant; +exports.getValidation = getValidation; /***/ }), -/***/ 240: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 6964: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.reduceRight = exports.reduceWithIndex = exports.reduce = exports.mapWithIndex = exports.map = exports.flatten = exports.extend = exports.duplicate = exports.chainFirst = exports.chain = exports.apSecond = exports.apFirst = exports.ap = exports.alt = exports.altW = exports.foldMap = exports.foldMapWithIndex = exports.intersperse = exports.prependToAll = exports.unzip = exports.zip = exports.zipWith = exports.fold = exports.concat = exports.of = exports.filterWithIndex = exports.filter = exports.copy = exports.modifyAt = exports.updateAt = exports.insertAt = exports.sort = exports.init = exports.last = exports.groupBy = exports.groupSort = exports.group = exports.getEq = exports.getSemigroup = exports.max = exports.min = exports.reverse = exports.tail = exports.head = exports.getShow = exports.unsnoc = exports.uncons = exports.fromArray = exports.snoc = exports.cons = void 0; -exports.apS = exports.bind = exports.bindTo = exports.Do = exports.nonEmptyArray = exports.Comonad = exports.Alt = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.Monad = exports.Applicative = exports.FunctorWithIndex = exports.Functor = exports.URI = exports.extract = exports.traverseWithIndex = exports.sequence = exports.traverse = exports.reduceRightWithIndex = void 0; -var RNEA = __importStar(__nccwpck_require__(8630)); -/* tslint:enable:readonly-keyword */ +exports.eqDate = exports.eqNumber = exports.eqString = exports.eqBoolean = exports.eq = exports.strictEqual = exports.getStructEq = exports.getTupleEq = exports.Contravariant = exports.getMonoid = exports.getSemigroup = exports.eqStrict = exports.URI = exports.contramap = exports.tuple = exports.struct = exports.fromEquals = void 0; +var function_1 = __nccwpck_require__(6985); +// ------------------------------------------------------------------------------------- +// constructors +// ------------------------------------------------------------------------------------- /** - * Append an element to the front of an array, creating a new non empty array - * - * @example - * import { cons } from 'fp-ts/NonEmptyArray' - * - * assert.deepStrictEqual(cons(1, [2, 3, 4]), [1, 2, 3, 4]) - * * @category constructors * @since 2.0.0 */ -exports.cons = RNEA.cons; +var fromEquals = function (equals) { return ({ + equals: function (x, y) { return x === y || equals(x, y); } +}); }; +exports.fromEquals = fromEquals; +// ------------------------------------------------------------------------------------- +// combinators +// ------------------------------------------------------------------------------------- +/** + * @since 2.10.0 + */ +var struct = function (eqs) { + return (0, exports.fromEquals)(function (first, second) { + for (var key in eqs) { + if (!eqs[key].equals(first[key], second[key])) { + return false; + } + } + return true; + }); +}; +exports.struct = struct; /** - * Append an element to the end of an array, creating a new non empty array + * Given a tuple of `Eq`s returns a `Eq` for the tuple * * @example - * import { snoc } from 'fp-ts/NonEmptyArray' + * import { tuple } from 'fp-ts/Eq' + * import * as S from 'fp-ts/string' + * import * as N from 'fp-ts/number' + * import * as B from 'fp-ts/boolean' * - * assert.deepStrictEqual(snoc([1, 2, 3], 4), [1, 2, 3, 4]) + * const E = tuple(S.Eq, N.Eq, B.Eq) + * assert.strictEqual(E.equals(['a', 1, true], ['a', 1, true]), true) + * assert.strictEqual(E.equals(['a', 1, true], ['b', 1, true]), false) + * assert.strictEqual(E.equals(['a', 1, true], ['a', 2, true]), false) + * assert.strictEqual(E.equals(['a', 1, true], ['a', 1, false]), false) * - * @category constructors - * @since 2.0.0 + * @since 2.10.0 */ -exports.snoc = RNEA.snoc; +var tuple = function () { + var eqs = []; + for (var _i = 0; _i < arguments.length; _i++) { + eqs[_i] = arguments[_i]; + } + return (0, exports.fromEquals)(function (first, second) { return eqs.every(function (E, i) { return E.equals(first[i], second[i]); }); }); +}; +exports.tuple = tuple; +/* istanbul ignore next */ +var contramap_ = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.contramap)(f)); }; /** - * Builds a `NonEmptyArray` from an `Array` returning `none` if `as` is an empty array + * A typical use case for `contramap` would be like, given some `User` type, to construct an `Eq`. * - * @category constructors - * @since 2.0.0 - */ -exports.fromArray = RNEA.fromArray; -/** - * Produces a couple of the first element of the array, and a new array of the remaining elements, if any + * We can do so with a function from `User -> X` where `X` is some value that we know how to compare + * for equality (meaning we have an `Eq`) + * + * For example, given the following `User` type, we want to construct an `Eq` that just looks at the `key` field + * for each user (since it's known to be unique). + * + * If we have a way of comparing `UUID`s for equality (`eqUUID: Eq`) and we know how to go from `User -> UUID`, + * using `contramap` we can do this * * @example - * import { cons, uncons } from 'fp-ts/NonEmptyArray' + * import { contramap, Eq } from 'fp-ts/Eq' + * import { pipe } from 'fp-ts/function' + * import * as S from 'fp-ts/string' * - * assert.deepStrictEqual(uncons(cons(1, [2, 3, 4])), [1, [2, 3, 4]]) + * type UUID = string * - * @category destructors - * @since 2.9.0 - */ -exports.uncons = RNEA.uncons; -/** - * Produces a couple of a copy of the array without its last element, and that last element + * interface User { + * readonly key: UUID + * readonly firstName: string + * readonly lastName: string + * } * - * @example - * import { snoc, unsnoc } from 'fp-ts/NonEmptyArray' + * const eqUUID: Eq = S.Eq * - * assert.deepStrictEqual(unsnoc(snoc([1, 2, 3], 4)), [[1, 2, 3], 4]) + * const eqUserByKey: Eq = pipe( + * eqUUID, + * contramap((user) => user.key) + * ) + * + * assert.deepStrictEqual( + * eqUserByKey.equals( + * { key: 'k1', firstName: 'a1', lastName: 'b1' }, + * { key: 'k2', firstName: 'a1', lastName: 'b1' } + * ), + * false + * ) + * assert.deepStrictEqual( + * eqUserByKey.equals( + * { key: 'k1', firstName: 'a1', lastName: 'b1' }, + * { key: 'k1', firstName: 'a2', lastName: 'b1' } + * ), + * true + * ) * - * @category destructors - * @since 2.9.0 - */ -exports.unsnoc = RNEA.unsnoc; -/** - * @category instances - * @since 2.0.0 - */ -exports.getShow = RNEA.getShow; -/** * @since 2.0.0 */ -exports.head = RNEA.head; +var contramap = function (f) { return function (fa) { + return (0, exports.fromEquals)(function (x, y) { return fa.equals(f(x), f(y)); }); +}; }; +exports.contramap = contramap; /** + * @category type lambdas * @since 2.0.0 */ -exports.tail = RNEA.tail; +exports.URI = 'Eq'; /** - * @category combinators - * @since 2.0.0 + * @category instances + * @since 2.5.0 */ -exports.reverse = RNEA.reverse; +exports.eqStrict = { + equals: function (a, b) { return a === b; } +}; +var empty = { + equals: function () { return true; } +}; /** - * @since 2.0.0 + * @category instances + * @since 2.10.0 */ -exports.min = RNEA.min; +var getSemigroup = function () { return ({ + concat: function (x, y) { return (0, exports.fromEquals)(function (a, b) { return x.equals(a, b) && y.equals(a, b); }); } +}); }; +exports.getSemigroup = getSemigroup; /** - * @since 2.0.0 + * @category instances + * @since 2.6.0 */ -exports.max = RNEA.max; +var getMonoid = function () { return ({ + concat: (0, exports.getSemigroup)().concat, + empty: empty +}); }; +exports.getMonoid = getMonoid; /** - * Builds a `Semigroup` instance for `NonEmptyArray` - * * @category instances - * @since 2.0.0 + * @since 2.7.0 */ -exports.getSemigroup = RNEA.getSemigroup; +exports.Contravariant = { + URI: exports.URI, + contramap: contramap_ +}; +// ------------------------------------------------------------------------------------- +// deprecated +// ------------------------------------------------------------------------------------- /** - * @example - * import { getEq, cons } from 'fp-ts/NonEmptyArray' - * import { eqNumber } from 'fp-ts/Eq' + * Use [`tuple`](#tuple) instead. * - * const E = getEq(eqNumber) - * assert.strictEqual(E.equals(cons(1, [2]), [1, 2]), true) - * assert.strictEqual(E.equals(cons(1, [2]), [1, 3]), false) - * - * @category instances + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.getEq = RNEA.getEq; -function group(E) { - return RNEA.group(E); -} -exports.group = group; +exports.getTupleEq = exports.tuple; /** - * Sort and then group the elements of an array into non empty arrays. - * - * @example - * import { cons, groupSort } from 'fp-ts/NonEmptyArray' - * import { ordNumber } from 'fp-ts/Ord' - * - * assert.deepStrictEqual(groupSort(ordNumber)([1, 2, 1, 1]), [cons(1, [1, 1]), cons(2, [])]) + * Use [`struct`](#struct) instead. * - * @category combinators + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.groupSort = RNEA.groupSort; +exports.getStructEq = exports.struct; /** - * Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning - * function on each element, and grouping the results according to values returned + * Use [`eqStrict`](#eqstrict) instead * - * @example - * import { cons, groupBy } from 'fp-ts/NonEmptyArray' - * - * assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['foo', 'bar', 'foobar']), { - * '3': cons('foo', ['bar']), - * '6': cons('foobar', []) - * }) - * - * @category constructors + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.groupBy = RNEA.groupBy; +exports.strictEqual = exports.eqStrict.equals; /** + * This instance is deprecated, use small, specific instances instead. + * For example if a function needs a `Contravariant` instance, pass `E.Contravariant` instead of `E.eq` + * (where `E` is from `import E from 'fp-ts/Eq'`) + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.last = RNEA.last; +exports.eq = exports.Contravariant; /** - * Get all but the last element of a non empty array, creating a new array. - * - * @example - * import { init } from 'fp-ts/NonEmptyArray' - * - * assert.deepStrictEqual(init([1, 2, 3]), [1, 2]) - * assert.deepStrictEqual(init([1]), []) + * Use [`Eq`](./boolean.ts.html#eq) instead. * - * @since 2.2.0 - */ -exports.init = RNEA.init; -/** - * @category combinators + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.sort = RNEA.sort; +exports.eqBoolean = exports.eqStrict; /** + * Use [`Eq`](./string.ts.html#eq) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.insertAt = RNEA.insertAt; +exports.eqString = exports.eqStrict; /** + * Use [`Eq`](./number.ts.html#eq) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.updateAt = RNEA.updateAt; +exports.eqNumber = exports.eqStrict; /** + * Use [`Eq`](./Date.ts.html#eq) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.modifyAt = RNEA.modifyAt; +exports.eqDate = { + equals: function (first, second) { return first.valueOf() === second.valueOf(); } +}; + + +/***/ }), + +/***/ 1964: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + /** - * @category combinators - * @since 2.0.0 + * The `FromEither` type class represents those data types which support errors. + * + * @since 2.10.0 */ -function copy(nea) { - var l = nea.length; - var as = Array(l); - for (var i = 0; i < l; i++) { - as[i] = nea[i]; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; } - return as; + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.tapEither = exports.filterOrElse = exports.chainFirstEitherK = exports.chainEitherK = exports.fromEitherK = exports.chainOptionK = exports.fromOptionK = exports.fromPredicate = exports.fromOption = void 0; +var Chain_1 = __nccwpck_require__(2372); +var function_1 = __nccwpck_require__(6985); +var _ = __importStar(__nccwpck_require__(1840)); +function fromOption(F) { + return function (onNone) { return function (ma) { return F.fromEither(_.isNone(ma) ? _.left(onNone()) : _.right(ma.value)); }; }; } -exports.copy = copy; -function filter(predicate) { - return RNEA.filter(predicate); +exports.fromOption = fromOption; +function fromPredicate(F) { + return function (predicate, onFalse) { + return function (a) { + return F.fromEither(predicate(a) ? _.right(a) : _.left(onFalse(a))); + }; + }; } -exports.filter = filter; +exports.fromPredicate = fromPredicate; +function fromOptionK(F) { + var fromOptionF = fromOption(F); + return function (onNone) { + var from = fromOptionF(onNone); + return function (f) { return (0, function_1.flow)(f, from); }; + }; +} +exports.fromOptionK = fromOptionK; +function chainOptionK(F, M) { + var fromOptionKF = fromOptionK(F); + return function (onNone) { + var from = fromOptionKF(onNone); + return function (f) { return function (ma) { return M.chain(ma, from(f)); }; }; + }; +} +exports.chainOptionK = chainOptionK; +function fromEitherK(F) { + return function (f) { return (0, function_1.flow)(f, F.fromEither); }; +} +exports.fromEitherK = fromEitherK; +function chainEitherK(F, M) { + var fromEitherKF = fromEitherK(F); + return function (f) { return function (ma) { return M.chain(ma, fromEitherKF(f)); }; }; +} +exports.chainEitherK = chainEitherK; +function chainFirstEitherK(F, M) { + var tapEitherM = tapEither(F, M); + return function (f) { return function (ma) { return tapEitherM(ma, f); }; }; +} +exports.chainFirstEitherK = chainFirstEitherK; +function filterOrElse(F, M) { + return function (predicate, onFalse) { + return function (ma) { + return M.chain(ma, function (a) { return F.fromEither(predicate(a) ? _.right(a) : _.left(onFalse(a))); }); + }; + }; +} +exports.filterOrElse = filterOrElse; +/** @internal */ +function tapEither(F, M) { + var fromEither = fromEitherK(F); + var tapM = (0, Chain_1.tap)(M); + return function (self, f) { return tapM(self, fromEither(f)); }; +} +exports.tapEither = tapEither; + + +/***/ }), + +/***/ 5533: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.asUnit = exports.as = exports.getFunctorComposition = exports["let"] = exports.bindTo = exports.flap = exports.map = void 0; /** + * A `Functor` is a type constructor which supports a mapping operation `map`. + * + * `map` can be used to turn functions `a -> b` into functions `f a -> f b` whose argument and return types use the type + * constructor `f` to represent some computational context. + * + * Instances must satisfy the following laws: + * + * 1. Identity: `F.map(fa, a => a) <-> fa` + * 2. Composition: `F.map(fa, a => bc(ab(a))) <-> F.map(F.map(fa, ab), bc)` + * * @since 2.0.0 */ -exports.filterWithIndex = RNEA.filterWithIndex; +var function_1 = __nccwpck_require__(6985); +function map(F, G) { + return function (f) { return function (fa) { return F.map(fa, function (ga) { return G.map(ga, f); }); }; }; +} +exports.map = map; +function flap(F) { + return function (a) { return function (fab) { return F.map(fab, function (f) { return f(a); }); }; }; +} +exports.flap = flap; +function bindTo(F) { + return function (name) { return function (fa) { return F.map(fa, function (a) { + var _a; + return (_a = {}, _a[name] = a, _a); + }); }; }; +} +exports.bindTo = bindTo; +function let_(F) { + return function (name, f) { return function (fa) { return F.map(fa, function (a) { + var _a; + return Object.assign({}, a, (_a = {}, _a[name] = f(a), _a)); + }); }; }; +} +exports["let"] = let_; +/** @deprecated */ +function getFunctorComposition(F, G) { + var _map = map(F, G); + return { + map: function (fga, f) { return (0, function_1.pipe)(fga, _map(f)); } + }; +} +exports.getFunctorComposition = getFunctorComposition; +/** @internal */ +function as(F) { + return function (self, b) { return F.map(self, function () { return b; }); }; +} +exports.as = as; +/** @internal */ +function asUnit(F) { + var asM = as(F); + return function (self) { return asM(self, undefined); }; +} +exports.asUnit = asUnit; + + +/***/ }), + +/***/ 179: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + /** - * Wrap a value into the type constructor. + * A `Magma` is a pair `(A, concat)` in which `A` is a non-empty set and `concat` is a binary operation on `A` + * + * See [Semigroup](https://gcanti.github.io/fp-ts/modules/Semigroup.ts.html) for some instances. * - * @category Applicative * @since 2.0.0 */ -exports.of = RNEA.of; -function concat(fx, fy) { - return RNEA.concat(fx, fy); -} -exports.concat = concat; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.concatAll = exports.endo = exports.filterSecond = exports.filterFirst = exports.reverse = void 0; +// ------------------------------------------------------------------------------------- +// combinators +// ------------------------------------------------------------------------------------- /** - * @since 2.5.0 + * The dual of a `Magma`, obtained by swapping the arguments of `concat`. + * + * @example + * import { reverse, concatAll } from 'fp-ts/Magma' + * import * as N from 'fp-ts/number' + * + * const subAll = concatAll(reverse(N.MagmaSub))(0) + * + * assert.deepStrictEqual(subAll([1, 2, 3]), 2) + * + * @since 2.11.0 */ -exports.fold = RNEA.fold; +var reverse = function (M) { return ({ + concat: function (first, second) { return M.concat(second, first); } +}); }; +exports.reverse = reverse; /** - * @category combinators - * @since 2.5.1 + * @since 2.11.0 */ -exports.zipWith = RNEA.zipWith; +var filterFirst = function (predicate) { + return function (M) { return ({ + concat: function (first, second) { return (predicate(first) ? M.concat(first, second) : second); } + }); }; +}; +exports.filterFirst = filterFirst; /** - * @category combinators - * @since 2.5.1 + * @since 2.11.0 */ -exports.zip = RNEA.zip; +var filterSecond = function (predicate) { + return function (M) { return ({ + concat: function (first, second) { return (predicate(second) ? M.concat(first, second) : first); } + }); }; +}; +exports.filterSecond = filterSecond; /** - * @since 2.5.1 + * @since 2.11.0 */ -exports.unzip = RNEA.unzip; +var endo = function (f) { + return function (M) { return ({ + concat: function (first, second) { return M.concat(f(first), f(second)); } + }); }; +}; +exports.endo = endo; +// ------------------------------------------------------------------------------------- +// utils +// ------------------------------------------------------------------------------------- /** - * Prepend an element to every member of an array - * - * @example - * import { cons, prependToAll } from 'fp-ts/NonEmptyArray' + * Given a sequence of `as`, concat them and return the total. * - * assert.deepStrictEqual(prependToAll(9)(cons(1, [2, 3, 4])), cons(9, [1, 9, 2, 9, 3, 9, 4])) - * - * @category combinators - * @since 2.9.0 - */ -exports.prependToAll = RNEA.prependToAll; -/** - * Places an element in between members of an array + * If `as` is empty, return the provided `startWith` value. * * @example - * import { cons, intersperse } from 'fp-ts/NonEmptyArray' + * import { concatAll } from 'fp-ts/Magma' + * import * as N from 'fp-ts/number' * - * assert.deepStrictEqual(intersperse(9)(cons(1, [2, 3, 4])), cons(1, [9, 2, 9, 3, 9, 4])) + * const subAll = concatAll(N.MagmaSub)(0) * - * @category combinators - * @since 2.9.0 + * assert.deepStrictEqual(subAll([1, 2, 3]), -6) + * + * @since 2.11.0 */ -exports.intersperse = RNEA.intersperse; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -var map_ = RNEA.Functor.map; -var mapWithIndex_ = RNEA.FunctorWithIndex.mapWithIndex; -var ap_ = RNEA.Applicative.ap; -var chain_ = RNEA.Monad.chain; -var extend_ = RNEA.Comonad.extend; -var reduce_ = RNEA.Foldable.reduce; -var foldMap_ = RNEA.Foldable.foldMap; -var reduceRight_ = RNEA.Foldable.reduceRight; -var traverse_ = RNEA.Traversable.traverse; -var alt_ = RNEA.Alt.alt; -var reduceWithIndex_ = RNEA.FoldableWithIndex - .reduceWithIndex; -var foldMapWithIndex_ = RNEA.FoldableWithIndex - .foldMapWithIndex; -var reduceRightWithIndex_ = RNEA.FoldableWithIndex - .reduceRightWithIndex; -var traverseWithIndex_ = RNEA.TraversableWithIndex - .traverseWithIndex; +var concatAll = function (M) { + return function (startWith) { + return function (as) { + return as.reduce(function (a, acc) { return M.concat(a, acc); }, startWith); + }; + }; +}; +exports.concatAll = concatAll; + + +/***/ }), + +/***/ 240: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.mapWithIndex = exports.map = exports.flatten = exports.duplicate = exports.extend = exports.flatMap = exports.ap = exports.alt = exports.altW = exports.chunksOf = exports.splitAt = exports.chop = exports.chainWithIndex = exports.foldMap = exports.foldMapWithIndex = exports.intersperse = exports.prependAll = exports.unzip = exports.zip = exports.zipWith = exports.of = exports.copy = exports.modifyAt = exports.updateAt = exports.insertAt = exports.sort = exports.groupBy = exports.group = exports.reverse = exports.concat = exports.concatW = exports.unappend = exports.unprepend = exports.range = exports.replicate = exports.makeBy = exports.fromArray = exports.fromReadonlyNonEmptyArray = exports.rotate = exports.union = exports.sortBy = exports.uniq = exports.unsafeUpdateAt = exports.unsafeInsertAt = exports.append = exports.appendW = exports.prepend = exports.prependW = exports.isOutOfBound = exports.isNonEmpty = void 0; +exports.chain = exports.intercalate = exports.updateLast = exports.modifyLast = exports.updateHead = exports.modifyHead = exports.matchRight = exports.matchLeft = exports.concatAll = exports.max = exports.min = exports.init = exports.last = exports.tail = exports.head = exports.apS = exports.bind = exports["let"] = exports.bindTo = exports.Do = exports.Comonad = exports.Alt = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.Monad = exports.chainFirst = exports.Chain = exports.Applicative = exports.apSecond = exports.apFirst = exports.Apply = exports.FunctorWithIndex = exports.Pointed = exports.flap = exports.Functor = exports.getUnionSemigroup = exports.getEq = exports.getSemigroup = exports.getShow = exports.URI = exports.extract = exports.traverseWithIndex = exports.sequence = exports.traverse = exports.reduceRightWithIndex = exports.reduceRight = exports.reduceWithIndex = exports.reduce = void 0; +exports.nonEmptyArray = exports.fold = exports.prependToAll = exports.snoc = exports.cons = exports.unsnoc = exports.uncons = exports.filterWithIndex = exports.filter = exports.groupSort = void 0; +var Apply_1 = __nccwpck_require__(205); +var Chain_1 = __nccwpck_require__(2372); +var function_1 = __nccwpck_require__(6985); +var Functor_1 = __nccwpck_require__(5533); +var _ = __importStar(__nccwpck_require__(1840)); +var Ord_1 = __nccwpck_require__(6685); +var RNEA = __importStar(__nccwpck_require__(8630)); // ------------------------------------------------------------------------------------- -// pipeables +// internal // ------------------------------------------------------------------------------------- /** - * @category FoldableWithIndex - * @since 2.0.0 + * @internal */ -exports.foldMapWithIndex = RNEA.foldMapWithIndex; +var isNonEmpty = function (as) { return as.length > 0; }; +exports.isNonEmpty = isNonEmpty; /** - * @category Foldable - * @since 2.0.0 + * @internal */ -exports.foldMap = RNEA.foldMap; +var isOutOfBound = function (i, as) { return i < 0 || i >= as.length; }; +exports.isOutOfBound = isOutOfBound; /** - * Less strict version of [`alt`](#alt). - * - * @category Alt - * @since 2.9.0 + * @internal */ -exports.altW = RNEA.altW; +var prependW = function (head) { + return function (tail) { + return __spreadArray([head], tail, true); + }; +}; +exports.prependW = prependW; /** - * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to - * types of kind `* -> *`. - * - * @category Alt - * @since 2.6.2 + * @internal */ -exports.alt = RNEA.alt; +exports.prepend = exports.prependW; /** - * Apply a function to an argument under a type constructor. - * - * @category Apply - * @since 2.0.0 + * @internal */ -exports.ap = RNEA.ap; +var appendW = function (end) { + return function (init) { + return __spreadArray(__spreadArray([], init, true), [end], false); + }; +}; +exports.appendW = appendW; /** - * Combine two effectful actions, keeping only the result of the first. - * - * Derivable from `Apply`. - * - * @category combinators - * @since 2.0.0 + * @internal */ -exports.apFirst = RNEA.apFirst; +exports.append = exports.appendW; /** - * Combine two effectful actions, keeping only the result of the second. - * - * Derivable from `Apply`. - * - * @category combinators - * @since 2.0.0 + * @internal */ -exports.apSecond = RNEA.apSecond; +var unsafeInsertAt = function (i, a, as) { + if ((0, exports.isNonEmpty)(as)) { + var xs = (0, exports.fromReadonlyNonEmptyArray)(as); + xs.splice(i, 0, a); + return xs; + } + return [a]; +}; +exports.unsafeInsertAt = unsafeInsertAt; /** - * Composes computations in sequence, using the return value of one computation to determine the next computation. - * - * @category Monad - * @since 2.0.0 + * @internal */ -exports.chain = RNEA.chain; +var unsafeUpdateAt = function (i, a, as) { + var xs = (0, exports.fromReadonlyNonEmptyArray)(as); + xs[i] = a; + return xs; +}; +exports.unsafeUpdateAt = unsafeUpdateAt; /** - * Composes computations in sequence, using the return value of one computation to determine the next computation and - * keeping only the result of the first. + * Remove duplicates from a `NonEmptyArray`, keeping the first occurrence of an element. + * + * @example + * import { uniq } from 'fp-ts/NonEmptyArray' + * import * as N from 'fp-ts/number' * - * Derivable from `Monad`. + * assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2]) * - * @category combinators - * @since 2.0.0 + * @since 2.11.0 */ -exports.chainFirst = RNEA.chainFirst; +var uniq = function (E) { + return function (as) { + if (as.length === 1) { + return (0, exports.copy)(as); + } + var out = [(0, exports.head)(as)]; + var rest = (0, exports.tail)(as); + var _loop_1 = function (a) { + if (out.every(function (o) { return !E.equals(o, a); })) { + out.push(a); + } + }; + for (var _i = 0, rest_1 = rest; _i < rest_1.length; _i++) { + var a = rest_1[_i]; + _loop_1(a); + } + return out; + }; +}; +exports.uniq = uniq; /** - * Derivable from `Extend`. + * Sort the elements of a `NonEmptyArray` in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`, + * etc... * - * @category combinators - * @since 2.0.0 + * @example + * import * as NEA from 'fp-ts/NonEmptyArray' + * import { contramap } from 'fp-ts/Ord' + * import * as S from 'fp-ts/string' + * import * as N from 'fp-ts/number' + * import { pipe } from 'fp-ts/function' + * + * interface Person { + * name: string + * age: number + * } + * + * const byName = pipe(S.Ord, contramap((p: Person) => p.name)) + * + * const byAge = pipe(N.Ord, contramap((p: Person) => p.age)) + * + * const sortByNameByAge = NEA.sortBy([byName, byAge]) + * + * const persons: NEA.NonEmptyArray = [ + * { name: 'a', age: 1 }, + * { name: 'b', age: 3 }, + * { name: 'c', age: 2 }, + * { name: 'b', age: 2 } + * ] + * + * assert.deepStrictEqual(sortByNameByAge(persons), [ + * { name: 'a', age: 1 }, + * { name: 'b', age: 2 }, + * { name: 'b', age: 3 }, + * { name: 'c', age: 2 } + * ]) + * + * @since 2.11.0 */ -exports.duplicate = RNEA.duplicate; +var sortBy = function (ords) { + if ((0, exports.isNonEmpty)(ords)) { + var M = (0, Ord_1.getMonoid)(); + return (0, exports.sort)(ords.reduce(M.concat, M.empty)); + } + return exports.copy; +}; +exports.sortBy = sortBy; /** - * @category Extend - * @since 2.0.0 + * @since 2.11.0 */ -exports.extend = RNEA.extend; +var union = function (E) { + var uniqE = (0, exports.uniq)(E); + return function (second) { return function (first) { return uniqE((0, function_1.pipe)(first, concat(second))); }; }; +}; +exports.union = union; /** - * Derivable from `Monad`. + * Rotate a `NonEmptyArray` by `n` steps. * - * @category combinators - * @since 2.0.0 - */ -exports.flatten = RNEA.flatten; -/** - * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types - * use the type constructor `F` to represent some computational context. + * @example + * import { rotate } from 'fp-ts/NonEmptyArray' * - * @category Functor - * @since 2.0.0 + * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3]) + * assert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2]) + * + * @since 2.11.0 */ -exports.map = RNEA.map; +var rotate = function (n) { + return function (as) { + var len = as.length; + var m = Math.round(n) % len; + if ((0, exports.isOutOfBound)(Math.abs(m), as) || m === 0) { + return (0, exports.copy)(as); + } + if (m < 0) { + var _a = (0, exports.splitAt)(-m)(as), f = _a[0], s = _a[1]; + return (0, function_1.pipe)(s, concat(f)); + } + else { + return (0, exports.rotate)(m - len)(as); + } + }; +}; +exports.rotate = rotate; +// ------------------------------------------------------------------------------------- +// constructors +// ------------------------------------------------------------------------------------- /** - * @category FunctorWithIndex - * @since 2.0.0 + * @category conversions + * @since 2.10.0 */ -exports.mapWithIndex = RNEA.mapWithIndex; +exports.fromReadonlyNonEmptyArray = _.fromReadonlyNonEmptyArray; /** - * @category Foldable + * Builds a `NonEmptyArray` from an `Array` returning `none` if `as` is an empty array + * + * @category conversions * @since 2.0.0 */ -exports.reduce = RNEA.reduce; +var fromArray = function (as) { return ((0, exports.isNonEmpty)(as) ? _.some(as) : _.none); }; +exports.fromArray = fromArray; /** - * @category FoldableWithIndex - * @since 2.0.0 - */ -exports.reduceWithIndex = RNEA.reduceWithIndex; + * Return a `NonEmptyArray` of length `n` with element `i` initialized with `f(i)`. + * + * **Note**. `n` is normalized to a natural number. + * + * @example + * import { makeBy } from 'fp-ts/NonEmptyArray' + * import { pipe } from 'fp-ts/function' + * + * const double = (n: number): number => n * 2 + * assert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8]) + * + * @category constructors + * @since 2.11.0 + */ +var makeBy = function (f) { + return function (n) { + var j = Math.max(0, Math.floor(n)); + var out = [f(0)]; + for (var i = 1; i < j; i++) { + out.push(f(i)); + } + return out; + }; +}; +exports.makeBy = makeBy; /** - * @category Foldable - * @since 2.0.0 - */ + * Create a `NonEmptyArray` containing a value repeated the specified number of times. + * + * **Note**. `n` is normalized to a natural number. + * + * @example + * import { replicate } from 'fp-ts/NonEmptyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a']) + * + * @category constructors + * @since 2.11.0 + */ +var replicate = function (a) { return (0, exports.makeBy)(function () { return a; }); }; +exports.replicate = replicate; +/** + * Create a `NonEmptyArray` containing a range of integers, including both endpoints. + * + * @example + * import { range } from 'fp-ts/NonEmptyArray' + * + * assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5]) + * + * @category constructors + * @since 2.11.0 + */ +var range = function (start, end) { + return start <= end ? (0, exports.makeBy)(function (i) { return start + i; })(end - start + 1) : [start]; +}; +exports.range = range; +/** + * Return the tuple of the `head` and the `tail`. + * + * @example + * import { unprepend } from 'fp-ts/NonEmptyArray' + * + * assert.deepStrictEqual(unprepend([1, 2, 3]), [1, [2, 3]]) + * + * @since 2.9.0 + */ +var unprepend = function (as) { return [(0, exports.head)(as), (0, exports.tail)(as)]; }; +exports.unprepend = unprepend; +/** + * Return the tuple of the `init` and the `last`. + * + * @example + * import { unappend } from 'fp-ts/NonEmptyArray' + * + * assert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4]) + * + * @since 2.9.0 + */ +var unappend = function (as) { return [(0, exports.init)(as), (0, exports.last)(as)]; }; +exports.unappend = unappend; +function concatW(second) { + return function (first) { return first.concat(second); }; +} +exports.concatW = concatW; +function concat(x, y) { + return y ? x.concat(y) : function (y) { return y.concat(x); }; +} +exports.concat = concat; +/** + * @since 2.0.0 + */ +var reverse = function (as) { return __spreadArray([(0, exports.last)(as)], as.slice(0, -1).reverse(), true); }; +exports.reverse = reverse; +function group(E) { + return function (as) { + var len = as.length; + if (len === 0) { + return []; + } + var out = []; + var head = as[0]; + var nea = [head]; + for (var i = 1; i < len; i++) { + var a = as[i]; + if (E.equals(a, head)) { + nea.push(a); + } + else { + out.push(nea); + head = a; + nea = [head]; + } + } + out.push(nea); + return out; + }; +} +exports.group = group; +/** + * Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning + * function on each element, and grouping the results according to values returned + * + * @example + * import { groupBy } from 'fp-ts/NonEmptyArray' + * + * assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), { + * '1': ['a', 'b'], + * '2': ['ab'] + * }) + * + * @since 2.0.0 + */ +var groupBy = function (f) { + return function (as) { + var out = {}; + for (var _i = 0, as_1 = as; _i < as_1.length; _i++) { + var a = as_1[_i]; + var k = f(a); + if (_.has.call(out, k)) { + out[k].push(a); + } + else { + out[k] = [a]; + } + } + return out; + }; +}; +exports.groupBy = groupBy; +/** + * @since 2.0.0 + */ +var sort = function (O) { + return function (as) { + return as.slice().sort(O.compare); + }; +}; +exports.sort = sort; +/** + * @since 2.0.0 + */ +var insertAt = function (i, a) { + return function (as) { + return i < 0 || i > as.length ? _.none : _.some((0, exports.unsafeInsertAt)(i, a, as)); + }; +}; +exports.insertAt = insertAt; +/** + * @since 2.0.0 + */ +var updateAt = function (i, a) { + return (0, exports.modifyAt)(i, function () { return a; }); +}; +exports.updateAt = updateAt; +/** + * @since 2.0.0 + */ +var modifyAt = function (i, f) { + return function (as) { + return (0, exports.isOutOfBound)(i, as) ? _.none : _.some((0, exports.unsafeUpdateAt)(i, f(as[i]), as)); + }; +}; +exports.modifyAt = modifyAt; +/** + * @since 2.0.0 + */ +exports.copy = exports.fromReadonlyNonEmptyArray; +/** + * @category constructors + * @since 2.0.0 + */ +var of = function (a) { return [a]; }; +exports.of = of; +/** + * @since 2.5.1 + */ +var zipWith = function (as, bs, f) { + var cs = [f(as[0], bs[0])]; + var len = Math.min(as.length, bs.length); + for (var i = 1; i < len; i++) { + cs[i] = f(as[i], bs[i]); + } + return cs; +}; +exports.zipWith = zipWith; +function zip(as, bs) { + if (bs === undefined) { + return function (bs) { return zip(bs, as); }; + } + return (0, exports.zipWith)(as, bs, function (a, b) { return [a, b]; }); +} +exports.zip = zip; +/** + * @since 2.5.1 + */ +var unzip = function (abs) { + var fa = [abs[0][0]]; + var fb = [abs[0][1]]; + for (var i = 1; i < abs.length; i++) { + fa[i] = abs[i][0]; + fb[i] = abs[i][1]; + } + return [fa, fb]; +}; +exports.unzip = unzip; +/** + * Prepend an element to every member of an array + * + * @example + * import { prependAll } from 'fp-ts/NonEmptyArray' + * + * assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4]) + * + * @since 2.10.0 + */ +var prependAll = function (middle) { + return function (as) { + var out = [middle, as[0]]; + for (var i = 1; i < as.length; i++) { + out.push(middle, as[i]); + } + return out; + }; +}; +exports.prependAll = prependAll; +/** + * Places an element in between members of an array + * + * @example + * import { intersperse } from 'fp-ts/NonEmptyArray' + * + * assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4]) + * + * @since 2.9.0 + */ +var intersperse = function (middle) { + return function (as) { + var rest = (0, exports.tail)(as); + return (0, exports.isNonEmpty)(rest) ? (0, function_1.pipe)(rest, (0, exports.prependAll)(middle), (0, exports.prepend)((0, exports.head)(as))) : (0, exports.copy)(as); + }; +}; +exports.intersperse = intersperse; +/** + * @category folding + * @since 2.0.0 + */ +exports.foldMapWithIndex = RNEA.foldMapWithIndex; +/** + * @category folding + * @since 2.0.0 + */ +exports.foldMap = RNEA.foldMap; +/** + * @category sequencing + * @since 2.10.0 + */ +var chainWithIndex = function (f) { + return function (as) { + var out = (0, exports.fromReadonlyNonEmptyArray)(f(0, (0, exports.head)(as))); + for (var i = 1; i < as.length; i++) { + out.push.apply(out, f(i, as[i])); + } + return out; + }; +}; +exports.chainWithIndex = chainWithIndex; +/** + * @since 2.10.0 + */ +var chop = function (f) { + return function (as) { + var _a = f(as), b = _a[0], rest = _a[1]; + var out = [b]; + var next = rest; + while ((0, exports.isNonEmpty)(next)) { + var _b = f(next), b_1 = _b[0], rest_2 = _b[1]; + out.push(b_1); + next = rest_2; + } + return out; + }; +}; +exports.chop = chop; +/** + * Splits a `NonEmptyArray` into two pieces, the first piece has max `n` elements. + * + * @since 2.10.0 + */ +var splitAt = function (n) { + return function (as) { + var m = Math.max(1, n); + return m >= as.length ? [(0, exports.copy)(as), []] : [(0, function_1.pipe)(as.slice(1, m), (0, exports.prepend)((0, exports.head)(as))), as.slice(m)]; + }; +}; +exports.splitAt = splitAt; +/** + * @since 2.10.0 + */ +var chunksOf = function (n) { return (0, exports.chop)((0, exports.splitAt)(n)); }; +exports.chunksOf = chunksOf; +/* istanbul ignore next */ +var _map = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }; +/* istanbul ignore next */ +var _mapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.mapWithIndex)(f)); }; +/* istanbul ignore next */ +var _ap = function (fab, fa) { return (0, function_1.pipe)(fab, (0, exports.ap)(fa)); }; +/* istanbul ignore next */ +var _extend = function (wa, f) { return (0, function_1.pipe)(wa, (0, exports.extend)(f)); }; +/* istanbul ignore next */ +var _reduce = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduce)(b, f)); }; +/* istanbul ignore next */ +var _foldMap = function (M) { + var foldMapM = (0, exports.foldMap)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapM(f)); }; +}; +/* istanbul ignore next */ +var _reduceRight = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduceRight)(b, f)); }; +/* istanbul ignore next */ +var _traverse = function (F) { + var traverseF = (0, exports.traverse)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseF(f)); }; +}; +/* istanbul ignore next */ +var _alt = function (fa, that) { return (0, function_1.pipe)(fa, (0, exports.alt)(that)); }; +/* istanbul ignore next */ +var _reduceWithIndex = function (fa, b, f) { + return (0, function_1.pipe)(fa, (0, exports.reduceWithIndex)(b, f)); +}; +/* istanbul ignore next */ +var _foldMapWithIndex = function (M) { + var foldMapWithIndexM = (0, exports.foldMapWithIndex)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapWithIndexM(f)); }; +}; +/* istanbul ignore next */ +var _reduceRightWithIndex = function (fa, b, f) { + return (0, function_1.pipe)(fa, (0, exports.reduceRightWithIndex)(b, f)); +}; +/* istanbul ignore next */ +var _traverseWithIndex = function (F) { + var traverseWithIndexF = (0, exports.traverseWithIndex)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseWithIndexF(f)); }; +}; +/** + * Less strict version of [`alt`](#alt). + * + * The `W` suffix (short for **W**idening) means that the return types will be merged. + * + * @example + * import * as NEA from 'fp-ts/NonEmptyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3] as NEA.NonEmptyArray, + * NEA.altW(() => ['a', 'b']) + * ), + * [1, 2, 3, 'a', 'b'] + * ) + * + * @category error handling + * @since 2.9.0 + */ +var altW = function (that) { + return function (as) { + return (0, function_1.pipe)(as, concatW(that())); + }; +}; +exports.altW = altW; +/** + * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to + * types of kind `* -> *`. + * + * In case of `NonEmptyArray` concatenates the inputs into a single array. + * + * @example + * import * as NEA from 'fp-ts/NonEmptyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * NEA.alt(() => [4, 5]) + * ), + * [1, 2, 3, 4, 5] + * ) + * + * @category error handling + * @since 2.6.2 + */ +exports.alt = exports.altW; +/** + * Apply a function to an argument under a type constructor. + * + * @since 2.0.0 + */ +var ap = function (as) { + return (0, exports.flatMap)(function (f) { return (0, function_1.pipe)(as, (0, exports.map)(f)); }); +}; +exports.ap = ap; +/** + * @example + * import * as NEA from 'fp-ts/NonEmptyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * NEA.flatMap((n) => [`a${n}`, `b${n}`]) + * ), + * ['a1', 'b1', 'a2', 'b2', 'a3', 'b3'] + * ) + * + * @category sequencing + * @since 2.14.0 + */ +exports.flatMap = (0, function_1.dual)(2, function (ma, f) { + return (0, function_1.pipe)(ma, (0, exports.chainWithIndex)(function (i, a) { return f(a, i); })); +}); +/** + * @since 2.0.0 + */ +var extend = function (f) { + return function (as) { + var next = (0, exports.tail)(as); + var out = [f(as)]; + while ((0, exports.isNonEmpty)(next)) { + out.push(f(next)); + next = (0, exports.tail)(next); + } + return out; + }; +}; +exports.extend = extend; +/** + * @since 2.5.0 + */ +exports.duplicate = (0, exports.extend)(function_1.identity); +/** + * @category sequencing + * @since 2.5.0 + */ +exports.flatten = (0, exports.flatMap)(function_1.identity); +/** + * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types + * use the type constructor `F` to represent some computational context. + * + * @category mapping + * @since 2.0.0 + */ +var map = function (f) { return (0, exports.mapWithIndex)(function (_, a) { return f(a); }); }; +exports.map = map; +/** + * @category mapping + * @since 2.0.0 + */ +var mapWithIndex = function (f) { + return function (as) { + var out = [f(0, (0, exports.head)(as))]; + for (var i = 1; i < as.length; i++) { + out.push(f(i, as[i])); + } + return out; + }; +}; +exports.mapWithIndex = mapWithIndex; +/** + * @category folding + * @since 2.0.0 + */ +exports.reduce = RNEA.reduce; +/** + * @category folding + * @since 2.0.0 + */ +exports.reduceWithIndex = RNEA.reduceWithIndex; +/** + * @category folding + * @since 2.0.0 + */ exports.reduceRight = RNEA.reduceRight; /** - * @category FoldableWithIndex + * @category folding * @since 2.0.0 */ exports.reduceRightWithIndex = RNEA.reduceRightWithIndex; /** + * @category traversing * @since 2.6.3 */ -exports.traverse = RNEA.traverse; +var traverse = function (F) { + var traverseWithIndexF = (0, exports.traverseWithIndex)(F); + return function (f) { return traverseWithIndexF(function (_, a) { return f(a); }); }; +}; +exports.traverse = traverse; /** + * @category traversing * @since 2.6.3 */ -exports.sequence = RNEA.sequence; +var sequence = function (F) { return (0, exports.traverseWithIndex)(F)(function (_, a) { return a; }); }; +exports.sequence = sequence; /** + * @category sequencing * @since 2.6.3 */ -exports.traverseWithIndex = RNEA.traverseWithIndex; +var traverseWithIndex = function (F) { + return function (f) { + return function (as) { + var out = F.map(f(0, (0, exports.head)(as)), exports.of); + for (var i = 1; i < as.length; i++) { + out = F.ap(F.map(out, function (bs) { return function (b) { return (0, function_1.pipe)(bs, (0, exports.append)(b)); }; }), f(i, as[i])); + } + return out; + }; + }; +}; +exports.traverseWithIndex = traverseWithIndex; /** * @since 2.7.0 */ -exports.extract = exports.head; -// ------------------------------------------------------------------------------------- -// instances -// ------------------------------------------------------------------------------------- +exports.extract = RNEA.head; /** - * @category instances + * @category type lambdas * @since 2.0.0 */ exports.URI = 'NonEmptyArray'; +/** + * @category instances + * @since 2.0.0 + */ +exports.getShow = RNEA.getShow; +/** + * Builds a `Semigroup` instance for `NonEmptyArray` + * + * @category instances + * @since 2.0.0 + */ +var getSemigroup = function () { return ({ + concat: concat +}); }; +exports.getSemigroup = getSemigroup; +/** + * @example + * import { getEq } from 'fp-ts/NonEmptyArray' + * import * as N from 'fp-ts/number' + * + * const E = getEq(N.Eq) + * assert.strictEqual(E.equals([1, 2], [1, 2]), true) + * assert.strictEqual(E.equals([1, 2], [1, 3]), false) + * + * @category instances + * @since 2.0.0 + */ +exports.getEq = RNEA.getEq; +/** + * @since 2.11.0 + */ +var getUnionSemigroup = function (E) { + var unionE = (0, exports.union)(E); + return { + concat: function (first, second) { return unionE(second)(first); } + }; +}; +exports.getUnionSemigroup = getUnionSemigroup; /** * @category instances * @since 2.7.0 */ exports.Functor = { URI: exports.URI, - map: map_ + map: _map +}; +/** + * @category mapping + * @since 2.10.0 + */ +exports.flap = (0, Functor_1.flap)(exports.Functor); +/** + * @category instances + * @since 2.10.0 + */ +exports.Pointed = { + URI: exports.URI, + of: exports.of }; /** * @category instances @@ -9714,29 +13073,69 @@ exports.Functor = { */ exports.FunctorWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_ + map: _map, + mapWithIndex: _mapWithIndex +}; +/** + * @category instances + * @since 2.10.0 + */ +exports.Apply = { + URI: exports.URI, + map: _map, + ap: _ap }; +/** + * Combine two effectful actions, keeping only the result of the first. + * + * @since 2.5.0 + */ +exports.apFirst = (0, Apply_1.apFirst)(exports.Apply); +/** + * Combine two effectful actions, keeping only the result of the second. + * + * @since 2.5.0 + */ +exports.apSecond = (0, Apply_1.apSecond)(exports.Apply); /** * @category instances * @since 2.7.0 */ exports.Applicative = { URI: exports.URI, - map: map_, - ap: ap_, + map: _map, + ap: _ap, of: exports.of }; +/** + * @category instances + * @since 2.10.0 + */ +exports.Chain = { + URI: exports.URI, + map: _map, + ap: _ap, + chain: exports.flatMap +}; +/** + * Composes computations in sequence, using the return value of one computation to determine the next computation and + * keeping only the result of the first. + * + * @category sequencing + * @since 2.5.0 + */ +exports.chainFirst = +/*#__PURE__*/ (0, Chain_1.chainFirst)(exports.Chain); /** * @category instances * @since 2.7.0 */ exports.Monad = { URI: exports.URI, - map: map_, - ap: ap_, + map: _map, + ap: _ap, of: exports.of, - chain: chain_ + chain: exports.flatMap }; /** * @category instances @@ -9744,9 +13143,9 @@ exports.Monad = { */ exports.Foldable = { URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_ + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight }; /** * @category instances @@ -9754,12 +13153,12 @@ exports.Foldable = { */ exports.FoldableWithIndex = { URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_ + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex }; /** * @category instances @@ -9767,11 +13166,11 @@ exports.FoldableWithIndex = { */ exports.Traversable = { URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: _map, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, sequence: exports.sequence }; /** @@ -9780,17 +13179,17 @@ exports.Traversable = { */ exports.TraversableWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: _map, + mapWithIndex: _mapWithIndex, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, sequence: exports.sequence, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverseWithIndex: traverseWithIndex_ + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex, + traverseWithIndex: _traverseWithIndex }; /** * @category instances @@ -9798,8 +13197,8 @@ exports.TraversableWithIndex = { */ exports.Alt = { URI: exports.URI, - map: map_, - alt: alt_ + map: _map, + alt: _alt }; /** * @category instances @@ -9807,170 +13206,329 @@ exports.Alt = { */ exports.Comonad = { URI: exports.URI, - map: map_, - extend: extend_, + map: _map, + extend: _extend, extract: exports.extract }; -// TODO: remove in v3 -/** - * @category instances - * @since 2.0.0 - */ -exports.nonEmptyArray = { - URI: exports.URI, - of: exports.of, - map: map_, - mapWithIndex: mapWithIndex_, - ap: ap_, - chain: chain_, - extend: extend_, - extract: exports.extract, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: exports.sequence, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverseWithIndex: traverseWithIndex_, - alt: alt_ -}; // ------------------------------------------------------------------------------------- // do notation // ------------------------------------------------------------------------------------- /** + * @category do notation * @since 2.9.0 */ -exports.Do = -/*#__PURE__*/ -exports.of({}); +exports.Do = (0, exports.of)(_.emptyRecord); /** + * @category do notation * @since 2.8.0 */ -exports.bindTo = RNEA.bindTo; +exports.bindTo = (0, Functor_1.bindTo)(exports.Functor); +var let_ = /*#__PURE__*/ (0, Functor_1.let)(exports.Functor); +exports["let"] = let_; /** + * @category do notation * @since 2.8.0 */ -exports.bind = RNEA.bind; -// ------------------------------------------------------------------------------------- -// pipeable sequence S -// ------------------------------------------------------------------------------------- +exports.bind = (0, Chain_1.bind)(exports.Chain); /** + * @category do notation * @since 2.8.0 */ -exports.apS = RNEA.apS; - - -/***/ }), - -/***/ 2569: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getApplySemigroup = exports.getOrd = exports.getEq = exports.getShow = exports.URI = exports.wilt = exports.wither = exports.sequence = exports.traverse = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports.separate = exports.compact = exports.reduceRight = exports.foldMap = exports.reduce = exports.duplicate = exports.extend = exports.throwError = exports.zero = exports.alt = exports.altW = exports.flatten = exports.chainFirst = exports.chain = exports.of = exports.apSecond = exports.apFirst = exports.ap = exports.map = exports.chainNullableK = exports.mapNullable = exports.fromNullableK = exports.getOrElse = exports.getOrElseW = exports.toUndefined = exports.toNullable = exports.fold = exports.fromEither = exports.getRight = exports.getLeft = exports.tryCatch = exports.fromPredicate = exports.fromNullable = exports.some = exports.none = exports.isNone = exports.isSome = void 0; -exports.sequenceArray = exports.traverseArray = exports.traverseArrayWithIndex = exports.apS = exports.bind = exports.bindTo = exports.Do = exports.getRefinement = exports.exists = exports.elem = exports.option = exports.MonadThrow = exports.Witherable = exports.Traversable = exports.Filterable = exports.Compactable = exports.Extend = exports.Alternative = exports.Alt = exports.Foldable = exports.Monad = exports.Applicative = exports.Functor = exports.getMonoid = exports.getLastMonoid = exports.getFirstMonoid = exports.getApplyMonoid = void 0; -var function_1 = __nccwpck_require__(6985); +exports.apS = (0, Apply_1.apS)(exports.Apply); // ------------------------------------------------------------------------------------- -// guards +// utils // ------------------------------------------------------------------------------------- /** - * Returns `true` if the option is an instance of `Some`, `false` otherwise. + * @since 2.0.0 + */ +exports.head = RNEA.head; +/** + * @since 2.0.0 + */ +var tail = function (as) { return as.slice(1); }; +exports.tail = tail; +/** + * @since 2.0.0 + */ +exports.last = RNEA.last; +/** + * Get all but the last element of a non empty array, creating a new array. * * @example - * import { some, none, isSome } from 'fp-ts/Option' + * import { init } from 'fp-ts/NonEmptyArray' * - * assert.strictEqual(isSome(some(1)), true) - * assert.strictEqual(isSome(none), false) + * assert.deepStrictEqual(init([1, 2, 3]), [1, 2]) + * assert.deepStrictEqual(init([1]), []) * - * @category guards + * @since 2.2.0 + */ +var init = function (as) { return as.slice(0, -1); }; +exports.init = init; +/** * @since 2.0.0 */ -var isSome = function (fa) { return fa._tag === 'Some'; }; -exports.isSome = isSome; +exports.min = RNEA.min; /** - * Returns `true` if the option is `None`, `false` otherwise. + * @since 2.0.0 + */ +exports.max = RNEA.max; +/** + * @since 2.10.0 + */ +var concatAll = function (S) { + return function (as) { + return as.reduce(S.concat); + }; +}; +exports.concatAll = concatAll; +/** + * Break an `Array` into its first element and remaining elements. * - * @example - * import { some, none, isNone } from 'fp-ts/Option' + * @category pattern matching + * @since 2.11.0 + */ +var matchLeft = function (f) { + return function (as) { + return f((0, exports.head)(as), (0, exports.tail)(as)); + }; +}; +exports.matchLeft = matchLeft; +/** + * Break an `Array` into its initial elements and the last element. * - * assert.strictEqual(isNone(some(1)), false) - * assert.strictEqual(isNone(none), true) + * @category pattern matching + * @since 2.11.0 + */ +var matchRight = function (f) { + return function (as) { + return f((0, exports.init)(as), (0, exports.last)(as)); + }; +}; +exports.matchRight = matchRight; +/** + * Apply a function to the head, creating a new `NonEmptyArray`. * - * @category guards - * @since 2.0.0 + * @since 2.11.0 */ -var isNone = function (fa) { return fa._tag === 'None'; }; -exports.isNone = isNone; -// ------------------------------------------------------------------------------------- -// constructors -// ------------------------------------------------------------------------------------- +var modifyHead = function (f) { + return function (as) { + return __spreadArray([f((0, exports.head)(as))], (0, exports.tail)(as), true); + }; +}; +exports.modifyHead = modifyHead; /** - * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value. + * Change the head, creating a new `NonEmptyArray`. * - * @category constructors - * @since 2.0.0 + * @since 2.11.0 */ -exports.none = { _tag: 'None' }; +var updateHead = function (a) { return (0, exports.modifyHead)(function () { return a; }); }; +exports.updateHead = updateHead; /** - * Constructs a `Some`. Represents an optional value that exists. + * Apply a function to the last element, creating a new `NonEmptyArray`. * - * @category constructors - * @since 2.0.0 + * @since 2.11.0 */ -var some = function (a) { return ({ _tag: 'Some', value: a }); }; -exports.some = some; +var modifyLast = function (f) { + return function (as) { + return (0, function_1.pipe)((0, exports.init)(as), (0, exports.append)(f((0, exports.last)(as)))); + }; +}; +exports.modifyLast = modifyLast; /** - * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise - * returns the value wrapped in a `Some`. + * Change the last element, creating a new `NonEmptyArray`. + * + * @since 2.11.0 + */ +var updateLast = function (a) { return (0, exports.modifyLast)(function () { return a; }); }; +exports.updateLast = updateLast; +/** + * Places an element in between members of a `NonEmptyArray`, then folds the results using the provided `Semigroup`. * * @example - * import { none, some, fromNullable } from 'fp-ts/Option' + * import * as S from 'fp-ts/string' + * import { intercalate } from 'fp-ts/NonEmptyArray' * - * assert.deepStrictEqual(fromNullable(undefined), none) - * assert.deepStrictEqual(fromNullable(null), none) - * assert.deepStrictEqual(fromNullable(1), some(1)) + * assert.deepStrictEqual(intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c') * - * @category constructors + * @since 2.12.0 + */ +exports.intercalate = RNEA.intercalate; +// ------------------------------------------------------------------------------------- +// legacy +// ------------------------------------------------------------------------------------- +/** + * Alias of `flatMap`. + * + * @category legacy * @since 2.0.0 */ -function fromNullable(a) { - return a == null ? exports.none : exports.some(a); +exports.chain = exports.flatMap; +function groupSort(O) { + var sortO = (0, exports.sort)(O); + var groupO = group(O); + return function (as) { return ((0, exports.isNonEmpty)(as) ? groupO(sortO(as)) : []); }; } -exports.fromNullable = fromNullable; -function fromPredicate(predicate) { - return function (a) { return (predicate(a) ? exports.some(a) : exports.none); }; +exports.groupSort = groupSort; +function filter(predicate) { + return (0, exports.filterWithIndex)(function (_, a) { return predicate(a); }); } -exports.fromPredicate = fromPredicate; +exports.filter = filter; /** - * Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a - * `Some`. - * - * @example - * import { none, some, tryCatch } from 'fp-ts/Option' + * Use [`filterWithIndex`](./Array.ts.html#filterwithindex) instead. * - * assert.deepStrictEqual( - * tryCatch(() => { - * throw new Error() - * }), - * none - * ) - * assert.deepStrictEqual(tryCatch(() => 1), some(1)) + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +var filterWithIndex = function (predicate) { + return function (as) { + return (0, exports.fromArray)(as.filter(function (a, i) { return predicate(i, a); })); + }; +}; +exports.filterWithIndex = filterWithIndex; +/** + * Use [`unprepend`](#unprepend) instead. * - * @category constructors + * @category zone of death + * @since 2.9.0 + * @deprecated + */ +exports.uncons = exports.unprepend; +/** + * Use [`unappend`](#unappend) instead. + * + * @category zone of death + * @since 2.9.0 + * @deprecated + */ +exports.unsnoc = exports.unappend; +function cons(head, tail) { + return tail === undefined ? (0, exports.prepend)(head) : (0, function_1.pipe)(tail, (0, exports.prepend)(head)); +} +exports.cons = cons; +/** + * Use [`append`](./Array.ts.html#append) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function tryCatch(f) { - try { - return exports.some(f()); - } - catch (e) { - return exports.none; +var snoc = function (init, end) { return (0, function_1.pipe)(init, (0, exports.append)(end)); }; +exports.snoc = snoc; +/** + * Use [`prependAll`](#prependall) instead. + * + * @category zone of death + * @since 2.9.0 + * @deprecated + */ +exports.prependToAll = exports.prependAll; +/** + * Use [`concatAll`](#concatall) instead. + * + * @category zone of death + * @since 2.5.0 + * @deprecated + */ +exports.fold = RNEA.concatAll; +/** + * This instance is deprecated, use small, specific instances instead. + * For example if a function needs a `Functor` instance, pass `NEA.Functor` instead of `NEA.nonEmptyArray` + * (where `NEA` is from `import NEA from 'fp-ts/NonEmptyArray'`) + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.nonEmptyArray = { + URI: exports.URI, + of: exports.of, + map: _map, + mapWithIndex: _mapWithIndex, + ap: _ap, + chain: exports.flatMap, + extend: _extend, + extract: exports.extract, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, + sequence: exports.sequence, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex, + traverseWithIndex: _traverseWithIndex, + alt: _alt +}; + + +/***/ }), + +/***/ 2569: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Witherable = exports.wilt = exports.wither = exports.Traversable = exports.sequence = exports.traverse = exports.Filterable = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports.Compactable = exports.separate = exports.compact = exports.Extend = exports.extend = exports.Alternative = exports.guard = exports.Zero = exports.zero = exports.Alt = exports.alt = exports.altW = exports.orElse = exports.Foldable = exports.reduceRight = exports.foldMap = exports.reduce = exports.Monad = exports.Chain = exports.flatMap = exports.Applicative = exports.Apply = exports.ap = exports.Pointed = exports.of = exports.asUnit = exports.as = exports.Functor = exports.map = exports.getMonoid = exports.getOrd = exports.getEq = exports.getShow = exports.URI = exports.getRight = exports.getLeft = exports.fromPredicate = exports.some = exports.none = void 0; +exports.getFirstMonoid = exports.getApplyMonoid = exports.getApplySemigroup = exports.option = exports.mapNullable = exports.getRefinement = exports.chainFirst = exports.chain = exports.sequenceArray = exports.traverseArray = exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndex = exports.traverseReadonlyNonEmptyArrayWithIndex = exports.ApT = exports.apS = exports.bind = exports["let"] = exports.bindTo = exports.Do = exports.exists = exports.elem = exports.toUndefined = exports.toNullable = exports.chainNullableK = exports.fromNullableK = exports.tryCatchK = exports.tryCatch = exports.fromNullable = exports.chainFirstEitherK = exports.chainEitherK = exports.fromEitherK = exports.duplicate = exports.tapEither = exports.tap = exports.flatten = exports.apSecond = exports.apFirst = exports.flap = exports.getOrElse = exports.getOrElseW = exports.fold = exports.match = exports.foldW = exports.matchW = exports.isNone = exports.isSome = exports.FromEither = exports.fromEither = exports.MonadThrow = exports.throwError = void 0; +exports.getLastMonoid = void 0; +var Applicative_1 = __nccwpck_require__(4766); +var Apply_1 = __nccwpck_require__(205); +var chainable = __importStar(__nccwpck_require__(2372)); +var FromEither_1 = __nccwpck_require__(1964); +var function_1 = __nccwpck_require__(6985); +var Functor_1 = __nccwpck_require__(5533); +var _ = __importStar(__nccwpck_require__(1840)); +var Predicate_1 = __nccwpck_require__(6382); +var Semigroup_1 = __nccwpck_require__(6339); +var Separated_1 = __nccwpck_require__(5877); +var Witherable_1 = __nccwpck_require__(4384); +var Zero_1 = __nccwpck_require__(9734); +// ------------------------------------------------------------------------------------- +// constructors +// ------------------------------------------------------------------------------------- +/** + * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value. + * + * @category constructors + * @since 2.0.0 + */ +exports.none = _.none; +/** + * Constructs a `Some`. Represents an optional value that exists. + * + * @category constructors + * @since 2.0.0 + */ +exports.some = _.some; +function fromPredicate(predicate) { + return function (a) { return (predicate(a) ? (0, exports.some)(a) : exports.none); }; } -exports.tryCatch = tryCatch; +exports.fromPredicate = fromPredicate; /** * Returns the `Left` value of an `Either` if possible. * @@ -9984,9 +13542,7 @@ exports.tryCatch = tryCatch; * @category constructors * @since 2.0.0 */ -function getLeft(ma) { - return ma._tag === 'Right' ? exports.none : exports.some(ma.left); -} +var getLeft = function (ma) { return (ma._tag === 'Right' ? exports.none : (0, exports.some)(ma.left)); }; exports.getLeft = getLeft; /** * Returns the `Right` value of an `Either` if possible. @@ -10001,918 +13557,913 @@ exports.getLeft = getLeft; * @category constructors * @since 2.0.0 */ -function getRight(ma) { - return ma._tag === 'Left' ? exports.none : exports.some(ma.right); -} +var getRight = function (ma) { return (ma._tag === 'Left' ? exports.none : (0, exports.some)(ma.right)); }; exports.getRight = getRight; +var _map = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }; +var _ap = function (fab, fa) { return (0, function_1.pipe)(fab, (0, exports.ap)(fa)); }; +var _reduce = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduce)(b, f)); }; +var _foldMap = function (M) { + var foldMapM = (0, exports.foldMap)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapM(f)); }; +}; +var _reduceRight = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduceRight)(b, f)); }; +var _traverse = function (F) { + var traverseF = (0, exports.traverse)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseF(f)); }; +}; +/* istanbul ignore next */ +var _alt = function (fa, that) { return (0, function_1.pipe)(fa, (0, exports.alt)(that)); }; +var _filter = function (fa, predicate) { return (0, function_1.pipe)(fa, (0, exports.filter)(predicate)); }; +/* istanbul ignore next */ +var _filterMap = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.filterMap)(f)); }; +/* istanbul ignore next */ +var _extend = function (wa, f) { return (0, function_1.pipe)(wa, (0, exports.extend)(f)); }; +/* istanbul ignore next */ +var _partition = function (fa, predicate) { + return (0, function_1.pipe)(fa, (0, exports.partition)(predicate)); +}; +/* istanbul ignore next */ +var _partitionMap = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.partitionMap)(f)); }; /** - * Transforms an `Either` to an `Option` discarding the error. - * - * Alias of [getRight](#getRight) - * - * Derivable from `MonadThrow`. - * - * @category constructors + * @category type lambdas * @since 2.0.0 */ -exports.fromEither = getRight; -// ------------------------------------------------------------------------------------- -// destructors -// ------------------------------------------------------------------------------------- +exports.URI = 'Option'; /** - * Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is - * returned, otherwise the function is applied to the value inside the `Some` and the result is returned. - * - * @example - * import { some, none, fold } from 'fp-ts/Option' - * import { pipe } from 'fp-ts/function' - * - * assert.strictEqual( - * pipe( - * some(1), - * fold(() => 'a none', a => `a some containing ${a}`) - * ), - * 'a some containing 1' - * ) - * - * assert.strictEqual( - * pipe( - * none, - * fold(() => 'a none', a => `a some containing ${a}`) - * ), - * 'a none' - * ) - * - * @category destructors + * @category instances * @since 2.0.0 */ -function fold(onNone, onSome) { - return function (ma) { return (exports.isNone(ma) ? onNone() : onSome(ma.value)); }; -} -exports.fold = fold; +var getShow = function (S) { return ({ + show: function (ma) { return ((0, exports.isNone)(ma) ? 'none' : "some(".concat(S.show(ma.value), ")")); } +}); }; +exports.getShow = getShow; /** - * Extracts the value out of the structure, if it exists. Otherwise returns `null`. - * * @example - * import { some, none, toNullable } from 'fp-ts/Option' - * import { pipe } from 'fp-ts/function' + * import { none, some, getEq } from 'fp-ts/Option' + * import * as N from 'fp-ts/number' * - * assert.strictEqual( - * pipe( - * some(1), - * toNullable - * ), - * 1 - * ) - * assert.strictEqual( - * pipe( - * none, - * toNullable - * ), - * null - * ) + * const E = getEq(N.Eq) + * assert.strictEqual(E.equals(none, none), true) + * assert.strictEqual(E.equals(none, some(1)), false) + * assert.strictEqual(E.equals(some(1), none), false) + * assert.strictEqual(E.equals(some(1), some(2)), false) + * assert.strictEqual(E.equals(some(1), some(1)), true) * - * @category destructors + * @category instances * @since 2.0.0 */ -function toNullable(ma) { - return exports.isNone(ma) ? null : ma.value; -} -exports.toNullable = toNullable; +var getEq = function (E) { return ({ + equals: function (x, y) { return x === y || ((0, exports.isNone)(x) ? (0, exports.isNone)(y) : (0, exports.isNone)(y) ? false : E.equals(x.value, y.value)); } +}); }; +exports.getEq = getEq; /** - * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`. - * - * @example - * import { some, none, toUndefined } from 'fp-ts/Option' - * import { pipe } from 'fp-ts/function' - * - * assert.strictEqual( - * pipe( - * some(1), - * toUndefined - * ), - * 1 - * ) - * assert.strictEqual( - * pipe( - * none, - * toUndefined - * ), - * undefined - * ) + * The `Ord` instance allows `Option` values to be compared with + * `compare`, whenever there is an `Ord` instance for + * the type the `Option` contains. * - * @category destructors - * @since 2.0.0 - */ -function toUndefined(ma) { - return exports.isNone(ma) ? undefined : ma.value; -} -exports.toUndefined = toUndefined; -/** - * Less strict version of [`getOrElse`](#getOrElse). + * `None` is considered to be less than any `Some` value. * - * @category destructors - * @since 2.6.0 - */ -var getOrElseW = function (onNone) { return function (ma) { return (exports.isNone(ma) ? onNone() : ma.value); }; }; -exports.getOrElseW = getOrElseW; -/** - * Extracts the value out of the structure, if it exists. Otherwise returns the given default value * * @example - * import { some, none, getOrElse } from 'fp-ts/Option' - * import { pipe } from 'fp-ts/function' + * import { none, some, getOrd } from 'fp-ts/Option' + * import * as N from 'fp-ts/number' * - * assert.strictEqual( - * pipe( - * some(1), - * getOrElse(() => 0) - * ), - * 1 - * ) - * assert.strictEqual( - * pipe( - * none, - * getOrElse(() => 0) - * ), - * 0 - * ) + * const O = getOrd(N.Ord) + * assert.strictEqual(O.compare(none, none), 0) + * assert.strictEqual(O.compare(none, some(1)), -1) + * assert.strictEqual(O.compare(some(1), none), 1) + * assert.strictEqual(O.compare(some(1), some(2)), -1) + * assert.strictEqual(O.compare(some(1), some(1)), 0) * - * @category destructors + * @category instances * @since 2.0.0 */ -exports.getOrElse = exports.getOrElseW; -// ------------------------------------------------------------------------------------- -// combinators -// ------------------------------------------------------------------------------------- +var getOrd = function (O) { return ({ + equals: (0, exports.getEq)(O).equals, + compare: function (x, y) { return (x === y ? 0 : (0, exports.isSome)(x) ? ((0, exports.isSome)(y) ? O.compare(x.value, y.value) : 1) : -1); } +}); }; +exports.getOrd = getOrd; /** - * Returns a *smart constructor* from a function that returns a nullable value. - * - * @example - * import { fromNullableK, none, some } from 'fp-ts/Option' + * Monoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are + * concatenated using the provided `Semigroup` * - * const f = (s: string): number | undefined => { - * const n = parseFloat(s) - * return isNaN(n) ? undefined : n - * } + * | x | y | concat(x, y) | + * | ------- | ------- | ------------------ | + * | none | none | none | + * | some(a) | none | some(a) | + * | none | some(b) | some(b) | + * | some(a) | some(b) | some(concat(a, b)) | * - * const g = fromNullableK(f) + * @example + * import { getMonoid, some, none } from 'fp-ts/Option' + * import { SemigroupSum } from 'fp-ts/number' * - * assert.deepStrictEqual(g('1'), some(1)) - * assert.deepStrictEqual(g('a'), none) + * const M = getMonoid(SemigroupSum) + * assert.deepStrictEqual(M.concat(none, none), none) + * assert.deepStrictEqual(M.concat(some(1), none), some(1)) + * assert.deepStrictEqual(M.concat(none, some(1)), some(1)) + * assert.deepStrictEqual(M.concat(some(1), some(2)), some(3)) * - * @category combinators - * @since 2.9.0 + * @category instances + * @since 2.0.0 */ -function fromNullableK(f) { - return function () { - var a = []; - for (var _i = 0; _i < arguments.length; _i++) { - a[_i] = arguments[_i]; - } - return fromNullable(f.apply(void 0, a)); - }; -} -exports.fromNullableK = fromNullableK; +var getMonoid = function (S) { return ({ + concat: function (x, y) { return ((0, exports.isNone)(x) ? y : (0, exports.isNone)(y) ? x : (0, exports.some)(S.concat(x.value, y.value))); }, + empty: exports.none +}); }; +exports.getMonoid = getMonoid; /** - * @category combinators + * @category mapping * @since 2.0.0 - * @deprecated */ -exports.mapNullable = chainNullableK; +var map = function (f) { return function (fa) { + return (0, exports.isNone)(fa) ? exports.none : (0, exports.some)(f(fa.value)); +}; }; +exports.map = map; /** - * This is `chain` + `fromNullable`, useful when working with optional values. - * - * @example - * import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option' - * import { pipe } from 'fp-ts/function' - * - * interface Employee { - * company?: { - * address?: { - * street?: { - * name?: string - * } - * } - * } - * } - * - * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } } - * - * assert.deepStrictEqual( - * pipe( - * fromNullable(employee1.company), - * chainNullableK(company => company.address), - * chainNullableK(address => address.street), - * chainNullableK(street => street.name) - * ), - * some('high street') - * ) - * - * const employee2: Employee = { company: { address: { street: {} } } } - * - * assert.deepStrictEqual( - * pipe( - * fromNullable(employee2.company), - * chainNullableK(company => company.address), - * chainNullableK(address => address.street), - * chainNullableK(street => street.name) - * ), - * none - * ) - * - * @category combinators - * @since 2.9.0 + * @category instances + * @since 2.7.0 */ -function chainNullableK(f) { - return function (ma) { return (exports.isNone(ma) ? exports.none : fromNullable(f(ma.value))); }; -} -exports.chainNullableK = chainNullableK; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -var map_ = function (fa, f) { return function_1.pipe(fa, exports.map(f)); }; -var ap_ = function (fab, fa) { return function_1.pipe(fab, exports.ap(fa)); }; -var chain_ = function (ma, f) { return function_1.pipe(ma, exports.chain(f)); }; -var reduce_ = function (fa, b, f) { return function_1.pipe(fa, exports.reduce(b, f)); }; -var foldMap_ = function (M) { - var foldMapM = exports.foldMap(M); - return function (fa, f) { return function_1.pipe(fa, foldMapM(f)); }; -}; -var reduceRight_ = function (fa, b, f) { return function_1.pipe(fa, exports.reduceRight(b, f)); }; -var traverse_ = function (F) { - var traverseF = exports.traverse(F); - return function (ta, f) { return function_1.pipe(ta, traverseF(f)); }; -}; -/* istanbul ignore next */ -var alt_ = function (fa, that) { return function_1.pipe(fa, exports.alt(that)); }; -var filter_ = function (fa, predicate) { - return function_1.pipe(fa, exports.filter(predicate)); -}; -/* istanbul ignore next */ -var filterMap_ = function (fa, f) { return function_1.pipe(fa, exports.filterMap(f)); }; -/* istanbul ignore next */ -var extend_ = function (wa, f) { return function_1.pipe(wa, exports.extend(f)); }; -/* istanbul ignore next */ -var partition_ = function (fa, predicate) { return function_1.pipe(fa, exports.partition(predicate)); }; -/* istanbul ignore next */ -var partitionMap_ = function (fa, f) { return function_1.pipe(fa, exports.partitionMap(f)); }; -/* istanbul ignore next */ -var wither_ = function (F) { - var witherF = exports.wither(F); - return function (fa, f) { return function_1.pipe(fa, witherF(f)); }; -}; -/* istanbul ignore next */ -var wilt_ = function (F) { - var wiltF = exports.wilt(F); - return function (fa, f) { return function_1.pipe(fa, wiltF(f)); }; +exports.Functor = { + URI: exports.URI, + map: _map }; -// ------------------------------------------------------------------------------------- -// pipeables -// ------------------------------------------------------------------------------------- /** - * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types - * use the type constructor `F` to represent some computational context. + * Maps the `Some` value of this `Option` to the specified constant value. * - * @category Functor - * @since 2.0.0 + * @category mapping + * @since 2.16.0 */ -var map = function (f) { return function (fa) { - return exports.isNone(fa) ? exports.none : exports.some(f(fa.value)); -}; }; -exports.map = map; +exports.as = (0, function_1.dual)(2, (0, Functor_1.as)(exports.Functor)); /** - * Apply a function to an argument under a type constructor. + * Maps the `Some` value of this `Option` to the void constant value. * - * @category Apply + * @category mapping + * @since 2.16.0 + */ +exports.asUnit = (0, Functor_1.asUnit)(exports.Functor); +/** + * @category constructors + * @since 2.7.0 + */ +exports.of = exports.some; +/** + * @category instances + * @since 2.10.0 + */ +exports.Pointed = { + URI: exports.URI, + of: exports.of +}; +/** * @since 2.0.0 */ var ap = function (fa) { return function (fab) { - return exports.isNone(fab) ? exports.none : exports.isNone(fa) ? exports.none : exports.some(fab.value(fa.value)); + return (0, exports.isNone)(fab) ? exports.none : (0, exports.isNone)(fa) ? exports.none : (0, exports.some)(fab.value(fa.value)); }; }; exports.ap = ap; /** - * Combine two effectful actions, keeping only the result of the first. - * - * Derivable from `Apply`. - * - * @category combinators - * @since 2.0.0 + * @category instances + * @since 2.10.0 */ -var apFirst = function (fb) { - return function_1.flow(exports.map(function (a) { return function () { return a; }; }), exports.ap(fb)); +exports.Apply = { + URI: exports.URI, + map: _map, + ap: _ap }; -exports.apFirst = apFirst; /** - * Combine two effectful actions, keeping only the result of the second. - * - * Derivable from `Apply`. - * - * @category combinators - * @since 2.0.0 + * @category instances + * @since 2.7.0 */ -var apSecond = function (fb) { - return function_1.flow(exports.map(function () { return function (b) { return b; }; }), exports.ap(fb)); +exports.Applicative = { + URI: exports.URI, + map: _map, + ap: _ap, + of: exports.of }; -exports.apSecond = apSecond; /** - * Wrap a value into the type constructor. - * - * @category Applicative + * @category sequencing + * @since 2.14.0 + */ +exports.flatMap = (0, function_1.dual)(2, function (ma, f) { return ((0, exports.isNone)(ma) ? exports.none : f(ma.value)); }); +/** + * @category instances + * @since 2.10.0 + */ +exports.Chain = { + URI: exports.URI, + map: _map, + ap: _ap, + chain: exports.flatMap +}; +/** + * @category instances * @since 2.7.0 */ -exports.of = exports.some; +exports.Monad = { + URI: exports.URI, + map: _map, + ap: _ap, + of: exports.of, + chain: exports.flatMap +}; /** - * Composes computations in sequence, using the return value of one computation to determine the next computation. - * - * @category Monad + * @category folding * @since 2.0.0 */ -var chain = function (f) { return function (ma) { - return exports.isNone(ma) ? exports.none : f(ma.value); +var reduce = function (b, f) { return function (fa) { + return (0, exports.isNone)(fa) ? b : f(b, fa.value); }; }; -exports.chain = chain; +exports.reduce = reduce; /** - * Composes computations in sequence, using the return value of one computation to determine the next computation and - * keeping only the result of the first. - * - * Derivable from `Monad`. - * - * @category combinators + * @category folding * @since 2.0.0 */ -var chainFirst = function (f) { - return exports.chain(function (a) { - return function_1.pipe(f(a), exports.map(function () { return a; })); - }); -}; -exports.chainFirst = chainFirst; +var foldMap = function (M) { return function (f) { return function (fa) { + return (0, exports.isNone)(fa) ? M.empty : f(fa.value); +}; }; }; +exports.foldMap = foldMap; /** - * Derivable from `Monad`. - * - * @category combinators + * @category folding * @since 2.0.0 */ -exports.flatten = -/*#__PURE__*/ -exports.chain(function_1.identity); +var reduceRight = function (b, f) { return function (fa) { + return (0, exports.isNone)(fa) ? b : f(fa.value, b); +}; }; +exports.reduceRight = reduceRight; /** - * Less strict version of [`alt`](#alt). - * - * @category Alt - * @since 2.9.0 + * @category instances + * @since 2.7.0 */ -var altW = function (that) { return function (fa) { - return exports.isNone(fa) ? that() : fa; -}; }; -exports.altW = altW; +exports.Foldable = { + URI: exports.URI, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight +}; /** - * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to - * types of kind `* -> *`. + * Returns the provided `Option` `that` if `self` is `None`, otherwise returns `self`. * - * In case of `Option` returns the left-most non-`None` value. + * @param self - The first `Option` to be checked. + * @param that - The `Option` to return if `self` is `None`. * * @example - * import * as O from 'fp-ts/Option' - * import { pipe } from 'fp-ts/function' + * import * as O from "fp-ts/Option" * - * assert.deepStrictEqual( - * pipe( - * O.some('a'), - * O.alt(() => O.some('b')) - * ), - * O.some('a') - * ) - * assert.deepStrictEqual( - * pipe( - * O.none, - * O.alt(() => O.some('b')) - * ), - * O.some('b') - * ) + * assert.deepStrictEqual(O.orElse(O.none, () => O.none), O.none) + * assert.deepStrictEqual(O.orElse(O.some(1), () => O.none), O.some(1)) + * assert.deepStrictEqual(O.orElse(O.none, () => O.some('b')), O.some('b')) + * assert.deepStrictEqual(O.orElse(O.some(1), () => O.some('b')), O.some(1)) + * + * @category error handling + * @since 2.16.0 + */ +exports.orElse = (0, function_1.dual)(2, function (self, that) { return ((0, exports.isNone)(self) ? that() : self); }); +/** + * Alias of `orElse`. + * + * Less strict version of [`alt`](#alt). + * + * The `W` suffix (short for **W**idening) means that the return types will be merged. * - * @category Alt + * @category legacy + * @since 2.9.0 + */ +exports.altW = exports.orElse; +/** + * Alias of `orElse`. + * + * @category legacy * @since 2.0.0 */ -exports.alt = exports.altW; +exports.alt = exports.orElse; /** - * @category Alternative + * @category instances * @since 2.7.0 */ -var zero = function () { return exports.none; }; -exports.zero = zero; +exports.Alt = { + URI: exports.URI, + map: _map, + alt: _alt +}; /** - * @category MonadThrow * @since 2.7.0 */ -var throwError = function () { return exports.none; }; -exports.throwError = throwError; +var zero = function () { return exports.none; }; +exports.zero = zero; /** - * @category Extend - * @since 2.0.0 + * @category instances + * @since 2.11.0 */ -var extend = function (f) { return function (wa) { - return exports.isNone(wa) ? exports.none : exports.some(f(wa)); -}; }; -exports.extend = extend; +exports.Zero = { + URI: exports.URI, + zero: exports.zero +}; /** - * Derivable from `Extend`. - * - * @category combinators - * @since 2.0.0 + * @category do notation + * @since 2.11.0 */ -exports.duplicate = -/*#__PURE__*/ -exports.extend(function_1.identity); +exports.guard = (0, Zero_1.guard)(exports.Zero, exports.Pointed); /** - * @category Foldable - * @since 2.0.0 + * @category instances + * @since 2.7.0 */ -var reduce = function (b, f) { return function (fa) { - return exports.isNone(fa) ? b : f(b, fa.value); -}; }; -exports.reduce = reduce; +exports.Alternative = { + URI: exports.URI, + map: _map, + ap: _ap, + of: exports.of, + alt: _alt, + zero: exports.zero +}; /** - * @category Foldable * @since 2.0.0 */ -var foldMap = function (M) { return function (f) { return function (fa) { - return exports.isNone(fa) ? M.empty : f(fa.value); -}; }; }; -exports.foldMap = foldMap; +var extend = function (f) { return function (wa) { + return (0, exports.isNone)(wa) ? exports.none : (0, exports.some)(f(wa)); +}; }; +exports.extend = extend; /** - * @category Foldable - * @since 2.0.0 + * @category instances + * @since 2.7.0 */ -var reduceRight = function (b, f) { return function (fa) { - return exports.isNone(fa) ? b : f(fa.value, b); -}; }; -exports.reduceRight = reduceRight; +exports.Extend = { + URI: exports.URI, + map: _map, + extend: _extend +}; /** - * @category Compactable + * @category filtering * @since 2.0.0 */ -exports.compact = exports.flatten; -var defaultSeparate = { left: exports.none, right: exports.none }; +exports.compact = (0, exports.flatMap)(function_1.identity); +var defaultSeparated = /*#__PURE__*/ (0, Separated_1.separated)(exports.none, exports.none); /** - * @category Compactable + * @category filtering * @since 2.0.0 */ var separate = function (ma) { - var o = function_1.pipe(ma, exports.map(function (e) { return ({ - left: getLeft(e), - right: getRight(e) - }); })); - return exports.isNone(o) ? defaultSeparate : o.value; + return (0, exports.isNone)(ma) ? defaultSeparated : (0, Separated_1.separated)((0, exports.getLeft)(ma.value), (0, exports.getRight)(ma.value)); }; exports.separate = separate; /** - * @category Filterable + * @category instances + * @since 2.7.0 + */ +exports.Compactable = { + URI: exports.URI, + compact: exports.compact, + separate: exports.separate +}; +/** + * @category filtering * @since 2.0.0 */ -var filter = function (predicate) { return function (fa) { return (exports.isNone(fa) ? exports.none : predicate(fa.value) ? fa : exports.none); }; }; +var filter = function (predicate) { + return function (fa) { + return (0, exports.isNone)(fa) ? exports.none : predicate(fa.value) ? fa : exports.none; + }; +}; exports.filter = filter; /** - * @category Filterable + * @category filtering * @since 2.0.0 */ var filterMap = function (f) { return function (fa) { - return exports.isNone(fa) ? exports.none : f(fa.value); + return (0, exports.isNone)(fa) ? exports.none : f(fa.value); }; }; exports.filterMap = filterMap; /** - * @category Filterable + * @category filtering * @since 2.0.0 */ -var partition = function (predicate) { return function (fa) { - return { - left: filter_(fa, function (a) { return !predicate(a); }), - right: filter_(fa, predicate) +var partition = function (predicate) { + return function (fa) { + return (0, Separated_1.separated)(_filter(fa, (0, Predicate_1.not)(predicate)), _filter(fa, predicate)); }; -}; }; +}; exports.partition = partition; /** - * @category Filterable + * @category filtering * @since 2.0.0 */ -var partitionMap = function (f) { return function_1.flow(exports.map(f), exports.separate); }; +var partitionMap = function (f) { return (0, function_1.flow)((0, exports.map)(f), exports.separate); }; exports.partitionMap = partitionMap; /** - * @category Traversable + * @category instances + * @since 2.7.0 + */ +exports.Filterable = { + URI: exports.URI, + map: _map, + compact: exports.compact, + separate: exports.separate, + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap +}; +/** + * @category traversing * @since 2.6.3 */ -var traverse = function (F) { return function (f) { return function (ta) { return (exports.isNone(ta) ? F.of(exports.none) : F.map(f(ta.value), exports.some)); }; }; }; +var traverse = function (F) { + return function (f) { + return function (ta) { + return (0, exports.isNone)(ta) ? F.of(exports.none) : F.map(f(ta.value), exports.some); + }; + }; +}; exports.traverse = traverse; /** - * @category Traversable + * @category traversing * @since 2.6.3 */ -var sequence = function (F) { return function (ta) { return (exports.isNone(ta) ? F.of(exports.none) : F.map(ta.value, exports.some)); }; }; +var sequence = function (F) { + return function (ta) { + return (0, exports.isNone)(ta) ? F.of(exports.none) : F.map(ta.value, exports.some); + }; +}; exports.sequence = sequence; /** - * @category Witherable + * @category instances + * @since 2.7.0 + */ +exports.Traversable = { + URI: exports.URI, + map: _map, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, + sequence: exports.sequence +}; +var _wither = /*#__PURE__*/ (0, Witherable_1.witherDefault)(exports.Traversable, exports.Compactable); +var _wilt = /*#__PURE__*/ (0, Witherable_1.wiltDefault)(exports.Traversable, exports.Compactable); +/** + * @category filtering * @since 2.6.5 */ -var wither = function (F) { return function (f) { return function (fa) { return (exports.isNone(fa) ? F.of(exports.none) : f(fa.value)); }; }; }; +var wither = function (F) { + var _witherF = _wither(F); + return function (f) { return function (fa) { return _witherF(fa, f); }; }; +}; exports.wither = wither; /** - * @category Witherable + * @category filtering * @since 2.6.5 */ -var wilt = function (F) { return function (f) { return function (fa) { - return exports.isNone(fa) - ? F.of({ - left: exports.none, - right: exports.none - }) - : F.map(f(fa.value), function (e) { return ({ - left: getLeft(e), - right: getRight(e) - }); }); -}; }; }; +var wilt = function (F) { + var _wiltF = _wilt(F); + return function (f) { return function (fa) { return _wiltF(fa, f); }; }; +}; exports.wilt = wilt; -// ------------------------------------------------------------------------------------- -// instances -// ------------------------------------------------------------------------------------- /** * @category instances - * @since 2.0.0 + * @since 2.7.0 */ -exports.URI = 'Option'; +exports.Witherable = { + URI: exports.URI, + map: _map, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, + sequence: exports.sequence, + compact: exports.compact, + separate: exports.separate, + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + wither: _wither, + wilt: _wilt +}; +/** + * @since 2.7.0 + */ +var throwError = function () { return exports.none; }; +exports.throwError = throwError; /** * @category instances - * @since 2.0.0 + * @since 2.7.0 */ -function getShow(S) { - return { - show: function (ma) { return (exports.isNone(ma) ? 'none' : "some(" + S.show(ma.value) + ")"); } - }; -} -exports.getShow = getShow; +exports.MonadThrow = { + URI: exports.URI, + map: _map, + ap: _ap, + of: exports.of, + chain: exports.flatMap, + throwError: exports.throwError +}; /** - * @example - * import { none, some, getEq } from 'fp-ts/Option' - * import { eqNumber } from 'fp-ts/Eq' + * Transforms an `Either` to an `Option` discarding the error. * - * const E = getEq(eqNumber) - * assert.strictEqual(E.equals(none, none), true) - * assert.strictEqual(E.equals(none, some(1)), false) - * assert.strictEqual(E.equals(some(1), none), false) - * assert.strictEqual(E.equals(some(1), some(2)), false) - * assert.strictEqual(E.equals(some(1), some(1)), true) + * Alias of [getRight](#getright) * - * @category instances + * @category conversions * @since 2.0.0 */ -function getEq(E) { - return { - equals: function (x, y) { return x === y || (exports.isNone(x) ? exports.isNone(y) : exports.isNone(y) ? false : E.equals(x.value, y.value)); } - }; -} -exports.getEq = getEq; +exports.fromEither = exports.getRight; /** - * The `Ord` instance allows `Option` values to be compared with - * `compare`, whenever there is an `Ord` instance for - * the type the `Option` contains. - * - * `None` is considered to be less than any `Some` value. - * + * @category instances + * @since 2.11.0 + */ +exports.FromEither = { + URI: exports.URI, + fromEither: exports.fromEither +}; +// ------------------------------------------------------------------------------------- +// refinements +// ------------------------------------------------------------------------------------- +/** + * Returns `true` if the option is an instance of `Some`, `false` otherwise. * * @example - * import { none, some, getOrd } from 'fp-ts/Option' - * import { ordNumber } from 'fp-ts/Ord' + * import { some, none, isSome } from 'fp-ts/Option' * - * const O = getOrd(ordNumber) - * assert.strictEqual(O.compare(none, none), 0) - * assert.strictEqual(O.compare(none, some(1)), -1) - * assert.strictEqual(O.compare(some(1), none), 1) - * assert.strictEqual(O.compare(some(1), some(2)), -1) - * assert.strictEqual(O.compare(some(1), some(1)), 0) + * assert.strictEqual(isSome(some(1)), true) + * assert.strictEqual(isSome(none), false) * - * @category instances + * @category refinements * @since 2.0.0 */ -function getOrd(O) { - return { - equals: getEq(O).equals, - compare: function (x, y) { return (x === y ? 0 : exports.isSome(x) ? (exports.isSome(y) ? O.compare(x.value, y.value) : 1) : -1); } - }; -} -exports.getOrd = getOrd; +exports.isSome = _.isSome; /** - * `Apply` semigroup - * - * | x | y | concat(x, y) | - * | ------- | ------- | ------------------ | - * | none | none | none | - * | some(a) | none | none | - * | none | some(a) | none | - * | some(a) | some(b) | some(concat(a, b)) | + * Returns `true` if the option is `None`, `false` otherwise. * * @example - * import { getApplySemigroup, some, none } from 'fp-ts/Option' - * import { semigroupSum } from 'fp-ts/Semigroup' + * import { some, none, isNone } from 'fp-ts/Option' * - * const S = getApplySemigroup(semigroupSum) - * assert.deepStrictEqual(S.concat(none, none), none) - * assert.deepStrictEqual(S.concat(some(1), none), none) - * assert.deepStrictEqual(S.concat(none, some(1)), none) - * assert.deepStrictEqual(S.concat(some(1), some(2)), some(3)) + * assert.strictEqual(isNone(some(1)), false) + * assert.strictEqual(isNone(none), true) * - * @category instances + * @category refinements * @since 2.0.0 */ -function getApplySemigroup(S) { - return { - concat: function (x, y) { return (exports.isSome(x) && exports.isSome(y) ? exports.some(S.concat(x.value, y.value)) : exports.none); } - }; -} -exports.getApplySemigroup = getApplySemigroup; +var isNone = function (fa) { return fa._tag === 'None'; }; +exports.isNone = isNone; /** - * @category instances - * @since 2.0.0 + * Less strict version of [`match`](#match). + * + * The `W` suffix (short for **W**idening) means that the handler return types will be merged. + * + * @category pattern matching + * @since 2.10.0 */ -function getApplyMonoid(M) { - return { - concat: getApplySemigroup(M).concat, - empty: exports.some(M.empty) +var matchW = function (onNone, onSome) { + return function (ma) { + return (0, exports.isNone)(ma) ? onNone() : onSome(ma.value); }; -} -exports.getApplyMonoid = getApplyMonoid; +}; +exports.matchW = matchW; /** - * Monoid returning the left-most non-`None` value + * Alias of [`matchW`](#matchw). * - * | x | y | concat(x, y) | - * | ------- | ------- | ------------ | - * | none | none | none | - * | some(a) | none | some(a) | - * | none | some(a) | some(a) | - * | some(a) | some(b) | some(a) | + * @category pattern matching + * @since 2.10.0 + */ +exports.foldW = exports.matchW; +/** + * Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is + * returned, otherwise the function is applied to the value inside the `Some` and the result is returned. * * @example - * import { getFirstMonoid, some, none } from 'fp-ts/Option' + * import { some, none, match } from 'fp-ts/Option' + * import { pipe } from 'fp-ts/function' * - * const M = getFirstMonoid() - * assert.deepStrictEqual(M.concat(none, none), none) - * assert.deepStrictEqual(M.concat(some(1), none), some(1)) - * assert.deepStrictEqual(M.concat(none, some(1)), some(1)) - * assert.deepStrictEqual(M.concat(some(1), some(2)), some(1)) + * assert.strictEqual( + * pipe( + * some(1), + * match(() => 'a none', a => `a some containing ${a}`) + * ), + * 'a some containing 1' + * ) * - * @category instances + * assert.strictEqual( + * pipe( + * none, + * match(() => 'a none', a => `a some containing ${a}`) + * ), + * 'a none' + * ) + * + * @category pattern matching + * @since 2.10.0 + */ +exports.match = exports.matchW; +/** + * Alias of [`match`](#match). + * + * @category pattern matching * @since 2.0.0 */ -function getFirstMonoid() { - return { - concat: function (x, y) { return (exports.isNone(x) ? y : x); }, - empty: exports.none - }; -} -exports.getFirstMonoid = getFirstMonoid; +exports.fold = exports.match; /** - * Monoid returning the right-most non-`None` value + * Less strict version of [`getOrElse`](#getorelse). * - * | x | y | concat(x, y) | - * | ------- | ------- | ------------ | - * | none | none | none | - * | some(a) | none | some(a) | - * | none | some(a) | some(a) | - * | some(a) | some(b) | some(b) | + * The `W` suffix (short for **W**idening) means that the handler return type will be merged. + * + * @category error handling + * @since 2.6.0 + */ +var getOrElseW = function (onNone) { + return function (ma) { + return (0, exports.isNone)(ma) ? onNone() : ma.value; + }; +}; +exports.getOrElseW = getOrElseW; +/** + * Extracts the value out of the structure, if it exists. Otherwise returns the given default value * * @example - * import { getLastMonoid, some, none } from 'fp-ts/Option' + * import { some, none, getOrElse } from 'fp-ts/Option' + * import { pipe } from 'fp-ts/function' * - * const M = getLastMonoid() - * assert.deepStrictEqual(M.concat(none, none), none) - * assert.deepStrictEqual(M.concat(some(1), none), some(1)) - * assert.deepStrictEqual(M.concat(none, some(1)), some(1)) - * assert.deepStrictEqual(M.concat(some(1), some(2)), some(2)) + * assert.strictEqual( + * pipe( + * some(1), + * getOrElse(() => 0) + * ), + * 1 + * ) + * assert.strictEqual( + * pipe( + * none, + * getOrElse(() => 0) + * ), + * 0 + * ) * - * @category instances + * @category error handling * @since 2.0.0 */ -function getLastMonoid() { - return { - concat: function (x, y) { return (exports.isNone(y) ? x : y); }, - empty: exports.none - }; -} -exports.getLastMonoid = getLastMonoid; +exports.getOrElse = exports.getOrElseW; /** - * Monoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are - * concatenated using the provided `Semigroup` - * - * | x | y | concat(x, y) | - * | ------- | ------- | ------------------ | - * | none | none | none | - * | some(a) | none | some(a) | - * | none | some(a) | some(a) | - * | some(a) | some(b) | some(concat(a, b)) | - * - * @example - * import { getMonoid, some, none } from 'fp-ts/Option' - * import { semigroupSum } from 'fp-ts/Semigroup' + * @category mapping + * @since 2.10.0 + */ +exports.flap = (0, Functor_1.flap)(exports.Functor); +/** + * Combine two effectful actions, keeping only the result of the first. * - * const M = getMonoid(semigroupSum) - * assert.deepStrictEqual(M.concat(none, none), none) - * assert.deepStrictEqual(M.concat(some(1), none), some(1)) - * assert.deepStrictEqual(M.concat(none, some(1)), some(1)) - * assert.deepStrictEqual(M.concat(some(1), some(2)), some(3)) + * @since 2.0.0 + */ +exports.apFirst = (0, Apply_1.apFirst)(exports.Apply); +/** + * Combine two effectful actions, keeping only the result of the second. * - * @category instances * @since 2.0.0 */ -function getMonoid(S) { - return { - concat: function (x, y) { return (exports.isNone(x) ? y : exports.isNone(y) ? x : exports.some(S.concat(x.value, y.value))); }, - empty: exports.none - }; -} -exports.getMonoid = getMonoid; +exports.apSecond = (0, Apply_1.apSecond)(exports.Apply); /** - * @category instances - * @since 2.7.0 + * @category sequencing + * @since 2.0.0 */ -exports.Functor = { - URI: exports.URI, - map: map_ -}; +exports.flatten = exports.compact; /** - * @category instances - * @since 2.7.0 + * Composes computations in sequence, using the return value of one computation to determine the next computation and + * keeping only the result of the first. + * + * @category combinators + * @since 2.15.0 */ -exports.Applicative = { - URI: exports.URI, - map: map_, - ap: ap_, - of: exports.of -}; +exports.tap = (0, function_1.dual)(2, chainable.tap(exports.Chain)); /** - * @category instances - * @since 2.7.0 + * Composes computations in sequence, using the return value of one computation to determine the next computation and + * keeping only the result of the first. + * + * @example + * import { pipe } from 'fp-ts/function' + * import * as O from 'fp-ts/Option' + * import * as E from 'fp-ts/Either' + * + * const compute = (value: number) => pipe( + * O.of(value), + * O.tapEither((value) => value > 0 ? E.right('ok') : E.left('error')), + * ) + * + * assert.deepStrictEqual(compute(1), O.of(1)) + * assert.deepStrictEqual(compute(-42), O.none) + * + * @category combinators + * @since 2.16.0 */ -exports.Monad = { - URI: exports.URI, - map: map_, - ap: ap_, - of: exports.of, - chain: chain_ -}; +exports.tapEither = (0, function_1.dual)(2, (0, FromEither_1.tapEither)(exports.FromEither, exports.Chain)); /** - * @category instances - * @since 2.7.0 + * @since 2.0.0 */ -exports.Foldable = { - URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_ -}; +exports.duplicate = (0, exports.extend)(function_1.identity); /** - * @category instances - * @since 2.7.0 + * @category lifting + * @since 2.11.0 */ -exports.Alt = { - URI: exports.URI, - map: map_, - alt: alt_ -}; +exports.fromEitherK = (0, FromEither_1.fromEitherK)(exports.FromEither); /** - * @category instances - * @since 2.7.0 + * @category sequencing + * @since 2.11.0 */ -exports.Alternative = { - URI: exports.URI, - map: map_, - ap: ap_, - of: exports.of, - alt: alt_, - zero: exports.zero -}; +exports.chainEitherK = +/*#__PURE__*/ (0, FromEither_1.chainEitherK)(exports.FromEither, exports.Chain); /** - * @category instances - * @since 2.7.0 + * Alias of `tapEither`. + * + * @category legacy + * @since 2.12.0 */ -exports.Extend = { - URI: exports.URI, - map: map_, - extend: extend_ -}; +exports.chainFirstEitherK = exports.tapEither; /** - * @category instances - * @since 2.7.0 + * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise + * returns the value wrapped in a `Some`. + * + * @example + * import { none, some, fromNullable } from 'fp-ts/Option' + * + * assert.deepStrictEqual(fromNullable(undefined), none) + * assert.deepStrictEqual(fromNullable(null), none) + * assert.deepStrictEqual(fromNullable(1), some(1)) + * + * @category conversions + * @since 2.0.0 */ -exports.Compactable = { - URI: exports.URI, - compact: exports.compact, - separate: exports.separate -}; +var fromNullable = function (a) { return (a == null ? exports.none : (0, exports.some)(a)); }; +exports.fromNullable = fromNullable; /** - * @category instances - * @since 2.7.0 + * Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a + * `Some`. + * + * See also [`tryCatchK`](#trycatchk). + * + * @example + * import { none, some, tryCatch } from 'fp-ts/Option' + * + * assert.deepStrictEqual( + * tryCatch(() => { + * throw new Error() + * }), + * none + * ) + * assert.deepStrictEqual(tryCatch(() => 1), some(1)) + * + * @category interop + * @since 2.0.0 */ -exports.Filterable = { - URI: exports.URI, - map: map_, - compact: exports.compact, - separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_ +var tryCatch = function (f) { + try { + return (0, exports.some)(f()); + } + catch (e) { + return exports.none; + } }; +exports.tryCatch = tryCatch; /** - * @category instances - * @since 2.7.0 + * Converts a function that may throw to one returning a `Option`. + * + * @category interop + * @since 2.10.0 */ -exports.Traversable = { - URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: exports.sequence +var tryCatchK = function (f) { + return function () { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } + return (0, exports.tryCatch)(function () { return f.apply(void 0, a); }); + }; }; +exports.tryCatchK = tryCatchK; /** - * @category instances - * @since 2.7.0 + * Returns a *smart constructor* from a function that returns a nullable value. + * + * @example + * import { fromNullableK, none, some } from 'fp-ts/Option' + * + * const f = (s: string): number | undefined => { + * const n = parseFloat(s) + * return isNaN(n) ? undefined : n + * } + * + * const g = fromNullableK(f) + * + * assert.deepStrictEqual(g('1'), some(1)) + * assert.deepStrictEqual(g('a'), none) + * + * @category lifting + * @since 2.9.0 */ -exports.Witherable = { - URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: exports.sequence, - compact: exports.compact, - separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - wither: wither_, - wilt: wilt_ -}; +var fromNullableK = function (f) { return (0, function_1.flow)(f, exports.fromNullable); }; +exports.fromNullableK = fromNullableK; /** - * @category instances - * @since 2.7.0 + * This is `chain` + `fromNullable`, useful when working with optional values. + * + * @example + * import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option' + * import { pipe } from 'fp-ts/function' + * + * interface Employee { + * readonly company?: { + * readonly address?: { + * readonly street?: { + * readonly name?: string + * } + * } + * } + * } + * + * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } } + * + * assert.deepStrictEqual( + * pipe( + * fromNullable(employee1.company), + * chainNullableK(company => company.address), + * chainNullableK(address => address.street), + * chainNullableK(street => street.name) + * ), + * some('high street') + * ) + * + * const employee2: Employee = { company: { address: { street: {} } } } + * + * assert.deepStrictEqual( + * pipe( + * fromNullable(employee2.company), + * chainNullableK(company => company.address), + * chainNullableK(address => address.street), + * chainNullableK(street => street.name) + * ), + * none + * ) + * + * @category sequencing + * @since 2.9.0 */ -exports.MonadThrow = { - URI: exports.URI, - map: map_, - ap: ap_, - of: exports.of, - chain: chain_, - throwError: exports.throwError +var chainNullableK = function (f) { + return function (ma) { + return (0, exports.isNone)(ma) ? exports.none : (0, exports.fromNullable)(f(ma.value)); + }; }; -// TODO: remove in v3 +exports.chainNullableK = chainNullableK; /** - * @category instances + * Extracts the value out of the structure, if it exists. Otherwise returns `null`. + * + * @example + * import { some, none, toNullable } from 'fp-ts/Option' + * import { pipe } from 'fp-ts/function' + * + * assert.strictEqual( + * pipe( + * some(1), + * toNullable + * ), + * 1 + * ) + * assert.strictEqual( + * pipe( + * none, + * toNullable + * ), + * null + * ) + * + * @category conversions * @since 2.0.0 */ -exports.option = { - URI: exports.URI, - map: map_, - of: exports.of, - ap: ap_, - chain: chain_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: exports.sequence, - zero: exports.zero, - alt: alt_, - extend: extend_, - compact: exports.compact, - separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - wither: wither_, - wilt: wilt_, - throwError: exports.throwError -}; -// ------------------------------------------------------------------------------------- -// utils -// ------------------------------------------------------------------------------------- +exports.toNullable = (0, exports.match)(function_1.constNull, function_1.identity); /** - * Returns `true` if `ma` contains `a` + * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`. * * @example - * import { some, none, elem } from 'fp-ts/Option' - * import { eqNumber } from 'fp-ts/Eq' + * import { some, none, toUndefined } from 'fp-ts/Option' + * import { pipe } from 'fp-ts/function' * - * assert.strictEqual(elem(eqNumber)(1, some(1)), true) - * assert.strictEqual(elem(eqNumber)(2, some(1)), false) - * assert.strictEqual(elem(eqNumber)(1, none), false) + * assert.strictEqual( + * pipe( + * some(1), + * toUndefined + * ), + * 1 + * ) + * assert.strictEqual( + * pipe( + * none, + * toUndefined + * ), + * undefined + * ) * + * @category conversions * @since 2.0.0 */ +exports.toUndefined = (0, exports.match)(function_1.constUndefined, function_1.identity); function elem(E) { - return function (a, ma) { return (exports.isNone(ma) ? false : E.equals(a, ma.value)); }; + return function (a, ma) { + if (ma === undefined) { + var elemE_1 = elem(E); + return function (ma) { return elemE_1(a, ma); }; + } + return (0, exports.isNone)(ma) ? false : E.equals(a, ma.value); + }; } exports.elem = elem; /** @@ -10946,273 +14497,455 @@ exports.elem = elem; * * @since 2.0.0 */ -function exists(predicate) { - return function (ma) { return (exports.isNone(ma) ? false : predicate(ma.value)); }; -} +var exists = function (predicate) { + return function (ma) { + return (0, exports.isNone)(ma) ? false : predicate(ma.value); + }; +}; exports.exists = exists; -/** - * Returns a `Refinement` (i.e. a custom type guard) from a `Option` returning function. - * This function ensures that a custom type guard definition is type-safe. - * - * ```ts - * import { some, none, getRefinement } from 'fp-ts/Option' - * - * type A = { type: 'A' } - * type B = { type: 'B' } - * type C = A | B - * - * const isA = (c: C): c is A => c.type === 'B' // <= typo but typescript doesn't complain - * const isA = getRefinement(c => (c.type === 'B' ? some(c) : none)) // static error: Type '"B"' is not assignable to type '"A"' - * ``` - * - * @since 2.0.0 - */ -function getRefinement(getOption) { - return function (a) { return exports.isSome(getOption(a)); }; -} -exports.getRefinement = getRefinement; // ------------------------------------------------------------------------------------- // do notation // ------------------------------------------------------------------------------------- /** + * @category do notation * @since 2.9.0 */ -exports.Do = -/*#__PURE__*/ -exports.of({}); +exports.Do = (0, exports.of)(_.emptyRecord); /** + * @category do notation * @since 2.8.0 */ -var bindTo = function (name) { return exports.map(function_1.bindTo_(name)); }; -exports.bindTo = bindTo; +exports.bindTo = (0, Functor_1.bindTo)(exports.Functor); +var let_ = /*#__PURE__*/ (0, Functor_1.let)(exports.Functor); +exports["let"] = let_; /** + * @category do notation * @since 2.8.0 */ -var bind = function (name, f) { - return exports.chain(function (a) { - return function_1.pipe(f(a), exports.map(function (b) { return function_1.bind_(a, name, b); })); - }); -}; -exports.bind = bind; -// ------------------------------------------------------------------------------------- -// pipeable sequence S -// ------------------------------------------------------------------------------------- +exports.bind = chainable.bind(exports.Chain); /** + * @category do notation * @since 2.8.0 */ -var apS = function (name, fb) { - return function_1.flow(exports.map(function (a) { return function (b) { return function_1.bind_(a, name, b); }; }), exports.ap(fb)); -}; -exports.apS = apS; +exports.apS = (0, Apply_1.apS)(exports.Apply); +/** + * @since 2.11.0 + */ +exports.ApT = (0, exports.of)(_.emptyReadonlyArray); // ------------------------------------------------------------------------------------- // array utils // ------------------------------------------------------------------------------------- /** + * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`. * - * @since 2.9.0 + * @category traversing + * @since 2.11.0 */ -var traverseArrayWithIndex = function (f) { return function (arr) { - // tslint:disable-next-line: readonly-array - var result = []; - for (var i = 0; i < arr.length; i++) { - var b = f(i, arr[i]); - if (exports.isNone(b)) { +var traverseReadonlyNonEmptyArrayWithIndex = function (f) { + return function (as) { + var o = f(0, _.head(as)); + if ((0, exports.isNone)(o)) { return exports.none; } - result.push(b.value); - } - return exports.some(result); -}; }; -exports.traverseArrayWithIndex = traverseArrayWithIndex; + var out = [o.value]; + for (var i = 1; i < as.length; i++) { + var o_1 = f(i, as[i]); + if ((0, exports.isNone)(o_1)) { + return exports.none; + } + out.push(o_1.value); + } + return (0, exports.some)(out); + }; +}; +exports.traverseReadonlyNonEmptyArrayWithIndex = traverseReadonlyNonEmptyArrayWithIndex; /** - * Runs an action for every element in array and accumulates the results in option + * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * - * this function has the same behavior of `A.sequence(O.option)` but it's optimized and performs better + * @category traversing + * @since 2.11.0 + */ +var traverseReadonlyArrayWithIndex = function (f) { + var g = (0, exports.traverseReadonlyNonEmptyArrayWithIndex)(f); + return function (as) { return (_.isNonEmpty(as) ? g(as) : exports.ApT); }; +}; +exports.traverseReadonlyArrayWithIndex = traverseReadonlyArrayWithIndex; +/** + * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * - * @example - * - * import * as A from 'fp-ts/Array' - * import { traverseArray, some, fromPredicate, none } from 'fp-ts/Option' - * import { pipe } from 'fp-ts/function' - * - * const arr = A.range(0, 10) - * assert.deepStrictEqual(pipe(arr, traverseArray(some)), some(arr)) - * assert.deepStrictEqual(pipe(arr, traverseArray(fromPredicate((x) => x > 5))), none) + * @category traversing + * @since 2.9.0 + */ +exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndex; +/** + * Equivalent to `ReadonlyArray#traverse(Applicative)`. * + * @category traversing * @since 2.9.0 */ -var traverseArray = function (f) { return exports.traverseArrayWithIndex(function (_, a) { return f(a); }); }; +var traverseArray = function (f) { + return (0, exports.traverseReadonlyArrayWithIndex)(function (_, a) { return f(a); }); +}; exports.traverseArray = traverseArray; /** - * get an array of option and convert it to option of array - * - * this function has the same behavior of `A.sequence(O.option)` but it's optimized and performs better - * - * @example - * - * import * as A from 'fp-ts/Array' - * import { sequenceArray, some, none, fromPredicate } from 'fp-ts/Option' - * import { pipe } from 'fp-ts/function' - * - * const arr = A.range(0, 10) - * assert.deepStrictEqual(pipe(arr, A.map(some), sequenceArray), some(arr)) - * assert.deepStrictEqual(pipe(arr, A.map(fromPredicate(x => x > 8)), sequenceArray), none) + * Equivalent to `ReadonlyArray#sequence(Applicative)`. * + * @category traversing * @since 2.9.0 */ exports.sequenceArray = -/*#__PURE__*/ -exports.traverseArray(function_1.identity); - - -/***/ }), - -/***/ 6685: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.ord = exports.Contravariant = exports.ordDate = exports.URI = exports.contramap = exports.getDualOrd = exports.getTupleOrd = exports.getMonoid = exports.getSemigroup = exports.fromCompare = exports.between = exports.clamp = exports.max = exports.min = exports.geq = exports.leq = exports.gt = exports.lt = exports.ordBoolean = exports.ordNumber = exports.ordString = void 0; -var Ordering_1 = __nccwpck_require__(4397); -var function_1 = __nccwpck_require__(6985); -// default compare for primitive types -function compare(x, y) { - return x < y ? -1 : x > y ? 1 : 0; -} -function strictEqual(a, b) { - return a === b; -} +/*#__PURE__*/ (0, exports.traverseArray)(function_1.identity); +// ------------------------------------------------------------------------------------- +// legacy +// ------------------------------------------------------------------------------------- /** - * @category instances + * Alias of `flatMap`. + * + * @category legacy * @since 2.0.0 */ -exports.ordString = { - equals: strictEqual, - compare: compare -}; +exports.chain = exports.flatMap; /** - * @category instances + * Alias of `tap`. + * + * @category legacy * @since 2.0.0 */ -exports.ordNumber = { - equals: strictEqual, - compare: compare -}; +exports.chainFirst = exports.tap; +// ------------------------------------------------------------------------------------- +// deprecated +// ------------------------------------------------------------------------------------- /** - * @category instances + * Use `Refinement` module instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.ordBoolean = { - equals: strictEqual, - compare: compare -}; -// TODO: curry in v3 +function getRefinement(getOption) { + return function (a) { return (0, exports.isSome)(getOption(a)); }; +} +exports.getRefinement = getRefinement; /** - * Test whether one value is _strictly less than_ another + * Use [`chainNullableK`](#chainnullablek) instead. * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function lt(O) { - return function (x, y) { return O.compare(x, y) === -1; }; -} -exports.lt = lt; -// TODO: curry in v3 +exports.mapNullable = exports.chainNullableK; /** - * Test whether one value is _strictly greater than_ another + * This instance is deprecated, use small, specific instances instead. + * For example if a function needs a `Functor` instance, pass `O.Functor` instead of `O.option` + * (where `O` is from `import O from 'fp-ts/Option'`) * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function gt(O) { - return function (x, y) { return O.compare(x, y) === 1; }; -} -exports.gt = gt; -// TODO: curry in v3 +exports.option = { + URI: exports.URI, + map: _map, + of: exports.of, + ap: _ap, + chain: exports.flatMap, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, + sequence: exports.sequence, + zero: exports.zero, + alt: _alt, + extend: _extend, + compact: exports.compact, + separate: exports.separate, + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + wither: _wither, + wilt: _wilt, + throwError: exports.throwError +}; /** - * Test whether one value is _non-strictly less than_ another + * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function leq(O) { - return function (x, y) { return O.compare(x, y) !== 1; }; -} -exports.leq = leq; -// TODO: curry in v3 +exports.getApplySemigroup = (0, Apply_1.getApplySemigroup)(exports.Apply); /** - * Test whether one value is _non-strictly greater than_ another + * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead. * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function geq(O) { - return function (x, y) { return O.compare(x, y) !== -1; }; -} -exports.geq = geq; -// TODO: curry in v3 +exports.getApplyMonoid = (0, Applicative_1.getApplicativeMonoid)(exports.Applicative); /** - * Take the minimum of two values. If they are considered equal, the first argument is chosen + * Use + * + * ```ts + * import { first } from 'fp-ts/Semigroup' + * import { getMonoid } from 'fp-ts/Option' + * + * getMonoid(first()) + * ``` + * + * instead. + * + * Monoid returning the left-most non-`None` value + * + * | x | y | concat(x, y) | + * | ------- | ------- | ------------ | + * | none | none | none | + * | some(a) | none | some(a) | + * | none | some(b) | some(b) | + * | some(a) | some(b) | some(a) | + * + * @example + * import { getFirstMonoid, some, none } from 'fp-ts/Option' + * + * const M = getFirstMonoid() + * assert.deepStrictEqual(M.concat(none, none), none) + * assert.deepStrictEqual(M.concat(some(1), none), some(1)) + * assert.deepStrictEqual(M.concat(none, some(2)), some(2)) + * assert.deepStrictEqual(M.concat(some(1), some(2)), some(1)) * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function min(O) { - return function (x, y) { return (O.compare(x, y) === 1 ? y : x); }; -} -exports.min = min; -// TODO: curry in v3 +var getFirstMonoid = function () { return (0, exports.getMonoid)((0, Semigroup_1.first)()); }; +exports.getFirstMonoid = getFirstMonoid; /** - * Take the maximum of two values. If they are considered equal, the first argument is chosen + * Use + * + * ```ts + * import { last } from 'fp-ts/Semigroup' + * import { getMonoid } from 'fp-ts/Option' + * + * getMonoid(last()) + * ``` + * + * instead. + * + * Monoid returning the right-most non-`None` value + * + * | x | y | concat(x, y) | + * | ------- | ------- | ------------ | + * | none | none | none | + * | some(a) | none | some(a) | + * | none | some(b) | some(b) | + * | some(a) | some(b) | some(b) | + * + * @example + * import { getLastMonoid, some, none } from 'fp-ts/Option' + * + * const M = getLastMonoid() + * assert.deepStrictEqual(M.concat(none, none), none) + * assert.deepStrictEqual(M.concat(some(1), none), some(1)) + * assert.deepStrictEqual(M.concat(none, some(2)), some(2)) + * assert.deepStrictEqual(M.concat(some(1), some(2)), some(2)) * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +var getLastMonoid = function () { return (0, exports.getMonoid)((0, Semigroup_1.last)()); }; +exports.getLastMonoid = getLastMonoid; + + +/***/ }), + +/***/ 6685: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.ordDate = exports.ordNumber = exports.ordString = exports.ordBoolean = exports.ord = exports.getDualOrd = exports.getTupleOrd = exports.between = exports.clamp = exports.max = exports.min = exports.geq = exports.leq = exports.gt = exports.lt = exports.equals = exports.trivial = exports.Contravariant = exports.getMonoid = exports.getSemigroup = exports.URI = exports.contramap = exports.reverse = exports.tuple = exports.fromCompare = exports.equalsDefault = void 0; +var Eq_1 = __nccwpck_require__(6964); +var function_1 = __nccwpck_require__(6985); +// ------------------------------------------------------------------------------------- +// defaults +// ------------------------------------------------------------------------------------- +/** + * @category defaults + * @since 2.10.0 + */ +var equalsDefault = function (compare) { + return function (first, second) { + return first === second || compare(first, second) === 0; + }; +}; +exports.equalsDefault = equalsDefault; +// ------------------------------------------------------------------------------------- +// constructors +// ------------------------------------------------------------------------------------- +/** + * @category constructors * @since 2.0.0 */ -function max(O) { - return function (x, y) { return (O.compare(x, y) === -1 ? y : x); }; -} -exports.max = max; +var fromCompare = function (compare) { return ({ + equals: (0, exports.equalsDefault)(compare), + compare: function (first, second) { return (first === second ? 0 : compare(first, second)); } +}); }; +exports.fromCompare = fromCompare; +// ------------------------------------------------------------------------------------- +// combinators +// ------------------------------------------------------------------------------------- /** - * Clamp a value between a minimum and a maximum + * Given a tuple of `Ord`s returns an `Ord` for the tuple. * - * @since 2.0.0 + * @example + * import { tuple } from 'fp-ts/Ord' + * import * as B from 'fp-ts/boolean' + * import * as S from 'fp-ts/string' + * import * as N from 'fp-ts/number' + * + * const O = tuple(S.Ord, N.Ord, B.Ord) + * assert.strictEqual(O.compare(['a', 1, true], ['b', 2, true]), -1) + * assert.strictEqual(O.compare(['a', 1, true], ['a', 2, true]), -1) + * assert.strictEqual(O.compare(['a', 1, true], ['a', 1, false]), 1) + * + * @since 2.10.0 */ -function clamp(O) { - var minO = min(O); - var maxO = max(O); - return function (low, hi) { return function (x) { return maxO(minO(x, hi), low); }; }; -} -exports.clamp = clamp; +var tuple = function () { + var ords = []; + for (var _i = 0; _i < arguments.length; _i++) { + ords[_i] = arguments[_i]; + } + return (0, exports.fromCompare)(function (first, second) { + var i = 0; + for (; i < ords.length - 1; i++) { + var r = ords[i].compare(first[i], second[i]); + if (r !== 0) { + return r; + } + } + return ords[i].compare(first[i], second[i]); + }); +}; +exports.tuple = tuple; /** - * Test whether a value is between a minimum and a maximum (inclusive) + * @since 2.10.0 + */ +var reverse = function (O) { return (0, exports.fromCompare)(function (first, second) { return O.compare(second, first); }); }; +exports.reverse = reverse; +/* istanbul ignore next */ +var contramap_ = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.contramap)(f)); }; +/** + * A typical use case for `contramap` would be like, given some `User` type, to construct an `Ord`. + * + * We can do so with a function from `User -> X` where `X` is some value that we know how to compare + * for ordering (meaning we have an `Ord`) + * + * For example, given the following `User` type, there are lots of possible choices for `X`, + * but let's say we want to sort a list of users by `lastName`. + * + * If we have a way of comparing `lastName`s for ordering (`ordLastName: Ord`) and we know how to go from `User -> string`, + * using `contramap` we can do this + * + * @example + * import { pipe } from 'fp-ts/function' + * import { contramap, Ord } from 'fp-ts/Ord' + * import * as RA from 'fp-ts/ReadonlyArray' + * import * as S from 'fp-ts/string' + * + * interface User { + * readonly firstName: string + * readonly lastName: string + * } + * + * const ordLastName: Ord = S.Ord + * + * const ordByLastName: Ord = pipe( + * ordLastName, + * contramap((user) => user.lastName) + * ) + * + * assert.deepStrictEqual( + * RA.sort(ordByLastName)([ + * { firstName: 'a', lastName: 'd' }, + * { firstName: 'c', lastName: 'b' } + * ]), + * [ + * { firstName: 'c', lastName: 'b' }, + * { firstName: 'a', lastName: 'd' } + * ] + * ) * * @since 2.0.0 */ -function between(O) { - var lessThanO = lt(O); - var greaterThanO = gt(O); - return function (low, hi) { return function (x) { return (lessThanO(x, low) || greaterThanO(x, hi) ? false : true); }; }; -} -exports.between = between; +var contramap = function (f) { return function (fa) { + return (0, exports.fromCompare)(function (first, second) { return fa.compare(f(first), f(second)); }); +}; }; +exports.contramap = contramap; /** - * @category constructors + * @category type lambdas * @since 2.0.0 */ -function fromCompare(compare) { - var optimizedCompare = function (x, y) { return (x === y ? 0 : compare(x, y)); }; - return { - equals: function (x, y) { return optimizedCompare(x, y) === 0; }, - compare: optimizedCompare - }; -} -exports.fromCompare = fromCompare; +exports.URI = 'Ord'; /** - * Use `getMonoid` instead + * A typical use case for the `Semigroup` instance of `Ord` is merging two or more orderings. + * + * For example the following snippet builds an `Ord` for a type `User` which + * sorts by `created` date descending, and **then** `lastName` + * + * @example + * import * as D from 'fp-ts/Date' + * import { pipe } from 'fp-ts/function' + * import { contramap, getSemigroup, Ord, reverse } from 'fp-ts/Ord' + * import * as RA from 'fp-ts/ReadonlyArray' + * import * as S from 'fp-ts/string' + * + * interface User { + * readonly id: string + * readonly lastName: string + * readonly created: Date + * } + * + * const ordByLastName: Ord = pipe( + * S.Ord, + * contramap((user) => user.lastName) + * ) + * + * const ordByCreated: Ord = pipe( + * D.Ord, + * contramap((user) => user.created) + * ) + * + * const ordUserByCreatedDescThenLastName = getSemigroup().concat( + * reverse(ordByCreated), + * ordByLastName + * ) + * + * assert.deepStrictEqual( + * RA.sort(ordUserByCreatedDescThenLastName)([ + * { id: 'c', lastName: 'd', created: new Date(1973, 10, 30) }, + * { id: 'a', lastName: 'b', created: new Date(1973, 10, 30) }, + * { id: 'e', lastName: 'f', created: new Date(1980, 10, 30) } + * ]), + * [ + * { id: 'e', lastName: 'f', created: new Date(1980, 10, 30) }, + * { id: 'a', lastName: 'b', created: new Date(1973, 10, 30) }, + * { id: 'c', lastName: 'd', created: new Date(1973, 10, 30) } + * ] + * ) * * @category instances * @since 2.0.0 - * @deprecated */ -function getSemigroup() { - return { - concat: function (x, y) { return fromCompare(function (a, b) { return Ordering_1.monoidOrdering.concat(x.compare(a, b), y.compare(a, b)); }); } - }; -} +var getSemigroup = function () { return ({ + concat: function (first, second) { + return (0, exports.fromCompare)(function (a, b) { + var ox = first.compare(a, b); + return ox !== 0 ? ox : second.compare(a, b); + }); + } +}); }; exports.getSemigroup = getSemigroup; /** * Returns a `Monoid` such that: @@ -11222,29 +14955,32 @@ exports.getSemigroup = getSemigroup; * * @example * import { sort } from 'fp-ts/Array' - * import { contramap, getDualOrd, getMonoid, ordBoolean, ordNumber, ordString } from 'fp-ts/Ord' + * import { contramap, reverse, getMonoid } from 'fp-ts/Ord' + * import * as S from 'fp-ts/string' + * import * as B from 'fp-ts/boolean' * import { pipe } from 'fp-ts/function' - * import { fold } from 'fp-ts/Monoid' + * import { concatAll } from 'fp-ts/Monoid' + * import * as N from 'fp-ts/number' * * interface User { - * id: number - * name: string - * age: number - * rememberMe: boolean + * readonly id: number + * readonly name: string + * readonly age: number + * readonly rememberMe: boolean * } * * const byName = pipe( - * ordString, + * S.Ord, * contramap((p: User) => p.name) * ) * * const byAge = pipe( - * ordNumber, + * N.Ord, * contramap((p: User) => p.age) * ) * * const byRememberMe = pipe( - * ordBoolean, + * B.Ord, * contramap((p: User) => p.rememberMe) * ) * @@ -11258,7 +14994,7 @@ exports.getSemigroup = getSemigroup; * ] * * // sort by name, then by age, then by `rememberMe` - * const O1 = fold(M)([byName, byAge, byRememberMe]) + * const O1 = concatAll(M)([byName, byAge, byRememberMe]) * assert.deepStrictEqual(sort(O1)(users), [ * { id: 3, name: 'Giulio', age: 44, rememberMe: false }, * { id: 4, name: 'Giulio', age: 44, rememberMe: true }, @@ -11267,7 +15003,7 @@ exports.getSemigroup = getSemigroup; * ]) * * // now `rememberMe = true` first, then by name, then by age - * const O2 = fold(M)([getDualOrd(byRememberMe), byName, byAge]) + * const O2 = concatAll(M)([reverse(byRememberMe), byName, byAge]) * assert.deepStrictEqual(sort(O2)(users), [ * { id: 4, name: 'Giulio', age: 44, rememberMe: true }, * { id: 2, name: 'Guido', age: 46, rememberMe: true }, @@ -11278,159 +15014,306 @@ exports.getSemigroup = getSemigroup; * @category instances * @since 2.4.0 */ -function getMonoid() { - return { - // tslint:disable-next-line: deprecation - concat: getSemigroup().concat, - empty: fromCompare(function () { return 0; }) - }; -} +var getMonoid = function () { return ({ + concat: (0, exports.getSemigroup)().concat, + empty: (0, exports.fromCompare)(function () { return 0; }) +}); }; exports.getMonoid = getMonoid; /** - * Given a tuple of `Ord`s returns an `Ord` for the tuple + * @category instances + * @since 2.7.0 + */ +exports.Contravariant = { + URI: exports.URI, + contramap: contramap_ +}; +// ------------------------------------------------------------------------------------- +// utils +// ------------------------------------------------------------------------------------- +/** + * @since 2.11.0 + */ +exports.trivial = { + equals: function_1.constTrue, + compare: /*#__PURE__*/ (0, function_1.constant)(0) +}; +/** + * @since 2.11.0 + */ +var equals = function (O) { + return function (second) { + return function (first) { + return first === second || O.compare(first, second) === 0; + }; + }; +}; +exports.equals = equals; +// TODO: curry in v3 +/** + * Test whether one value is _strictly less than_ another * - * @example - * import { getTupleOrd, ordString, ordNumber, ordBoolean } from 'fp-ts/Ord' + * @since 2.0.0 + */ +var lt = function (O) { + return function (first, second) { + return O.compare(first, second) === -1; + }; +}; +exports.lt = lt; +// TODO: curry in v3 +/** + * Test whether one value is _strictly greater than_ another * - * const O = getTupleOrd(ordString, ordNumber, ordBoolean) - * assert.strictEqual(O.compare(['a', 1, true], ['b', 2, true]), -1) - * assert.strictEqual(O.compare(['a', 1, true], ['a', 2, true]), -1) - * assert.strictEqual(O.compare(['a', 1, true], ['a', 1, false]), 1) + * @since 2.0.0 + */ +var gt = function (O) { + return function (first, second) { + return O.compare(first, second) === 1; + }; +}; +exports.gt = gt; +// TODO: curry in v3 +/** + * Test whether one value is _non-strictly less than_ another * - * @category instances * @since 2.0.0 */ -function getTupleOrd() { - var ords = []; - for (var _i = 0; _i < arguments.length; _i++) { - ords[_i] = arguments[_i]; - } - var len = ords.length; - return fromCompare(function (x, y) { - var i = 0; - for (; i < len - 1; i++) { - var r = ords[i].compare(x[i], y[i]); - if (r !== 0) { - return r; - } - } - return ords[i].compare(x[i], y[i]); - }); -} -exports.getTupleOrd = getTupleOrd; +var leq = function (O) { + return function (first, second) { + return O.compare(first, second) !== 1; + }; +}; +exports.leq = leq; +// TODO: curry in v3 /** - * @category combinators + * Test whether one value is _non-strictly greater than_ another + * * @since 2.0.0 */ -function getDualOrd(O) { - return fromCompare(function (x, y) { return O.compare(y, x); }); -} -exports.getDualOrd = getDualOrd; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -/* istanbul ignore next */ -var contramap_ = function (fa, f) { return function_1.pipe(fa, exports.contramap(f)); }; -// ------------------------------------------------------------------------------------- -// pipeables -// ------------------------------------------------------------------------------------- +var geq = function (O) { + return function (first, second) { + return O.compare(first, second) !== -1; + }; +}; +exports.geq = geq; +// TODO: curry in v3 /** - * @category Contravariant + * Take the minimum of two values. If they are considered equal, the first argument is chosen + * * @since 2.0.0 */ -var contramap = function (f) { return function (fa) { - return fromCompare(function (x, y) { return fa.compare(f(x), f(y)); }); -}; }; -exports.contramap = contramap; +var min = function (O) { + return function (first, second) { + return first === second || O.compare(first, second) < 1 ? first : second; + }; +}; +exports.min = min; +// TODO: curry in v3 +/** + * Take the maximum of two values. If they are considered equal, the first argument is chosen + * + * @since 2.0.0 + */ +var max = function (O) { + return function (first, second) { + return first === second || O.compare(first, second) > -1 ? first : second; + }; +}; +exports.max = max; +/** + * Clamp a value between a minimum and a maximum + * + * @since 2.0.0 + */ +var clamp = function (O) { + var minO = (0, exports.min)(O); + var maxO = (0, exports.max)(O); + return function (low, hi) { return function (a) { return maxO(minO(a, hi), low); }; }; +}; +exports.clamp = clamp; +/** + * Test whether a value is between a minimum and a maximum (inclusive) + * + * @since 2.0.0 + */ +var between = function (O) { + var ltO = (0, exports.lt)(O); + var gtO = (0, exports.gt)(O); + return function (low, hi) { return function (a) { return ltO(a, low) || gtO(a, hi) ? false : true; }; }; +}; +exports.between = between; // ------------------------------------------------------------------------------------- -// instances +// deprecated // ------------------------------------------------------------------------------------- /** - * @category instances + * Use [`tuple`](#tuple) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.URI = 'Ord'; +exports.getTupleOrd = exports.tuple; /** - * @category instances + * Use [`reverse`](#reverse) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.ordDate = -/*#__PURE__*/ -function_1.pipe(exports.ordNumber, -/*#__PURE__*/ -exports.contramap(function (date) { return date.valueOf(); })); +exports.getDualOrd = exports.reverse; /** - * @category instances - * @since 2.7.0 + * Use [`Contravariant`](#contravariant) instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated */ -exports.Contravariant = { - URI: exports.URI, - contramap: contramap_ +exports.ord = exports.Contravariant; +// default compare for primitive types +function compare(first, second) { + return first < second ? -1 : first > second ? 1 : 0; +} +var strictOrd = { + equals: Eq_1.eqStrict.equals, + compare: compare }; -// TODO: remove in v3 /** - * @category instances + * Use [`Ord`](./boolean.ts.html#ord) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.ord = exports.Contravariant; +exports.ordBoolean = strictOrd; +/** + * Use [`Ord`](./string.ts.html#ord) instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.ordString = strictOrd; +/** + * Use [`Ord`](./number.ts.html#ord) instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.ordNumber = strictOrd; +/** + * Use [`Ord`](./Date.ts.html#ord) instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.ordDate = (0, function_1.pipe)(exports.ordNumber, +/*#__PURE__*/ +(0, exports.contramap)(function (date) { return date.valueOf(); })); /***/ }), -/***/ 4397: -/***/ ((__unused_webpack_module, exports) => { +/***/ 6382: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.invert = exports.monoidOrdering = exports.semigroupOrdering = exports.eqOrdering = exports.sign = void 0; +exports.and = exports.or = exports.not = exports.Contravariant = exports.getMonoidAll = exports.getSemigroupAll = exports.getMonoidAny = exports.getSemigroupAny = exports.URI = exports.contramap = void 0; +var function_1 = __nccwpck_require__(6985); +var contramap_ = function (predicate, f) { return (0, function_1.pipe)(predicate, (0, exports.contramap)(f)); }; /** - * @since 2.0.0 + * @since 2.11.0 */ -function sign(n) { - return n <= -1 ? -1 : n >= 1 ? 1 : 0; -} -exports.sign = sign; +var contramap = function (f) { + return function (predicate) { + return (0, function_1.flow)(f, predicate); + }; +}; +exports.contramap = contramap; +/** + * @category type lambdas + * @since 2.11.0 + */ +exports.URI = 'Predicate'; /** * @category instances - * @since 2.0.0 + * @since 2.11.0 */ -exports.eqOrdering = { - equals: function (x, y) { return x === y; } -}; +var getSemigroupAny = function () { return ({ + concat: function (first, second) { return (0, function_1.pipe)(first, (0, exports.or)(second)); } +}); }; +exports.getSemigroupAny = getSemigroupAny; /** - * Use `monoidOrdering` instead - * * @category instances - * @since 2.0.0 - * @deprecated + * @since 2.11.0 */ -exports.semigroupOrdering = { - concat: function (x, y) { return (x !== 0 ? x : y); } -}; +var getMonoidAny = function () { return ({ + concat: (0, exports.getSemigroupAny)().concat, + empty: function_1.constFalse +}); }; +exports.getMonoidAny = getMonoidAny; /** * @category instances - * @since 2.4.0 + * @since 2.11.0 */ -exports.monoidOrdering = { - // tslint:disable-next-line: deprecation - concat: exports.semigroupOrdering.concat, - empty: 0 +var getSemigroupAll = function () { return ({ + concat: function (first, second) { return (0, function_1.pipe)(first, (0, exports.and)(second)); } +}); }; +exports.getSemigroupAll = getSemigroupAll; +/** + * @category instances + * @since 2.11.0 + */ +var getMonoidAll = function () { return ({ + concat: (0, exports.getSemigroupAll)().concat, + empty: function_1.constTrue +}); }; +exports.getMonoidAll = getMonoidAll; +/** + * @category instances + * @since 2.11.0 + */ +exports.Contravariant = { + URI: exports.URI, + contramap: contramap_ }; +// ------------------------------------------------------------------------------------- +// utils +// ------------------------------------------------------------------------------------- /** - * @since 2.0.0 + * @since 2.11.0 */ -function invert(O) { - switch (O) { - case -1: - return 1; - case 1: - return -1; - default: - return 0; - } -} -exports.invert = invert; +var not = function (predicate) { + return function (a) { + return !predicate(a); + }; +}; +exports.not = not; +/** + * @since 2.11.0 + */ +var or = function (second) { + return function (first) { + return function (a) { + return first(a) || second(a); + }; + }; +}; +exports.or = or; +/** + * @since 2.11.0 + */ +var and = function (second) { + return function (first) { + return function (a) { + return first(a) && second(a); + }; + }; +}; +exports.and = and; /***/ }), @@ -11442,7 +15325,11 @@ exports.invert = invert; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -11459,152 +15346,99 @@ var __importStar = (this && this.__importStar) || function (mod) { __setModuleDefault(result, mod); return result; }; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.intersperse = exports.prependToAll = exports.unzip = exports.zip = exports.zipWith = exports.sort = exports.lefts = exports.rights = exports.reverse = exports.modifyAt = exports.deleteAt = exports.updateAt = exports.insertAt = exports.findLastIndex = exports.findLastMap = exports.findLast = exports.findFirstMap = exports.findFirst = exports.findIndex = exports.dropLeftWhile = exports.dropRight = exports.dropLeft = exports.spanLeft = exports.takeLeftWhile = exports.takeRight = exports.takeLeft = exports.init = exports.tail = exports.last = exports.head = exports.snoc = exports.cons = exports.lookup = exports.isOutOfBound = exports.isNonEmpty = exports.isEmpty = exports.scanRight = exports.scanLeft = exports.foldRight = exports.foldLeft = exports.flatten = exports.replicate = exports.range = exports.makeBy = exports.getOrd = exports.getEq = exports.getMonoid = exports.getShow = exports.toArray = exports.fromArray = void 0; -exports.FunctorWithIndex = exports.Functor = exports.URI = exports.unfold = exports.wilt = exports.wither = exports.traverseWithIndex = exports.sequence = exports.traverse = exports.reduceRightWithIndex = exports.reduceRight = exports.reduceWithIndex = exports.foldMap = exports.reduce = exports.foldMapWithIndex = exports.duplicate = exports.extend = exports.filterWithIndex = exports.partitionMapWithIndex = exports.partitionMap = exports.partitionWithIndex = exports.partition = exports.compact = exports.filterMap = exports.filterMapWithIndex = exports.filter = exports.separate = exports.mapWithIndex = exports.map = exports.chainFirst = exports.chainWithIndex = exports.chain = exports.apSecond = exports.apFirst = exports.ap = exports.alt = exports.altW = exports.zero = exports.of = exports.difference = exports.intersection = exports.union = exports.comprehension = exports.chunksOf = exports.splitAt = exports.chop = exports.sortBy = exports.uniq = exports.elem = exports.rotate = void 0; -exports.apS = exports.bind = exports.bindTo = exports.Do = exports.some = exports.every = exports.empty = exports.unsafeDeleteAt = exports.unsafeUpdateAt = exports.unsafeInsertAt = exports.readonlyArray = exports.Witherable = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.FilterableWithIndex = exports.Filterable = exports.Compactable = exports.Extend = exports.Alternative = exports.Alt = exports.Unfoldable = exports.Monad = exports.Applicative = void 0; +exports.sort = exports.lefts = exports.rights = exports.reverse = exports.modifyAt = exports.deleteAt = exports.updateAt = exports.insertAt = exports.findLastIndex = exports.findLastMap = exports.findLast = exports.findFirstMap = exports.findFirst = exports.findIndex = exports.dropLeftWhile = exports.dropRight = exports.dropLeft = exports.spanLeft = exports.takeLeftWhile = exports.takeRight = exports.takeLeft = exports.init = exports.tail = exports.last = exports.head = exports.lookup = exports.isOutOfBound = exports.size = exports.scanRight = exports.scanLeft = exports.chainWithIndex = exports.foldRight = exports.matchRight = exports.matchRightW = exports.foldLeft = exports.matchLeft = exports.matchLeftW = exports.match = exports.matchW = exports.fromEither = exports.fromOption = exports.fromPredicate = exports.replicate = exports.makeBy = exports.appendW = exports.append = exports.prependW = exports.prepend = exports.isNonEmpty = exports.isEmpty = void 0; +exports.sequence = exports.traverse = exports.reduceRightWithIndex = exports.reduceRight = exports.reduceWithIndex = exports.foldMap = exports.reduce = exports.foldMapWithIndex = exports.duplicate = exports.extend = exports.filterWithIndex = exports.partitionMapWithIndex = exports.partitionMap = exports.partitionWithIndex = exports.partition = exports.compact = exports.filterMap = exports.filterMapWithIndex = exports.filter = exports.separate = exports.mapWithIndex = exports.map = exports.flatten = exports.flatMap = exports.ap = exports.alt = exports.altW = exports.zero = exports.of = exports._chainRecBreadthFirst = exports._chainRecDepthFirst = exports.difference = exports.intersection = exports.union = exports.concat = exports.concatW = exports.comprehension = exports.fromOptionK = exports.chunksOf = exports.splitAt = exports.chop = exports.sortBy = exports.uniq = exports.elem = exports.rotate = exports.intersperse = exports.prependAll = exports.unzip = exports.zip = exports.zipWith = void 0; +exports.toArray = exports.unsafeDeleteAt = exports.unsafeUpdateAt = exports.unsafeInsertAt = exports.fromEitherK = exports.FromEither = exports.filterE = exports.Witherable = exports.ChainRecBreadthFirst = exports.chainRecBreadthFirst = exports.ChainRecDepthFirst = exports.chainRecDepthFirst = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.FilterableWithIndex = exports.Filterable = exports.Compactable = exports.Extend = exports.Alternative = exports.guard = exports.Zero = exports.Alt = exports.Unfoldable = exports.chainFirst = exports.Monad = exports.Chain = exports.Applicative = exports.apSecond = exports.apFirst = exports.Apply = exports.FunctorWithIndex = exports.Pointed = exports.flap = exports.Functor = exports.getDifferenceMagma = exports.getIntersectionSemigroup = exports.getUnionMonoid = exports.getUnionSemigroup = exports.getOrd = exports.getEq = exports.getMonoid = exports.getSemigroup = exports.getShow = exports.URI = exports.unfold = exports.wilt = exports.wither = exports.traverseWithIndex = void 0; +exports.readonlyArray = exports.prependToAll = exports.snoc = exports.cons = exports.range = exports.chain = exports.apS = exports.bind = exports["let"] = exports.bindTo = exports.Do = exports.intercalate = exports.exists = exports.some = exports.every = exports.empty = exports.fromArray = void 0; +var Apply_1 = __nccwpck_require__(205); +var Chain_1 = __nccwpck_require__(2372); +var Eq_1 = __nccwpck_require__(6964); +var FromEither_1 = __nccwpck_require__(1964); var function_1 = __nccwpck_require__(6985); -var O = __importStar(__nccwpck_require__(2569)); +var Functor_1 = __nccwpck_require__(5533); +var _ = __importStar(__nccwpck_require__(1840)); +var N = __importStar(__nccwpck_require__(52)); var Ord_1 = __nccwpck_require__(6685); +var RNEA = __importStar(__nccwpck_require__(8630)); +var Separated_1 = __nccwpck_require__(5877); +var Witherable_1 = __nccwpck_require__(4384); +var Zero_1 = __nccwpck_require__(9734); // ------------------------------------------------------------------------------------- -// model +// refinements // ------------------------------------------------------------------------------------- /** - * @category constructors - * @since 2.5.0 - */ -// tslint:disable-next-line: readonly-array -function fromArray(as) { - var l = as.length; - if (l === 0) { - return exports.empty; - } - var ras = Array(l); - for (var i = 0; i < l; i++) { - ras[i] = as[i]; - } - return ras; -} -exports.fromArray = fromArray; -/** - * @category destructors + * Test whether a `ReadonlyArray` is empty. + * + * @example + * import { isEmpty } from 'fp-ts/ReadonlyArray' + * + * assert.strictEqual(isEmpty([]), true) + * + * @category refinements * @since 2.5.0 */ -// tslint:disable-next-line: readonly-array -function toArray(ras) { - var l = ras.length; - var as = Array(l); - for (var i = 0; i < l; i++) { - as[i] = ras[i]; - } - return as; -} -exports.toArray = toArray; +var isEmpty = function (as) { return as.length === 0; }; +exports.isEmpty = isEmpty; /** - * @category instances + * Test whether a `ReadonlyArray` is non empty. + * + * @category refinements * @since 2.5.0 */ -function getShow(S) { - return { - show: function (as) { return "[" + as.map(S.show).join(', ') + "]"; } - }; -} -exports.getShow = getShow; -var concat = function (x, y) { - var lenx = x.length; - if (lenx === 0) { - return y; - } - var leny = y.length; - if (leny === 0) { - return x; - } - var r = Array(lenx + leny); - for (var i = 0; i < lenx; i++) { - r[i] = x[i]; - } - for (var i = 0; i < leny; i++) { - r[i + lenx] = y[i]; - } - return r; -}; +exports.isNonEmpty = RNEA.isNonEmpty; +// ------------------------------------------------------------------------------------- +// constructors +// ------------------------------------------------------------------------------------- /** - * Returns a `Monoid` for `ReadonlyArray` + * Prepend an element to the front of a `ReadonlyArray`, creating a new `ReadonlyNonEmptyArray`. * * @example - * import { getMonoid } from 'fp-ts/ReadonlyArray' + * import { prepend } from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' * - * const M = getMonoid() - * assert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4]) + * assert.deepStrictEqual(pipe([2, 3, 4], prepend(1)), [1, 2, 3, 4]) * - * @category instances - * @since 2.5.0 + * @since 2.10.0 */ -function getMonoid() { - return { - concat: concat, - empty: exports.empty - }; -} -exports.getMonoid = getMonoid; +exports.prepend = RNEA.prepend; /** - * Derives an `Eq` over the `ReadonlyArray` of a given element type from the `Eq` of that type. The derived `Eq` defines two - * arrays as equal if all elements of both arrays are compared equal pairwise with the given `E`. In case of arrays of - * different lengths, the result is non equality. + * Less strict version of [`prepend`](#prepend). + * + * @since 2.11.0 + */ +exports.prependW = RNEA.prependW; +/** + * Append an element to the end of a `ReadonlyArray`, creating a new `ReadonlyNonEmptyArray`. * * @example - * import { eqString } from 'fp-ts/Eq' - * import { getEq } from 'fp-ts/ReadonlyArray' + * import { append } from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' * - * const E = getEq(eqString) - * assert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true) - * assert.strictEqual(E.equals(['a'], []), false) + * assert.deepStrictEqual(pipe([1, 2, 3], append(4)), [1, 2, 3, 4]) * - * @category instances - * @since 2.5.0 + * @since 2.10.0 */ -function getEq(E) { - return { - equals: function (xs, ys) { return xs === ys || (xs.length === ys.length && xs.every(function (x, i) { return E.equals(x, ys[i]); })); } - }; -} -exports.getEq = getEq; +exports.append = RNEA.append; /** - * Derives an `Ord` over the `ReadonlyArray` of a given element type from the `Ord` of that type. The ordering between two such - * arrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in - * case of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have - * the same length, the result is equality. + * Less strict version of [`append`](#append). * - * @example - * import { getOrd } from 'fp-ts/ReadonlyArray' - * import { ordString } from 'fp-ts/Ord' - * - * const O = getOrd(ordString) - * assert.strictEqual(O.compare(['b'], ['a']), 1) - * assert.strictEqual(O.compare(['a'], ['a']), 0) - * assert.strictEqual(O.compare(['a'], ['b']), -1) - * - * - * @category instances - * @since 2.5.0 + * @since 2.11.0 */ -function getOrd(O) { - return Ord_1.fromCompare(function (a, b) { - var aLen = a.length; - var bLen = b.length; - var len = Math.min(aLen, bLen); - for (var i = 0; i < len; i++) { - var ordering = O.compare(a[i], b[i]); - if (ordering !== 0) { - return ordering; - } - } - return Ord_1.ordNumber.compare(aLen, bLen); - }); -} -exports.getOrd = getOrd; +exports.appendW = RNEA.appendW; /** - * Return a list of length `n` with element `i` initialized with `f(i)` + * Return a `ReadonlyArray` of length `n` with element `i` initialized with `f(i)`. + * + * **Note**. `n` is normalized to a non negative integer. * * @example * import { makeBy } from 'fp-ts/ReadonlyArray' @@ -11615,32 +15449,12 @@ exports.getOrd = getOrd; * @category constructors * @since 2.5.0 */ -function makeBy(n, f) { - // tslint:disable-next-line: readonly-array - var r = []; - for (var i = 0; i < n; i++) { - r.push(f(i)); - } - return r; -} +var makeBy = function (n, f) { return (n <= 0 ? exports.empty : RNEA.makeBy(f)(n)); }; exports.makeBy = makeBy; /** - * Create an array containing a range of integers, including both endpoints + * Create a `ReadonlyArray` containing a value repeated the specified number of times. * - * @example - * import { range } from 'fp-ts/ReadonlyArray' - * - * assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5]) - * - * @category constructors - * @since 2.5.0 - */ -function range(start, end) { - return makeBy(end - start + 1, function (i) { return start + i; }); -} -exports.range = range; -/** - * Create an array containing a value repeated the specified number of times + * **Note**. `n` is normalized to a non negative integer. * * @example * import { replicate } from 'fp-ts/ReadonlyArray' @@ -11650,90 +15464,147 @@ exports.range = range; * @category constructors * @since 2.5.0 */ -function replicate(n, a) { - return makeBy(n, function () { return a; }); -} +var replicate = function (n, a) { return (0, exports.makeBy)(n, function () { return a; }); }; exports.replicate = replicate; +function fromPredicate(predicate) { + return function (a) { return (predicate(a) ? [a] : exports.empty); }; +} +exports.fromPredicate = fromPredicate; +// ------------------------------------------------------------------------------------- +// conversions +// ------------------------------------------------------------------------------------- +/** + * @category conversions + * @since 2.11.0 + */ +var fromOption = function (ma) { return (_.isNone(ma) ? exports.empty : [ma.value]); }; +exports.fromOption = fromOption; /** - * Removes one level of nesting + * Transforms an `Either` to a `ReadonlyArray`. * - * Derivable from `Monad`. + * @category conversions + * @since 2.11.0 + */ +var fromEither = function (e) { return (_.isLeft(e) ? exports.empty : [e.right]); }; +exports.fromEither = fromEither; +/** + * Less strict version of [`match`](#match). * - * @example - * import { flatten } from 'fp-ts/ReadonlyArray' + * The `W` suffix (short for **W**idening) means that the handler return types will be merged. * - * assert.deepStrictEqual(flatten([[1], [2], [3]]), [1, 2, 3]) + * @category pattern matching + * @since 2.11.0 + */ +var matchW = function (onEmpty, onNonEmpty) { + return function (as) { + return (0, exports.isNonEmpty)(as) ? onNonEmpty(as) : onEmpty(); + }; +}; +exports.matchW = matchW; +/** + * @category pattern matching + * @since 2.11.0 + */ +exports.match = exports.matchW; +/** + * Less strict version of [`matchLeft`](#matchleft). * - * @category combinators - * @since 2.5.0 + * @category pattern matching + * @since 2.11.0 */ -function flatten(mma) { - var rLen = 0; - var len = mma.length; - for (var i = 0; i < len; i++) { - rLen += mma[i].length; - } - var r = Array(rLen); - var start = 0; - for (var i = 0; i < len; i++) { - var arr = mma[i]; - var l = arr.length; - for (var j = 0; j < l; j++) { - r[j + start] = arr[j]; - } - start += l; - } - return r; -} -exports.flatten = flatten; +var matchLeftW = function (onEmpty, onNonEmpty) { + return function (as) { + return (0, exports.isNonEmpty)(as) ? onNonEmpty(RNEA.head(as), RNEA.tail(as)) : onEmpty(); + }; +}; +exports.matchLeftW = matchLeftW; /** - * Break an array into its first element and remaining elements + * Break a `ReadonlyArray` into its first element and remaining elements. * * @example - * import { foldLeft } from 'fp-ts/ReadonlyArray' + * import { matchLeft } from 'fp-ts/ReadonlyArray' * - * const len: (as: ReadonlyArray) => number = foldLeft(() => 0, (_, tail) => 1 + len(tail)) + * const len: (as: ReadonlyArray) => number = matchLeft(() => 0, (_, tail) => 1 + len(tail)) * assert.strictEqual(len([1, 2, 3]), 3) * - * @category destructors + * @category pattern matching + * @since 2.10.0 + */ +exports.matchLeft = exports.matchLeftW; +/** + * Alias of [`matchLeft`](#matchleft). + * + * @category pattern matching * @since 2.5.0 */ -function foldLeft(onEmpty, onCons) { - return function (as) { return (isEmpty(as) ? onEmpty() : onCons(as[0], as.slice(1))); }; -} -exports.foldLeft = foldLeft; +exports.foldLeft = exports.matchLeft; +/** + * Less strict version of [`matchRight`](#matchright). + * + * @category pattern matching + * @since 2.11.0 + */ +var matchRightW = function (onEmpty, onNonEmpty) { + return function (as) { + return (0, exports.isNonEmpty)(as) ? onNonEmpty(RNEA.init(as), RNEA.last(as)) : onEmpty(); + }; +}; +exports.matchRightW = matchRightW; +/** + * Break a `ReadonlyArray` into its initial elements and the last element. + * + * @category pattern matching + * @since 2.10.0 + */ +exports.matchRight = exports.matchRightW; /** - * Break an array into its initial elements and the last element + * Alias of [`matchRight`](#matchright). * - * @category destructors + * @category pattern matching * @since 2.5.0 */ -function foldRight(onEmpty, onCons) { - return function (as) { return (isEmpty(as) ? onEmpty() : onCons(as.slice(0, as.length - 1), as[as.length - 1])); }; -} -exports.foldRight = foldRight; +exports.foldRight = exports.matchRight; +// ------------------------------------------------------------------------------------- +// combinators +// ------------------------------------------------------------------------------------- /** - * Same as `reduce` but it carries over the intermediate steps + * @category sequencing + * @since 2.7.0 + */ +var chainWithIndex = function (f) { + return function (as) { + if ((0, exports.isEmpty)(as)) { + return exports.empty; + } + var out = []; + for (var i = 0; i < as.length; i++) { + out.push.apply(out, f(i, as[i])); + } + return out; + }; +}; +exports.chainWithIndex = chainWithIndex; +/** + * Same as `reduce` but it carries over the intermediate steps. * * @example * import { scanLeft } from 'fp-ts/ReadonlyArray' * * assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4]) * - * @category combinators * @since 2.5.0 */ -function scanLeft(b, f) { +var scanLeft = function (b, f) { return function (as) { - var l = as.length; - var r = new Array(l + 1); - r[0] = b; - for (var i = 0; i < l; i++) { - r[i + 1] = f(r[i], as[i]); + var len = as.length; + var out = new Array(len + 1); + out[0] = b; + for (var i = 0; i < len; i++) { + out[i + 1] = f(out[i], as[i]); } - return r; + return out; }; -} +}; exports.scanLeft = scanLeft; /** * Fold an array from the right, keeping all intermediate results instead of only the final result @@ -11743,93 +15614,37 @@ exports.scanLeft = scanLeft; * * assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10]) * - * @category combinators * @since 2.5.0 */ -function scanRight(b, f) { +var scanRight = function (b, f) { return function (as) { - var l = as.length; - var r = new Array(l + 1); - r[l] = b; - for (var i = l - 1; i >= 0; i--) { - r[i] = f(as[i], r[i + 1]); + var len = as.length; + var out = new Array(len + 1); + out[len] = b; + for (var i = len - 1; i >= 0; i--) { + out[i] = f(as[i], out[i + 1]); } - return r; + return out; }; -} +}; exports.scanRight = scanRight; /** - * Test whether an array is empty + * Calculate the number of elements in a `ReadonlyArray`. * - * @example - * import { isEmpty } from 'fp-ts/ReadonlyArray' - * - * assert.strictEqual(isEmpty([]), true) - * - * @since 2.5.0 - */ -function isEmpty(as) { - return as.length === 0; -} -exports.isEmpty = isEmpty; -/** - * Test whether an array is non empty narrowing down the type to `NonEmptyReadonlyArray` - * - * @category guards - * @since 2.5.0 + * @since 2.10.0 */ -function isNonEmpty(as) { - return as.length > 0; -} -exports.isNonEmpty = isNonEmpty; +var size = function (as) { return as.length; }; +exports.size = size; /** * Test whether an array contains a particular index * * @since 2.5.0 */ -function isOutOfBound(i, as) { - return i < 0 || i >= as.length; -} -exports.isOutOfBound = isOutOfBound; +exports.isOutOfBound = RNEA.isOutOfBound; function lookup(i, as) { - return as === undefined ? function (as) { return lookup(i, as); } : isOutOfBound(i, as) ? O.none : O.some(as[i]); + return as === undefined ? function (as) { return lookup(i, as); } : (0, exports.isOutOfBound)(i, as) ? _.none : _.some(as[i]); } exports.lookup = lookup; -function cons(head, tail) { - if (tail === undefined) { - return function (tail) { return cons(head, tail); }; - } - var len = tail.length; - var r = Array(len + 1); - for (var i = 0; i < len; i++) { - r[i + 1] = tail[i]; - } - r[0] = head; - return r; -} -exports.cons = cons; -// TODO: curry and make data-last in v3 -/** - * Append an element to the end of an array, creating a new non empty array - * - * @example - * import { snoc } from 'fp-ts/ReadonlyArray' - * - * assert.deepStrictEqual(snoc([1, 2, 3], 4), [1, 2, 3, 4]) - * - * @category constructors - * @since 2.5.0 - */ -function snoc(init, end) { - var len = init.length; - var r = Array(len + 1); - for (var i = 0; i < len; i++) { - r[i] = init[i]; - } - r[len] = end; - return r; -} -exports.snoc = snoc; /** * Get the first element in an array, or `None` if the array is empty * @@ -11842,9 +15657,7 @@ exports.snoc = snoc; * * @since 2.5.0 */ -function head(as) { - return isEmpty(as) ? O.none : O.some(as[0]); -} +var head = function (as) { return ((0, exports.isNonEmpty)(as) ? _.some(RNEA.head(as)) : _.none); }; exports.head = head; /** * Get the last element in an array, or `None` if the array is empty @@ -11858,9 +15671,7 @@ exports.head = head; * * @since 2.5.0 */ -function last(as) { - return lookup(as.length - 1, as); -} +var last = function (as) { return ((0, exports.isNonEmpty)(as) ? _.some(RNEA.last(as)) : _.none); }; exports.last = last; /** * Get all but the first element of an array, creating a new array, or `None` if the array is empty @@ -11874,9 +15685,9 @@ exports.last = last; * * @since 2.5.0 */ -function tail(as) { - return isEmpty(as) ? O.none : O.some(as.slice(1)); -} +var tail = function (as) { + return (0, exports.isNonEmpty)(as) ? _.some(RNEA.tail(as)) : _.none; +}; exports.tail = tail; /** * Get all but the last element of an array, creating a new array, or `None` if the array is empty @@ -11890,54 +15701,74 @@ exports.tail = tail; * * @since 2.5.0 */ -function init(as) { - var len = as.length; - return len === 0 ? O.none : O.some(as.slice(0, len - 1)); -} +var init = function (as) { + return (0, exports.isNonEmpty)(as) ? _.some(RNEA.init(as)) : _.none; +}; exports.init = init; /** - * Keep only a number of elements from the start of an array, creating a new array. - * `n` must be a natural number + * Keep only a max number of elements from the start of an `ReadonlyArray`, creating a new `ReadonlyArray`. + * + * **Note**. `n` is normalized to a non negative integer. * * @example - * import { takeLeft } from 'fp-ts/ReadonlyArray' + * import * as RA from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(takeLeft(2)([1, 2, 3]), [1, 2]) + * const input: ReadonlyArray = [1, 2, 3] + * assert.deepStrictEqual(pipe(input, RA.takeLeft(2)), [1, 2]) + * + * // out of bounds + * assert.strictEqual(pipe(input, RA.takeLeft(4)), input) + * assert.strictEqual(pipe(input, RA.takeLeft(-1)), input) * - * @category combinators * @since 2.5.0 */ -function takeLeft(n) { - return function (as) { return as.slice(0, n); }; -} +var takeLeft = function (n) { + return function (as) { + return (0, exports.isOutOfBound)(n, as) ? as : n === 0 ? exports.empty : as.slice(0, n); + }; +}; exports.takeLeft = takeLeft; /** - * Keep only a number of elements from the end of an array, creating a new array. - * `n` must be a natural number + * Keep only a max number of elements from the end of an `ReadonlyArray`, creating a new `ReadonlyArray`. + * + * **Note**. `n` is normalized to a non negative integer. * * @example - * import { takeRight } from 'fp-ts/ReadonlyArray' + * import * as RA from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(takeRight(2)([1, 2, 3, 4, 5]), [4, 5]) + * const input: ReadonlyArray = [1, 2, 3] + * assert.deepStrictEqual(pipe(input, RA.takeRight(2)), [2, 3]) + * + * // out of bounds + * assert.strictEqual(pipe(input, RA.takeRight(4)), input) + * assert.strictEqual(pipe(input, RA.takeRight(-1)), input) * * @since 2.5.0 */ -function takeRight(n) { - return function (as) { return (n === 0 ? exports.empty : as.slice(-n)); }; -} +var takeRight = function (n) { + return function (as) { + return (0, exports.isOutOfBound)(n, as) ? as : n === 0 ? exports.empty : as.slice(-n); + }; +}; exports.takeRight = takeRight; function takeLeftWhile(predicate) { return function (as) { - var i = spanIndexUncurry(as, predicate); - var init = Array(i); - for (var j = 0; j < i; j++) { - init[j] = as[j]; + var out = []; + for (var _i = 0, as_1 = as; _i < as_1.length; _i++) { + var a = as_1[_i]; + if (!predicate(a)) { + break; + } + out.push(a); } - return init; + var len = out.length; + return len === as.length ? as : len === 0 ? exports.empty : out; }; } exports.takeLeftWhile = takeLeftWhile; -var spanIndexUncurry = function (as, predicate) { +var spanLeftIndex = function (as, predicate) { var l = as.length; var i = 0; for (; i < l; i++) { @@ -11949,70 +15780,59 @@ var spanIndexUncurry = function (as, predicate) { }; function spanLeft(predicate) { return function (as) { - var i = spanIndexUncurry(as, predicate); - var init = Array(i); - for (var j = 0; j < i; j++) { - init[j] = as[j]; - } - var l = as.length; - var rest = Array(l - i); - for (var j = i; j < l; j++) { - rest[j - i] = as[j]; - } + var _a = (0, exports.splitAt)(spanLeftIndex(as, predicate))(as), init = _a[0], rest = _a[1]; return { init: init, rest: rest }; }; } exports.spanLeft = spanLeft; /** - * Drop a number of elements from the start of an array, creating a new array + * Drop a max number of elements from the start of an `ReadonlyArray`, creating a new `ReadonlyArray`. + * + * **Note**. `n` is normalized to a non negative integer. * * @example - * import { dropLeft } from 'fp-ts/ReadonlyArray' + * import * as RA from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(dropLeft(2)([1, 2, 3]), [3]) + * const input: ReadonlyArray = [1, 2, 3] + * assert.deepStrictEqual(pipe(input, RA.dropLeft(2)), [3]) + * assert.strictEqual(pipe(input, RA.dropLeft(0)), input) + * assert.strictEqual(pipe(input, RA.dropLeft(-1)), input) * - * @category combinators * @since 2.5.0 */ -function dropLeft(n) { - return function (as) { return as.slice(n, as.length); }; -} +var dropLeft = function (n) { + return function (as) { + return n <= 0 || (0, exports.isEmpty)(as) ? as : n >= as.length ? exports.empty : as.slice(n, as.length); + }; +}; exports.dropLeft = dropLeft; /** - * Drop a number of elements from the end of an array, creating a new array - * - * @example - * import { dropRight } from 'fp-ts/ReadonlyArray' + * Drop a max number of elements from the end of an `ReadonlyArray`, creating a new `ReadonlyArray`. * - * assert.deepStrictEqual(dropRight(2)([1, 2, 3, 4, 5]), [1, 2, 3]) - * - * @category combinators - * @since 2.5.0 - */ -function dropRight(n) { - return function (as) { return as.slice(0, as.length - n); }; -} -exports.dropRight = dropRight; -/** - * Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new array + * **Note**. `n` is normalized to a non negative integer. * * @example - * import { dropLeftWhile } from 'fp-ts/ReadonlyArray' + * import * as RA from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5]) + * const input: ReadonlyArray = [1, 2, 3] + * assert.deepStrictEqual(pipe(input, RA.dropRight(2)), [1]) + * assert.strictEqual(pipe(input, RA.dropRight(0)), input) + * assert.strictEqual(pipe(input, RA.dropRight(-1)), input) * - * @category combinators * @since 2.5.0 */ +var dropRight = function (n) { + return function (as) { + return n <= 0 || (0, exports.isEmpty)(as) ? as : n >= as.length ? exports.empty : as.slice(0, as.length - n); + }; +}; +exports.dropRight = dropRight; function dropLeftWhile(predicate) { return function (as) { - var i = spanIndexUncurry(as, predicate); - var l = as.length; - var rest = Array(l - i); - for (var j = i; j < l; j++) { - rest[j - i] = as[j]; - } - return rest; + var i = spanLeftIndex(as, predicate); + return i === 0 ? as : i === as.length ? exports.empty : as.slice(i); }; } exports.dropLeftWhile = dropLeftWhile; @@ -12028,27 +15848,25 @@ exports.dropLeftWhile = dropLeftWhile; * * @since 2.5.0 */ -function findIndex(predicate) { +var findIndex = function (predicate) { return function (as) { - var len = as.length; - for (var i = 0; i < len; i++) { + for (var i = 0; i < as.length; i++) { if (predicate(as[i])) { - return O.some(i); + return _.some(i); } } - return O.none; + return _.none; }; -} +}; exports.findIndex = findIndex; function findFirst(predicate) { return function (as) { - var len = as.length; - for (var i = 0; i < len; i++) { + for (var i = 0; i < as.length; i++) { if (predicate(as[i])) { - return O.some(as[i]); + return _.some(as[i]); } } - return O.none; + return _.none; }; } exports.findFirst = findFirst; @@ -12060,8 +15878,8 @@ exports.findFirst = findFirst; * import { some, none } from 'fp-ts/Option' * * interface Person { - * name: string - * age?: number + * readonly name: string + * readonly age?: number * } * * const persons: ReadonlyArray = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }] @@ -12071,28 +15889,26 @@ exports.findFirst = findFirst; * * @since 2.5.0 */ -function findFirstMap(f) { +var findFirstMap = function (f) { return function (as) { - var len = as.length; - for (var i = 0; i < len; i++) { - var v = f(as[i]); - if (O.isSome(v)) { - return v; + for (var i = 0; i < as.length; i++) { + var out = f(as[i]); + if (_.isSome(out)) { + return out; } } - return O.none; + return _.none; }; -} +}; exports.findFirstMap = findFirstMap; function findLast(predicate) { return function (as) { - var len = as.length; - for (var i = len - 1; i >= 0; i--) { + for (var i = as.length - 1; i >= 0; i--) { if (predicate(as[i])) { - return O.some(as[i]); + return _.some(as[i]); } } - return O.none; + return _.none; }; } exports.findLast = findLast; @@ -12104,8 +15920,8 @@ exports.findLast = findLast; * import { some, none } from 'fp-ts/Option' * * interface Person { - * name: string - * age?: number + * readonly name: string + * readonly age?: number * } * * const persons: ReadonlyArray = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }] @@ -12115,18 +15931,17 @@ exports.findLast = findLast; * * @since 2.5.0 */ -function findLastMap(f) { +var findLastMap = function (f) { return function (as) { - var len = as.length; - for (var i = len - 1; i >= 0; i--) { - var v = f(as[i]); - if (O.isSome(v)) { - return v; + for (var i = as.length - 1; i >= 0; i--) { + var out = f(as[i]); + if (_.isSome(out)) { + return out; } } - return O.none; + return _.none; }; -} +}; exports.findLastMap = findLastMap; /** * Returns the index of the last element of the list which matches the predicate @@ -12136,27 +15951,26 @@ exports.findLastMap = findLastMap; * import { some, none } from 'fp-ts/Option' * * interface X { - * a: number - * b: number + * readonly a: number + * readonly b: number * } * const xs: ReadonlyArray = [{ a: 1, b: 0 }, { a: 1, b: 1 }] - * assert.deepStrictEqual(findLastIndex((x: { a: number }) => x.a === 1)(xs), some(1)) - * assert.deepStrictEqual(findLastIndex((x: { a: number }) => x.a === 4)(xs), none) + * assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 1)(xs), some(1)) + * assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 4)(xs), none) * * * @since 2.5.0 */ -function findLastIndex(predicate) { +var findLastIndex = function (predicate) { return function (as) { - var len = as.length; - for (var i = len - 1; i >= 0; i--) { + for (var i = as.length - 1; i >= 0; i--) { if (predicate(as[i])) { - return O.some(i); + return _.some(i); } } - return O.none; + return _.none; }; -} +}; exports.findLastIndex = findLastIndex; /** * Insert an element at the specified index, creating a new array, or returning `None` if the index is out of bounds @@ -12169,9 +15983,11 @@ exports.findLastIndex = findLastIndex; * * @since 2.5.0 */ -function insertAt(i, a) { - return function (as) { return (i < 0 || i > as.length ? O.none : O.some(unsafeInsertAt(i, a, as))); }; -} +var insertAt = function (i, a) { + return function (as) { + return i < 0 || i > as.length ? _.none : _.some(RNEA.unsafeInsertAt(i, a, as)); + }; +}; exports.insertAt = insertAt; /** * Change the element at the specified index, creating a new array, or returning `None` if the index is out of bounds @@ -12185,9 +16001,9 @@ exports.insertAt = insertAt; * * @since 2.5.0 */ -function updateAt(i, a) { - return function (as) { return (isOutOfBound(i, as) ? O.none : O.some(unsafeUpdateAt(i, a, as))); }; -} +var updateAt = function (i, a) { + return (0, exports.modifyAt)(i, function () { return a; }); +}; exports.updateAt = updateAt; /** * Delete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds @@ -12201,9 +16017,11 @@ exports.updateAt = updateAt; * * @since 2.5.0 */ -function deleteAt(i) { - return function (as) { return (isOutOfBound(i, as) ? O.none : O.some(unsafeDeleteAt(i, as))); }; -} +var deleteAt = function (i) { + return function (as) { + return (0, exports.isOutOfBound)(i, as) ? _.none : _.some((0, exports.unsafeDeleteAt)(i, as)); + }; +}; exports.deleteAt = deleteAt; /** * Apply a function to the element at the specified index, creating a new array, or returning `None` if the index is out @@ -12219,9 +16037,11 @@ exports.deleteAt = deleteAt; * * @since 2.5.0 */ -function modifyAt(i, f) { - return function (as) { return (isOutOfBound(i, as) ? O.none : O.some(unsafeUpdateAt(i, f(as[i]), as))); }; -} +var modifyAt = function (i, f) { + return function (as) { + return (0, exports.isOutOfBound)(i, as) ? _.none : _.some((0, exports.unsafeUpdateAt)(i, f(as[i]), as)); + }; +}; exports.modifyAt = modifyAt; /** * Reverse an array, creating a new array @@ -12231,15 +16051,9 @@ exports.modifyAt = modifyAt; * * assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1]) * - * @category combinators * @since 2.5.0 */ -function reverse(as) { - if (isEmpty(as)) { - return as; - } - return as.slice().reverse(); -} +var reverse = function (as) { return (as.length <= 1 ? as : as.slice().reverse()); }; exports.reverse = reverse; /** * Extracts from an array of `Either` all the `Right` elements. All the `Right` elements are extracted in order @@ -12250,21 +16064,18 @@ exports.reverse = reverse; * * assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2]) * - * @category combinators * @since 2.5.0 */ -function rights(as) { - // tslint:disable-next-line: readonly-array +var rights = function (as) { var r = []; - var len = as.length; - for (var i = 0; i < len; i++) { + for (var i = 0; i < as.length; i++) { var a = as[i]; if (a._tag === 'Right') { r.push(a.right); } } return r; -} +}; exports.rights = rights; /** * Extracts from an array of `Either` all the `Left` elements. All the `Left` elements are extracted in order @@ -12277,34 +16088,33 @@ exports.rights = rights; * * @since 2.5.0 */ -function lefts(as) { - // tslint:disable-next-line: readonly-array +var lefts = function (as) { var r = []; - var len = as.length; - for (var i = 0; i < len; i++) { + for (var i = 0; i < as.length; i++) { var a = as[i]; if (a._tag === 'Left') { r.push(a.left); } } return r; -} +}; exports.lefts = lefts; /** * Sort the elements of an array in increasing order, creating a new array * * @example * import { sort } from 'fp-ts/ReadonlyArray' - * import { ordNumber } from 'fp-ts/Ord' + * import * as N from 'fp-ts/number' * - * assert.deepStrictEqual(sort(ordNumber)([3, 2, 1]), [1, 2, 3]) + * assert.deepStrictEqual(sort(N.Ord)([3, 2, 1]), [1, 2, 3]) * - * @category combinators * @since 2.5.0 */ -var sort = function (O) { return function (as) { - return as.length <= 1 ? as : as.slice().sort(O.compare); -}; }; +var sort = function (O) { + return function (as) { + return as.length <= 1 ? as : as.slice().sort(O.compare); + }; +}; exports.sort = sort; // TODO: curry and make data-last in v3 /** @@ -12316,24 +16126,22 @@ exports.sort = sort; * * assert.deepStrictEqual(zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n), ['a1', 'b2', 'c3']) * - * @category combinators * @since 2.5.0 */ -function zipWith(fa, fb, f) { - // tslint:disable-next-line: readonly-array +var zipWith = function (fa, fb, f) { var fc = []; var len = Math.min(fa.length, fb.length); for (var i = 0; i < len; i++) { fc[i] = f(fa[i], fb[i]); } return fc; -} +}; exports.zipWith = zipWith; function zip(as, bs) { if (bs === undefined) { return function (bs) { return zip(bs, as); }; } - return zipWith(as, bs, function (a, b) { return [a, b]; }); + return (0, exports.zipWith)(as, bs, function (a, b) { return [a, b]; }); } exports.zip = zip; /** @@ -12346,39 +16154,31 @@ exports.zip = zip; * * @since 2.5.0 */ -function unzip(as) { - // tslint:disable-next-line: readonly-array +var unzip = function (as) { var fa = []; - // tslint:disable-next-line: readonly-array var fb = []; for (var i = 0; i < as.length; i++) { fa[i] = as[i][0]; fb[i] = as[i][1]; } return [fa, fb]; -} +}; exports.unzip = unzip; /** * Prepend an element to every member of an array * * @example - * import { prependToAll } from 'fp-ts/ReadonlyArray' + * import { prependAll } from 'fp-ts/ReadonlyArray' * - * assert.deepStrictEqual(prependToAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4]) + * assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4]) * - * @category combinators - * @since 2.9.0 + * @since 2.10.0 */ -var prependToAll = function (e) { return function (xs) { - // tslint:disable-next-line: readonly-array - var ys = []; - for (var _i = 0, xs_1 = xs; _i < xs_1.length; _i++) { - var x = xs_1[_i]; - ys.push(e, x); - } - return ys; -}; }; -exports.prependToAll = prependToAll; +var prependAll = function (middle) { + var f = RNEA.prependAll(middle); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : as); }; +}; +exports.prependAll = prependAll; /** * Places an element in between members of an array * @@ -12387,44 +16187,27 @@ exports.prependToAll = prependToAll; * * assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4]) * - * @category combinators * @since 2.9.0 */ -function intersperse(e) { - return function (as) { - var length = as.length; - if (length === 0) { - return as; - } - return cons(as[0], exports.prependToAll(e)(as.slice(1, as.length))); - }; -} +var intersperse = function (middle) { + var f = RNEA.intersperse(middle); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : as); }; +}; exports.intersperse = intersperse; /** - * Rotate an array to the right by `n` steps + * Rotate a `ReadonlyArray` by `n` steps. * * @example * import { rotate } from 'fp-ts/ReadonlyArray' * * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3]) * - * @category combinators * @since 2.5.0 */ -function rotate(n) { - return function (as) { - var len = as.length; - if (n === 0 || len <= 1 || len === Math.abs(n)) { - return as; - } - else if (n < 0) { - return rotate(len + n)(as); - } - else { - return as.slice(-n).concat(as.slice(0, len - n)); - } - }; -} +var rotate = function (n) { + var f = RNEA.rotate(n); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : as); }; +}; exports.rotate = rotate; function elem(E) { return function (a, as) { @@ -12434,8 +16217,7 @@ function elem(E) { } var predicate = function (element) { return E.equals(element, a); }; var i = 0; - var len = as.length; - for (; i < len; i++) { + for (; i < as.length; i++) { if (predicate(as[i])) { return true; } @@ -12449,32 +16231,16 @@ exports.elem = elem; * * @example * import { uniq } from 'fp-ts/ReadonlyArray' - * import { eqNumber } from 'fp-ts/Eq' + * import * as N from 'fp-ts/number' * - * assert.deepStrictEqual(uniq(eqNumber)([1, 2, 1]), [1, 2]) + * assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2]) * - * @category combinators * @since 2.5.0 */ -function uniq(E) { - var elemS = elem(E); - return function (as) { - var len = as.length; - if (len <= 1) { - return as; - } - // tslint:disable-next-line: readonly-array - var r = []; - var i = 0; - for (; i < len; i++) { - var a = as[i]; - if (!elemS(a, r)) { - r.push(a); - } - } - return len === r.length ? as : r; - }; -} +var uniq = function (E) { + var f = RNEA.uniq(E); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : as); }; +}; exports.uniq = uniq; /** * Sort the elements of an array in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`, @@ -12482,14 +16248,17 @@ exports.uniq = uniq; * * @example * import { sortBy } from 'fp-ts/ReadonlyArray' - * import { ord, ordString, ordNumber } from 'fp-ts/Ord' + * import { contramap } from 'fp-ts/Ord' + * import * as S from 'fp-ts/string' + * import * as N from 'fp-ts/number' + * import { pipe } from 'fp-ts/function' * * interface Person { - * name: string - * age: number + * readonly name: string + * readonly age: number * } - * const byName = ord.contramap(ordString, (p: Person) => p.name) - * const byAge = ord.contramap(ordNumber, (p: Person) => p.age) + * const byName = pipe(S.Ord, contramap((p: Person) => p.name)) + * const byAge = pipe(N.Ord, contramap((p: Person) => p.age)) * * const sortByNameByAge = sortBy([byName, byAge]) * @@ -12501,48 +16270,41 @@ exports.uniq = uniq; * { name: 'c', age: 2 } * ]) * - * @category combinators * @since 2.5.0 */ -function sortBy(ords) { - var M = Ord_1.getMonoid(); - return exports.sort(ords.reduce(M.concat, M.empty)); -} +var sortBy = function (ords) { + var f = RNEA.sortBy(ords); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : as); }; +}; exports.sortBy = sortBy; /** - * A useful recursion pattern for processing an array to produce a new array, often used for "chopping" up the input - * array. Typically chop is called with some function that will consume an initial prefix of the array and produce a - * value and the rest of the array. + * A useful recursion pattern for processing a `ReadonlyArray` to produce a new `ReadonlyArray`, often used for "chopping" up the input + * `ReadonlyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `ReadonlyArray` and produce a + * value and the tail of the `ReadonlyArray`. * * @example - * import { Eq, eqNumber } from 'fp-ts/Eq' - * import { chop, spanLeft } from 'fp-ts/ReadonlyArray' + * import { Eq } from 'fp-ts/Eq' + * import * as RA from 'fp-ts/ReadonlyArray' + * import * as N from 'fp-ts/number' + * import { pipe } from 'fp-ts/function' * * const group = (S: Eq): ((as: ReadonlyArray) => ReadonlyArray>) => { - * return chop(as => { - * const { init, rest } = spanLeft((a: A) => S.equals(a, as[0]))(as) + * return RA.chop(as => { + * const { init, rest } = pipe(as, RA.spanLeft((a: A) => S.equals(a, as[0]))) * return [init, rest] * }) * } - * assert.deepStrictEqual(group(eqNumber)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]]) + * assert.deepStrictEqual(group(N.Eq)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]]) * - * @category combinators * @since 2.5.0 */ -var chop = function (f) { return function (as) { - // tslint:disable-next-line: readonly-array - var result = []; - var cs = as; - while (isNonEmpty(cs)) { - var _a = f(cs), b = _a[0], c = _a[1]; - result.push(b); - cs = c; - } - return result; -}; }; +var chop = function (f) { + var g = RNEA.chop(f); + return function (as) { return ((0, exports.isNonEmpty)(as) ? g(as) : exports.empty); }; +}; exports.chop = chop; /** - * Splits an array into two pieces, the first piece has `n` elements. + * Splits a `ReadonlyArray` into two pieces, the first piece has max `n` elements. * * @example * import { splitAt } from 'fp-ts/ReadonlyArray' @@ -12551,55 +16313,81 @@ exports.chop = chop; * * @since 2.5.0 */ -function splitAt(n) { - return function (as) { return [as.slice(0, n), as.slice(n)]; }; -} +var splitAt = function (n) { + return function (as) { + return n >= 1 && (0, exports.isNonEmpty)(as) ? RNEA.splitAt(n)(as) : (0, exports.isEmpty)(as) ? [as, exports.empty] : [exports.empty, as]; + }; +}; exports.splitAt = splitAt; /** - * Splits an array into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of - * the array. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive - * definition of `chunksOf`; it satisfies the property that + * Splits a `ReadonlyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of + * the `ReadonlyArray`. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive + * definition of `chunksOf`; it satisfies the property that: * * ```ts * chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys))) * ``` * - * whenever `n` evenly divides the length of `xs`. + * whenever `n` evenly divides the length of `as`. * * @example * import { chunksOf } from 'fp-ts/ReadonlyArray' * * assert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]]) * - * * @since 2.5.0 */ -function chunksOf(n) { - var f = exports.chop(splitAt(n)); - return function (as) { return (as.length === 0 ? exports.empty : isOutOfBound(n - 1, as) ? [as] : f(as)); }; -} +var chunksOf = function (n) { + var f = RNEA.chunksOf(n); + return function (as) { return ((0, exports.isNonEmpty)(as) ? f(as) : exports.empty); }; +}; exports.chunksOf = chunksOf; +/** + * @category lifting + * @since 2.11.0 + */ +var fromOptionK = function (f) { + return function () { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } + return (0, exports.fromOption)(f.apply(void 0, a)); + }; +}; +exports.fromOptionK = fromOptionK; function comprehension(input, f, g) { if (g === void 0) { g = function () { return true; }; } var go = function (scope, input) { - if (input.length === 0) { - return g.apply(void 0, scope) ? [f.apply(void 0, scope)] : exports.empty; - } - else { - return chain_(input[0], function (x) { return go(snoc(scope, x), input.slice(1)); }); - } + return (0, exports.isNonEmpty)(input) + ? (0, exports.flatMap)(RNEA.head(input), function (a) { return go((0, function_1.pipe)(scope, (0, exports.append)(a)), RNEA.tail(input)); }) + : g.apply(void 0, scope) ? [f.apply(void 0, scope)] + : exports.empty; }; return go(exports.empty, input); } exports.comprehension = comprehension; +/** + * @since 2.11.0 + */ +var concatW = function (second) { + return function (first) { + return (0, exports.isEmpty)(first) ? second : (0, exports.isEmpty)(second) ? first : first.concat(second); + }; +}; +exports.concatW = concatW; +/** + * @since 2.11.0 + */ +exports.concat = exports.concatW; function union(E) { - var elemE = elem(E); - return function (xs, ys) { - if (ys === undefined) { + var unionE = RNEA.union(E); + return function (first, second) { + if (second === undefined) { var unionE_1 = union(E); - return function (ys) { return unionE_1(ys, xs); }; + return function (second) { return unionE_1(second, first); }; } - return concat(xs, ys.filter(function (a) { return !elemE(a, xs); })); + return (0, exports.isNonEmpty)(first) && (0, exports.isNonEmpty)(second) ? unionE(second)(first) : (0, exports.isNonEmpty)(first) ? first : second; }; } exports.union = union; @@ -12625,189 +16413,157 @@ function difference(E) { }; } exports.difference = difference; -/** - * Wrap a value into the type constructor. - * - * @category Applicative - * @since 2.5.0 - */ -var of = function (a) { return [a]; }; -exports.of = of; -/** - * @category Alternative - * @since 2.7.0 - */ -var zero = function () { return exports.empty; }; -exports.zero = zero; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -var map_ = function (fa, f) { return function_1.pipe(fa, exports.map(f)); }; -var mapWithIndex_ = function (fa, f) { return function_1.pipe(fa, exports.mapWithIndex(f)); }; -var ap_ = function (fab, fa) { return function_1.pipe(fab, exports.ap(fa)); }; -var chain_ = function (ma, f) { - return function_1.pipe(ma, exports.chain(f)); -}; -var filter_ = function (fa, predicate) { return function_1.pipe(fa, exports.filter(predicate)); }; -var filterMap_ = function (fa, f) { return function_1.pipe(fa, exports.filterMap(f)); }; -var partitionWithIndex_ = function (fa, predicateWithIndex) { return function_1.pipe(fa, exports.partitionWithIndex(predicateWithIndex)); }; -var partition_ = function (fa, predicate) { return function_1.pipe(fa, exports.partition(predicate)); }; -var partitionMap_ = function (fa, f) { return function_1.pipe(fa, exports.partitionMap(f)); }; -var partitionMapWithIndex_ = function (fa, f) { return function_1.pipe(fa, exports.partitionMapWithIndex(f)); }; -var alt_ = function (fa, that) { return function_1.pipe(fa, exports.alt(that)); }; -var reduce_ = function (fa, b, f) { return function_1.pipe(fa, exports.reduce(b, f)); }; -var foldMap_ = function (M) { - var foldMapM = exports.foldMap(M); - return function (fa, f) { return function_1.pipe(fa, foldMapM(f)); }; -}; -var reduceRight_ = function (fa, b, f) { return function_1.pipe(fa, exports.reduceRight(b, f)); }; -var reduceWithIndex_ = function (fa, b, f) { - var l = fa.length; - var r = b; - for (var i = 0; i < l; i++) { - r = f(i, r, fa[i]); - } - return r; +var _map = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }; +var _mapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.mapWithIndex)(f)); }; +var _ap = function (fab, fa) { return (0, function_1.pipe)(fab, (0, exports.ap)(fa)); }; +var _filter = function (fa, predicate) { + return (0, function_1.pipe)(fa, (0, exports.filter)(predicate)); }; -var foldMapWithIndex_ = function (M) { return function (fa, f) { - return fa.reduce(function (b, a, i) { return M.concat(b, f(i, a)); }, M.empty); -}; }; -var reduceRightWithIndex_ = function (fa, b, f) { - return function_1.pipe(fa, exports.reduceRightWithIndex(b, f)); +var _filterMap = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.filterMap)(f)); }; +var _partition = function (fa, predicate) { + return (0, function_1.pipe)(fa, (0, exports.partition)(predicate)); }; -var filterMapWithIndex_ = function (fa, f) { - return function_1.pipe(fa, exports.filterMapWithIndex(f)); +var _partitionMap = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.partitionMap)(f)); }; +var _partitionWithIndex = function (fa, predicateWithIndex) { return (0, function_1.pipe)(fa, (0, exports.partitionWithIndex)(predicateWithIndex)); }; +var _partitionMapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.partitionMapWithIndex)(f)); }; +var _alt = function (fa, that) { return (0, function_1.pipe)(fa, (0, exports.alt)(that)); }; +var _reduce = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduce)(b, f)); }; +var _foldMap = function (M) { + var foldMapM = (0, exports.foldMap)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapM(f)); }; }; -var filterWithIndex_ = function (fa, predicateWithIndex) { return function_1.pipe(fa, exports.filterWithIndex(predicateWithIndex)); }; -var extend_ = function (fa, f) { return function_1.pipe(fa, exports.extend(f)); }; -var traverse_ = function (F) { - var traverseF = exports.traverse(F); - return function (ta, f) { return function_1.pipe(ta, traverseF(f)); }; +var _reduceRight = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduceRight)(b, f)); }; +var _reduceWithIndex = function (fa, b, f) { + return (0, function_1.pipe)(fa, (0, exports.reduceWithIndex)(b, f)); }; -/* istanbul ignore next */ -var traverseWithIndex_ = function (F) { - var traverseWithIndexF = exports.traverseWithIndex(F); - return function (ta, f) { return function_1.pipe(ta, traverseWithIndexF(f)); }; +var _foldMapWithIndex = function (M) { + var foldMapWithIndexM = (0, exports.foldMapWithIndex)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapWithIndexM(f)); }; }; -/* istanbul ignore next */ -var wither_ = function (F) { - var witherF = exports.wither(F); - return function (fa, f) { return function_1.pipe(fa, witherF(f)); }; +var _reduceRightWithIndex = function (fa, b, f) { + return (0, function_1.pipe)(fa, (0, exports.reduceRightWithIndex)(b, f)); +}; +var _filterMapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.filterMapWithIndex)(f)); }; +var _filterWithIndex = function (fa, predicateWithIndex) { return (0, function_1.pipe)(fa, (0, exports.filterWithIndex)(predicateWithIndex)); }; +var _extend = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.extend)(f)); }; +var _traverse = function (F) { + var traverseF = (0, exports.traverse)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseF(f)); }; }; /* istanbul ignore next */ -var wilt_ = function (F) { - var wiltF = exports.wilt(F); - return function (fa, f) { return function_1.pipe(fa, wiltF(f)); }; +var _traverseWithIndex = function (F) { + var traverseWithIndexF = (0, exports.traverseWithIndex)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseWithIndexF(f)); }; }; -// ------------------------------------------------------------------------------------- -// pipeables -// ------------------------------------------------------------------------------------- +/** @internal */ +var _chainRecDepthFirst = function (a, f) { return (0, function_1.pipe)(a, (0, exports.chainRecDepthFirst)(f)); }; +exports._chainRecDepthFirst = _chainRecDepthFirst; +/** @internal */ +var _chainRecBreadthFirst = function (a, f) { return (0, function_1.pipe)(a, (0, exports.chainRecBreadthFirst)(f)); }; +exports._chainRecBreadthFirst = _chainRecBreadthFirst; +/** + * @category constructors + * @since 2.5.0 + */ +exports.of = RNEA.of; +/** + * @since 2.7.0 + */ +var zero = function () { return exports.empty; }; +exports.zero = zero; /** * Less strict version of [`alt`](#alt). * - * @category Alt + * The `W` suffix (short for **W**idening) means that the return types will be merged. + * + * @example + * import * as RA from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * RA.altW(() => ['a', 'b']) + * ), + * [1, 2, 3, 'a', 'b'] + * ) + * + * @category error handling * @since 2.9.0 */ -var altW = function (that) { return function (fa) { return concat(fa, that()); }; }; +var altW = function (that) { + return function (fa) { + return fa.concat(that()); + }; +}; exports.altW = altW; /** * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to * types of kind `* -> *`. * - * @category Alt + * In case of `ReadonlyArray` concatenates the inputs into a single array. + * + * @example + * import * as RA from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * RA.alt(() => [4, 5]) + * ), + * [1, 2, 3, 4, 5] + * ) + * + * @category error handling * @since 2.5.0 */ exports.alt = exports.altW; /** - * Apply a function to an argument under a type constructor. - * - * @category Apply * @since 2.5.0 */ var ap = function (fa) { - return exports.chain(function (f) { return function_1.pipe(fa, exports.map(f)); }); + return (0, exports.flatMap)(function (f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }); }; exports.ap = ap; /** - * Combine two effectful actions, keeping only the result of the first. - * - * Derivable from `Apply`. - * - * @category combinators - * @since 2.5.0 - */ -var apFirst = function (fb) { - return function_1.flow(exports.map(function (a) { return function () { return a; }; }), exports.ap(fb)); -}; -exports.apFirst = apFirst; -/** - * Combine two effectful actions, keeping only the result of the second. + * Composes computations in sequence, using the return value of one computation to determine the next computation. * - * Derivable from `Apply`. + * @example + * import * as RA from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' * - * @category combinators - * @since 2.5.0 - */ -var apSecond = function (fb) { - return function_1.flow(exports.map(function () { return function (b) { return b; }; }), exports.ap(fb)); -}; -exports.apSecond = apSecond; -/** - * Composes computations in sequence, using the return value of one computation to determine the next computation. + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * RA.flatMap((n) => [`a${n}`, `b${n}`]) + * ), + * ['a1', 'b1', 'a2', 'b2', 'a3', 'b3'] + * ) + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * RA.flatMap(() => []) + * ), + * [] + * ) * - * @category Monad - * @since 2.5.0 - */ -var chain = function (f) { return function (ma) { - return function_1.pipe(ma, exports.chainWithIndex(function (_, a) { return f(a); })); -}; }; -exports.chain = chain; -/** - * @since 2.7.0 + * @category sequencing + * @since 2.14.0 */ -var chainWithIndex = function (f) { return function (ma) { - var outLen = 0; - var l = ma.length; - var temp = new Array(l); - for (var i = 0; i < l; i++) { - var e = ma[i]; - var arr = f(i, e); - outLen += arr.length; - temp[i] = arr; - } - var out = Array(outLen); - var start = 0; - for (var i = 0; i < l; i++) { - var arr = temp[i]; - var l_1 = arr.length; - for (var j = 0; j < l_1; j++) { - out[j + start] = arr[j]; - } - start += l_1; - } - return out; -}; }; -exports.chainWithIndex = chainWithIndex; +exports.flatMap = (0, function_1.dual)(2, function (ma, f) { + return (0, function_1.pipe)(ma, (0, exports.chainWithIndex)(function (i, a) { return f(a, i); })); +}); /** - * Composes computations in sequence, using the return value of one computation to determine the next computation and - * keeping only the result of the first. - * - * Derivable from `Monad`. - * - * @category combinators + * @category sequencing * @since 2.5.0 */ -var chainFirst = function (f) { - return exports.chain(function (a) { - return function_1.pipe(f(a), exports.map(function () { return a; })); - }); -}; -exports.chainFirst = chainFirst; +exports.flatten = (0, exports.flatMap)(function_1.identity); /** * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types * use the type constructor `F` to represent some computational context. * - * @category Functor + * @category mapping * @since 2.5.0 */ var map = function (f) { return function (fa) { @@ -12815,19 +16571,19 @@ var map = function (f) { return function (fa) { }; }; exports.map = map; /** - * @category FunctorWithIndex + * @category mapping * @since 2.5.0 */ -var mapWithIndex = function (f) { return function (fa) { return fa.map(function (a, i) { return f(i, a); }); }; }; +var mapWithIndex = function (f) { return function (fa) { + return fa.map(function (a, i) { return f(i, a); }); +}; }; exports.mapWithIndex = mapWithIndex; /** - * @category Compactable + * @category filtering * @since 2.5.0 */ var separate = function (fa) { - // tslint:disable-next-line: readonly-array var left = []; - // tslint:disable-next-line: readonly-array var right = []; for (var _i = 0, fa_1 = fa; _i < fa_1.length; _i++) { var e = fa_1[_i]; @@ -12838,269 +16594,412 @@ var separate = function (fa) { right.push(e.right); } } - return { - left: left, - right: right - }; + return (0, Separated_1.separated)(left, right); }; exports.separate = separate; /** - * @category Filterable + * @category filtering * @since 2.5.0 */ -var filter = function (predicate) { return function (fa) { return fa.filter(predicate); }; }; +var filter = function (predicate) { + return function (as) { + return as.filter(predicate); + }; +}; exports.filter = filter; /** - * @category FilterableWithIndex + * @category filtering * @since 2.5.0 */ -var filterMapWithIndex = function (f) { return function (fa) { - // tslint:disable-next-line: readonly-array - var result = []; - for (var i = 0; i < fa.length; i++) { - var optionB = f(i, fa[i]); - if (O.isSome(optionB)) { - result.push(optionB.value); +var filterMapWithIndex = function (f) { + return function (fa) { + var out = []; + for (var i = 0; i < fa.length; i++) { + var optionB = f(i, fa[i]); + if (_.isSome(optionB)) { + out.push(optionB.value); + } } - } - return result; -}; }; + return out; + }; +}; exports.filterMapWithIndex = filterMapWithIndex; /** - * @category Filterable + * @category filtering * @since 2.5.0 */ var filterMap = function (f) { - return exports.filterMapWithIndex(function (_, a) { return f(a); }); + return (0, exports.filterMapWithIndex)(function (_, a) { return f(a); }); }; exports.filterMap = filterMap; /** - * @category Compactable + * @category filtering * @since 2.5.0 */ -exports.compact = -/*#__PURE__*/ -exports.filterMap(function_1.identity); +exports.compact = (0, exports.filterMap)(function_1.identity); /** - * @category Filterable + * @category filtering * @since 2.5.0 */ var partition = function (predicate) { - return exports.partitionWithIndex(function (_, a) { return predicate(a); }); + return (0, exports.partitionWithIndex)(function (_, a) { return predicate(a); }); }; exports.partition = partition; /** - * @category FilterableWithIndex + * @category filtering * @since 2.5.0 */ -var partitionWithIndex = function (predicateWithIndex) { return function (fa) { - // tslint:disable-next-line: readonly-array - var left = []; - // tslint:disable-next-line: readonly-array - var right = []; - for (var i = 0; i < fa.length; i++) { - var a = fa[i]; - if (predicateWithIndex(i, a)) { - right.push(a); - } - else { - left.push(a); +var partitionWithIndex = function (predicateWithIndex) { + return function (as) { + var left = []; + var right = []; + for (var i = 0; i < as.length; i++) { + var a = as[i]; + if (predicateWithIndex(i, a)) { + right.push(a); + } + else { + left.push(a); + } } - } - return { - left: left, - right: right + return (0, Separated_1.separated)(left, right); }; -}; }; +}; exports.partitionWithIndex = partitionWithIndex; /** - * @category Filterable + * @category filtering * @since 2.5.0 */ var partitionMap = function (f) { - return exports.partitionMapWithIndex(function (_, a) { return f(a); }); + return (0, exports.partitionMapWithIndex)(function (_, a) { return f(a); }); }; exports.partitionMap = partitionMap; /** - * @category FilterableWithIndex + * @category filtering * @since 2.5.0 */ -var partitionMapWithIndex = function (f) { return function (fa) { - // tslint:disable-next-line: readonly-array - var left = []; - // tslint:disable-next-line: readonly-array - var right = []; - for (var i = 0; i < fa.length; i++) { - var e = f(i, fa[i]); - if (e._tag === 'Left') { - left.push(e.left); - } - else { - right.push(e.right); +var partitionMapWithIndex = function (f) { + return function (fa) { + var left = []; + var right = []; + for (var i = 0; i < fa.length; i++) { + var e = f(i, fa[i]); + if (e._tag === 'Left') { + left.push(e.left); + } + else { + right.push(e.right); + } } - } - return { - left: left, - right: right + return (0, Separated_1.separated)(left, right); }; -}; }; +}; exports.partitionMapWithIndex = partitionMapWithIndex; /** - * @category FilterableWithIndex + * @category filtering * @since 2.5.0 */ -var filterWithIndex = function (predicateWithIndex) { return function (fa) { - return fa.filter(function (a, i) { return predicateWithIndex(i, a); }); -}; }; +var filterWithIndex = function (predicateWithIndex) { + return function (as) { + return as.filter(function (a, i) { return predicateWithIndex(i, a); }); + }; +}; exports.filterWithIndex = filterWithIndex; /** - * @category Extend * @since 2.5.0 */ -var extend = function (f) { return function (wa) { return wa.map(function (_, i, as) { return f(as.slice(i)); }); }; }; +var extend = function (f) { return function (wa) { + return wa.map(function (_, i) { return f(wa.slice(i)); }); +}; }; exports.extend = extend; /** - * Derivable from `Extend`. - * - * @category combinators * @since 2.5.0 */ -exports.duplicate = -/*#__PURE__*/ -exports.extend(function_1.identity); +exports.duplicate = (0, exports.extend)(function_1.identity); /** - * @category FoldableWithIndex + * @category folding * @since 2.5.0 */ var foldMapWithIndex = function (M) { - var foldMapWithIndexM = foldMapWithIndex_(M); - return function (f) { return function (fa) { return foldMapWithIndexM(fa, f); }; }; + return function (f) { + return function (fa) { + return fa.reduce(function (b, a, i) { return M.concat(b, f(i, a)); }, M.empty); + }; + }; }; exports.foldMapWithIndex = foldMapWithIndex; /** - * @category Foldable + * @category folding * @since 2.5.0 */ var reduce = function (b, f) { - return exports.reduceWithIndex(b, function (_, b, a) { return f(b, a); }); + return (0, exports.reduceWithIndex)(b, function (_, b, a) { return f(b, a); }); }; exports.reduce = reduce; /** - * @category Foldable + * @category folding * @since 2.5.0 */ var foldMap = function (M) { - var foldMapWithIndexM = exports.foldMapWithIndex(M); + var foldMapWithIndexM = (0, exports.foldMapWithIndex)(M); return function (f) { return foldMapWithIndexM(function (_, a) { return f(a); }); }; }; exports.foldMap = foldMap; /** - * @category FoldableWithIndex + * @category folding * @since 2.5.0 */ -var reduceWithIndex = function (b, f) { return function (fa) { return reduceWithIndex_(fa, b, f); }; }; +var reduceWithIndex = function (b, f) { return function (fa) { + var len = fa.length; + var out = b; + for (var i = 0; i < len; i++) { + out = f(i, out, fa[i]); + } + return out; +}; }; exports.reduceWithIndex = reduceWithIndex; /** - * @category Foldable + * @category folding * @since 2.5.0 */ var reduceRight = function (b, f) { - return exports.reduceRightWithIndex(b, function (_, a, b) { return f(a, b); }); + return (0, exports.reduceRightWithIndex)(b, function (_, a, b) { return f(a, b); }); }; exports.reduceRight = reduceRight; /** - * @category FoldableWithIndex + * @category folding * @since 2.5.0 */ -var reduceRightWithIndex = function (b, f) { return function (fa) { return fa.reduceRight(function (b, a, i) { return f(i, a, b); }, b); }; }; +var reduceRightWithIndex = function (b, f) { return function (fa) { + return fa.reduceRight(function (b, a, i) { return f(i, a, b); }, b); +}; }; exports.reduceRightWithIndex = reduceRightWithIndex; /** - * **for optimized and stack safe version check the data types `traverseArray` function** - * @category Traversable + * @category traversing * @since 2.6.3 */ var traverse = function (F) { - var traverseWithIndexF = exports.traverseWithIndex(F); + var traverseWithIndexF = (0, exports.traverseWithIndex)(F); return function (f) { return traverseWithIndexF(function (_, a) { return f(a); }); }; }; exports.traverse = traverse; /** - * **for optimized and stack safe version check the data types `sequenceArray` function** - * @category Traversable + * @category traversing * @since 2.6.3 */ -var sequence = function (F) { return function (ta) { - return reduce_(ta, F.of(exports.zero()), function (fas, fa) { - return F.ap(F.map(fas, function (as) { return function (a) { return snoc(as, a); }; }), fa); - }); -}; }; +var sequence = function (F) { + return function (ta) { + return _reduce(ta, F.of((0, exports.zero)()), function (fas, fa) { + return F.ap(F.map(fas, function (as) { return function (a) { return (0, function_1.pipe)(as, (0, exports.append)(a)); }; }), fa); + }); + }; +}; exports.sequence = sequence; /** - * **for optimized and stack safe version check the data types `traverseArrayWithIndex` function** - * @category TraversableWithIndex + * @category sequencing * @since 2.6.3 */ -var traverseWithIndex = function (F) { return function (f) { - return exports.reduceWithIndex(F.of(exports.zero()), function (i, fbs, a) { - return F.ap(F.map(fbs, function (bs) { return function (b) { return snoc(bs, b); }; }), f(i, a)); - }); -}; }; +var traverseWithIndex = function (F) { + return function (f) { + return (0, exports.reduceWithIndex)(F.of((0, exports.zero)()), function (i, fbs, a) { + return F.ap(F.map(fbs, function (bs) { return function (b) { return (0, function_1.pipe)(bs, (0, exports.append)(b)); }; }), f(i, a)); + }); + }; +}; exports.traverseWithIndex = traverseWithIndex; /** - * @category Witherable + * @category filtering * @since 2.6.5 */ var wither = function (F) { - var traverseF = exports.traverse(F); - return function (f) { return function (fa) { return F.map(function_1.pipe(fa, traverseF(f)), exports.compact); }; }; + var _witherF = _wither(F); + return function (f) { return function (fa) { return _witherF(fa, f); }; }; }; exports.wither = wither; /** - * @category Witherable + * @category filtering * @since 2.6.5 */ var wilt = function (F) { - var traverseF = exports.traverse(F); - return function (f) { return function (fa) { return F.map(function_1.pipe(fa, traverseF(f)), exports.separate); }; }; + var _wiltF = _wilt(F); + return function (f) { return function (fa) { return _wiltF(fa, f); }; }; }; exports.wilt = wilt; /** - * @category Unfoldable * @since 2.6.6 */ var unfold = function (b, f) { - // tslint:disable-next-line: readonly-array - var ret = []; + var out = []; var bb = b; + // eslint-disable-next-line no-constant-condition while (true) { var mt = f(bb); - if (O.isSome(mt)) { + if (_.isSome(mt)) { var _a = mt.value, a = _a[0], b_1 = _a[1]; - ret.push(a); + out.push(a); bb = b_1; } else { break; } } - return ret; + return out; }; exports.unfold = unfold; -// ------------------------------------------------------------------------------------- -// instances -// ------------------------------------------------------------------------------------- /** - * @category instances + * @category type lambdas * @since 2.5.0 */ exports.URI = 'ReadonlyArray'; +/** + * @category instances + * @since 2.5.0 + */ +var getShow = function (S) { return ({ + show: function (as) { return "[".concat(as.map(S.show).join(', '), "]"); } +}); }; +exports.getShow = getShow; +/** + * @category instances + * @since 2.5.0 + */ +var getSemigroup = function () { return ({ + concat: function (first, second) { return ((0, exports.isEmpty)(first) ? second : (0, exports.isEmpty)(second) ? first : first.concat(second)); } +}); }; +exports.getSemigroup = getSemigroup; +/** + * Returns a `Monoid` for `ReadonlyArray`. + * + * @example + * import { getMonoid } from 'fp-ts/ReadonlyArray' + * + * const M = getMonoid() + * assert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4]) + * + * @category instances + * @since 2.5.0 + */ +var getMonoid = function () { return ({ + concat: (0, exports.getSemigroup)().concat, + empty: exports.empty +}); }; +exports.getMonoid = getMonoid; +/** + * Derives an `Eq` over the `ReadonlyArray` of a given element type from the `Eq` of that type. The derived `Eq` defines two + * arrays as equal if all elements of both arrays are compared equal pairwise with the given `E`. In case of arrays of + * different lengths, the result is non equality. + * + * @example + * import * as S from 'fp-ts/string' + * import { getEq } from 'fp-ts/ReadonlyArray' + * + * const E = getEq(S.Eq) + * assert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true) + * assert.strictEqual(E.equals(['a'], []), false) + * + * @category instances + * @since 2.5.0 + */ +var getEq = function (E) { + return (0, Eq_1.fromEquals)(function (xs, ys) { return xs.length === ys.length && xs.every(function (x, i) { return E.equals(x, ys[i]); }); }); +}; +exports.getEq = getEq; +/** + * Derives an `Ord` over the `ReadonlyArray` of a given element type from the `Ord` of that type. The ordering between two such + * arrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in + * case of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have + * the same length, the result is equality. + * + * @example + * import { getOrd } from 'fp-ts/ReadonlyArray' + * import * as S from 'fp-ts/string' + * + * const O = getOrd(S.Ord) + * assert.strictEqual(O.compare(['b'], ['a']), 1) + * assert.strictEqual(O.compare(['a'], ['a']), 0) + * assert.strictEqual(O.compare(['a'], ['b']), -1) + * + * + * @category instances + * @since 2.5.0 + */ +var getOrd = function (O) { + return (0, Ord_1.fromCompare)(function (a, b) { + var aLen = a.length; + var bLen = b.length; + var len = Math.min(aLen, bLen); + for (var i = 0; i < len; i++) { + var ordering = O.compare(a[i], b[i]); + if (ordering !== 0) { + return ordering; + } + } + return N.Ord.compare(aLen, bLen); + }); +}; +exports.getOrd = getOrd; +/** + * @category instances + * @since 2.11.0 + */ +var getUnionSemigroup = function (E) { + var unionE = union(E); + return { + concat: function (first, second) { return unionE(second)(first); } + }; +}; +exports.getUnionSemigroup = getUnionSemigroup; +/** + * @category instances + * @since 2.11.0 + */ +var getUnionMonoid = function (E) { return ({ + concat: (0, exports.getUnionSemigroup)(E).concat, + empty: exports.empty +}); }; +exports.getUnionMonoid = getUnionMonoid; +/** + * @category instances + * @since 2.11.0 + */ +var getIntersectionSemigroup = function (E) { + var intersectionE = intersection(E); + return { + concat: function (first, second) { return intersectionE(second)(first); } + }; +}; +exports.getIntersectionSemigroup = getIntersectionSemigroup; +/** + * @category instances + * @since 2.11.0 + */ +var getDifferenceMagma = function (E) { + var differenceE = difference(E); + return { + concat: function (first, second) { return differenceE(second)(first); } + }; +}; +exports.getDifferenceMagma = getDifferenceMagma; /** * @category instances * @since 2.7.0 */ exports.Functor = { URI: exports.URI, - map: map_ + map: _map +}; +/** + * @category mapping + * @since 2.10.0 + */ +exports.flap = (0, Functor_1.flap)(exports.Functor); +/** + * @category instances + * @since 2.10.0 + */ +exports.Pointed = { + URI: exports.URI, + of: exports.of }; /** * @category instances @@ -13108,30 +17007,89 @@ exports.Functor = { */ exports.FunctorWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_ + map: _map, + mapWithIndex: _mapWithIndex }; +/** + * @category instances + * @since 2.10.0 + */ +exports.Apply = { + URI: exports.URI, + map: _map, + ap: _ap +}; +/** + * Combine two effectful actions, keeping only the result of the first. + * + * @since 2.5.0 + */ +exports.apFirst = (0, Apply_1.apFirst)(exports.Apply); +/** + * Combine two effectful actions, keeping only the result of the second. + * + * @since 2.5.0 + */ +exports.apSecond = (0, Apply_1.apSecond)(exports.Apply); /** * @category instances * @since 2.7.0 */ exports.Applicative = { URI: exports.URI, - map: map_, - ap: ap_, + map: _map, + ap: _ap, of: exports.of }; +/** + * @category instances + * @since 2.10.0 + */ +exports.Chain = { + URI: exports.URI, + map: _map, + ap: _ap, + chain: exports.flatMap +}; /** * @category instances * @since 2.7.0 */ exports.Monad = { URI: exports.URI, - map: map_, - ap: ap_, + map: _map, + ap: _ap, of: exports.of, - chain: chain_ + chain: exports.flatMap }; +/** + * Composes computations in sequence, using the return value of one computation to determine the next computation and + * keeping only the result of the first. + * + * @example + * import * as RA from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * RA.chainFirst(() => ['a', 'b']) + * ), + * [1, 1, 2, 2, 3, 3] + * ) + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * RA.chainFirst(() => []) + * ), + * [] + * ) + * + * @category sequencing + * @since 2.5.0 + */ +exports.chainFirst = +/*#__PURE__*/ (0, Chain_1.chainFirst)(exports.Chain); /** * @category instances * @since 2.7.0 @@ -13146,19 +17104,32 @@ exports.Unfoldable = { */ exports.Alt = { URI: exports.URI, - map: map_, - alt: alt_ + map: _map, + alt: _alt +}; +/** + * @category instances + * @since 2.11.0 + */ +exports.Zero = { + URI: exports.URI, + zero: exports.zero }; +/** + * @category do notation + * @since 2.11.0 + */ +exports.guard = (0, Zero_1.guard)(exports.Zero, exports.Pointed); /** * @category instances * @since 2.7.0 */ exports.Alternative = { URI: exports.URI, - map: map_, - ap: ap_, + map: _map, + ap: _ap, of: exports.of, - alt: alt_, + alt: _alt, zero: exports.zero }; /** @@ -13167,8 +17138,8 @@ exports.Alternative = { */ exports.Extend = { URI: exports.URI, - map: map_, - extend: extend_ + map: _map, + extend: _extend }; /** * @category instances @@ -13185,13 +17156,13 @@ exports.Compactable = { */ exports.Filterable = { URI: exports.URI, - map: map_, + map: _map, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_ + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap }; /** * @category instances @@ -13199,18 +17170,18 @@ exports.Filterable = { */ exports.FilterableWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, + map: _map, + mapWithIndex: _mapWithIndex, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - partitionMapWithIndex: partitionMapWithIndex_, - partitionWithIndex: partitionWithIndex_, - filterMapWithIndex: filterMapWithIndex_, - filterWithIndex: filterWithIndex_ + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + partitionMapWithIndex: _partitionMapWithIndex, + partitionWithIndex: _partitionWithIndex, + filterMapWithIndex: _filterMapWithIndex, + filterWithIndex: _filterWithIndex }; /** * @category instances @@ -13218,9 +17189,9 @@ exports.FilterableWithIndex = { */ exports.Foldable = { URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_ + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight }; /** * @category instances @@ -13228,12 +17199,12 @@ exports.Foldable = { */ exports.FoldableWithIndex = { URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_ + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex }; /** * @category instances @@ -13241,11 +17212,11 @@ exports.FoldableWithIndex = { */ exports.Traversable = { URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: _map, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, sequence: exports.sequence }; /** @@ -13254,77 +17225,148 @@ exports.Traversable = { */ exports.TraversableWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverse: traverse_, + map: _map, + mapWithIndex: _mapWithIndex, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex, + traverse: _traverse, sequence: exports.sequence, - traverseWithIndex: traverseWithIndex_ + traverseWithIndex: _traverseWithIndex +}; +/** + * @category sequencing + * @since 2.11.0 + */ +var chainRecDepthFirst = function (f) { + return function (a) { + var todo = __spreadArray([], f(a), true); + var out = []; + while (todo.length > 0) { + var e = todo.shift(); + if (_.isLeft(e)) { + todo.unshift.apply(todo, f(e.left)); + } + else { + out.push(e.right); + } + } + return out; + }; +}; +exports.chainRecDepthFirst = chainRecDepthFirst; +/** + * @category instances + * @since 2.11.0 + */ +exports.ChainRecDepthFirst = { + URI: exports.URI, + map: _map, + ap: _ap, + chain: exports.flatMap, + chainRec: exports._chainRecDepthFirst +}; +/** + * @category sequencing + * @since 2.11.0 + */ +var chainRecBreadthFirst = function (f) { + return function (a) { + var initial = f(a); + var todo = []; + var out = []; + function go(e) { + if (_.isLeft(e)) { + f(e.left).forEach(function (v) { return todo.push(v); }); + } + else { + out.push(e.right); + } + } + for (var _i = 0, initial_1 = initial; _i < initial_1.length; _i++) { + var e = initial_1[_i]; + go(e); + } + while (todo.length > 0) { + go(todo.shift()); + } + return out; + }; +}; +exports.chainRecBreadthFirst = chainRecBreadthFirst; +/** + * @category instances + * @since 2.11.0 + */ +exports.ChainRecBreadthFirst = { + URI: exports.URI, + map: _map, + ap: _ap, + chain: exports.flatMap, + chainRec: exports._chainRecBreadthFirst }; +var _wither = /*#__PURE__*/ (0, Witherable_1.witherDefault)(exports.Traversable, exports.Compactable); +var _wilt = /*#__PURE__*/ (0, Witherable_1.wiltDefault)(exports.Traversable, exports.Compactable); /** * @category instances * @since 2.7.0 */ exports.Witherable = { URI: exports.URI, - map: map_, + map: _map, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, sequence: exports.sequence, - wither: wither_, - wilt: wilt_ + wither: _wither, + wilt: _wilt }; -// TODO: remove in v3 +/** + * Filter values inside a context. + * + * @example + * import { pipe } from 'fp-ts/function' + * import * as RA from 'fp-ts/ReadonlyArray' + * import * as T from 'fp-ts/Task' + * + * const filterE = RA.filterE(T.ApplicativePar) + * async function test() { + * assert.deepStrictEqual( + * await pipe( + * [-1, 2, 3], + * filterE((n) => T.of(n > 0)) + * )(), + * [2, 3] + * ) + * } + * test() + * + * @since 2.11.0 + */ +exports.filterE = (0, Witherable_1.filterE)(exports.Witherable); /** * @category instances - * @since 2.5.0 + * @since 2.11.0 */ -exports.readonlyArray = { +exports.FromEither = { URI: exports.URI, - compact: exports.compact, - separate: exports.separate, - map: map_, - ap: ap_, - of: exports.of, - chain: chain_, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - mapWithIndex: mapWithIndex_, - partitionMapWithIndex: partitionMapWithIndex_, - partitionWithIndex: partitionWithIndex_, - filterMapWithIndex: filterMapWithIndex_, - filterWithIndex: filterWithIndex_, - alt: alt_, - zero: exports.zero, - unfold: exports.unfold, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: exports.sequence, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverseWithIndex: traverseWithIndex_, - extend: extend_, - wither: wither_, - wilt: wilt_ + fromEither: exports.fromEither }; +/** + * @category lifting + * @since 2.11.0 + */ +exports.fromEitherK = (0, FromEither_1.fromEitherK)(exports.FromEither); // ------------------------------------------------------------------------------------- // unsafe // ------------------------------------------------------------------------------------- @@ -13332,37 +17374,37 @@ exports.readonlyArray = { * @category unsafe * @since 2.5.0 */ -function unsafeInsertAt(i, a, as) { - var xs = as.slice(); - xs.splice(i, 0, a); - return xs; -} -exports.unsafeInsertAt = unsafeInsertAt; +exports.unsafeInsertAt = RNEA.unsafeInsertAt; /** * @category unsafe * @since 2.5.0 */ -function unsafeUpdateAt(i, a, as) { - if (as[i] === a) { - return as; - } - else { - var xs = as.slice(); - xs[i] = a; - return xs; - } -} +var unsafeUpdateAt = function (i, a, as) { + return (0, exports.isNonEmpty)(as) ? RNEA.unsafeUpdateAt(i, a, as) : as; +}; exports.unsafeUpdateAt = unsafeUpdateAt; /** * @category unsafe * @since 2.5.0 */ -function unsafeDeleteAt(i, as) { +var unsafeDeleteAt = function (i, as) { var xs = as.slice(); xs.splice(i, 1); return xs; -} +}; exports.unsafeDeleteAt = unsafeDeleteAt; +/** + * @category conversions + * @since 2.5.0 + */ +var toArray = function (as) { return as.slice(); }; +exports.toArray = toArray; +/** + * @category conversions + * @since 2.5.0 + */ +var fromArray = function (as) { return ((0, exports.isEmpty)(as) ? exports.empty : as.slice()); }; +exports.fromArray = fromArray; // ------------------------------------------------------------------------------------- // utils // ------------------------------------------------------------------------------------- @@ -13371,22 +17413,10 @@ exports.unsafeDeleteAt = unsafeDeleteAt; * * @since 2.5.0 */ -exports.empty = []; -/** - * Check if a predicate holds true for every array member. - * - * @example - * import { every } from 'fp-ts/ReadonlyArray' - * import { pipe } from 'fp-ts/function' - * - * const isPositive = (n: number): boolean => n > 0 - * - * assert.deepStrictEqual(pipe([1, 2, 3], every(isPositive)), true) - * assert.deepStrictEqual(pipe([1, 2, -3], every(isPositive)), false) - * - * @since 2.9.0 - */ -var every = function (predicate) { return function (as) { return as.every(predicate); }; }; +exports.empty = RNEA.empty; +function every(predicate) { + return function (as) { return as.every(predicate); }; +} exports.every = every; /** * Check if a predicate holds true for any array member. @@ -13402,43 +17432,146 @@ exports.every = every; * * @since 2.9.0 */ -var some = function (predicate) { return function (as) { return as.some(predicate); }; }; +var some = function (predicate) { + return function (as) { + return as.some(predicate); + }; +}; exports.some = some; +/** + * Alias of [`some`](#some) + * + * @since 2.11.0 + */ +exports.exists = exports.some; +/** + * Places an element in between members of a `ReadonlyArray`, then folds the results using the provided `Monoid`. + * + * @example + * import * as S from 'fp-ts/string' + * import { intercalate } from 'fp-ts/ReadonlyArray' + * + * assert.deepStrictEqual(intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c') + * + * @since 2.12.0 + */ +var intercalate = function (M) { + var intercalateM = RNEA.intercalate(M); + return function (middle) { return (0, exports.match)(function () { return M.empty; }, intercalateM(middle)); }; +}; +exports.intercalate = intercalate; // ------------------------------------------------------------------------------------- // do notation // ------------------------------------------------------------------------------------- /** + * @category do notation * @since 2.9.0 */ -exports.Do = -/*#__PURE__*/ -exports.of({}); +exports.Do = (0, exports.of)(_.emptyRecord); /** + * @category do notation * @since 2.8.0 */ -var bindTo = function (name) { - return exports.map(function_1.bindTo_(name)); -}; -exports.bindTo = bindTo; +exports.bindTo = (0, Functor_1.bindTo)(exports.Functor); +var let_ = /*#__PURE__*/ (0, Functor_1.let)(exports.Functor); +exports["let"] = let_; /** + * @category do notation * @since 2.8.0 */ -var bind = function (name, f) { - return exports.chain(function (a) { - return function_1.pipe(f(a), exports.map(function (b) { return function_1.bind_(a, name, b); })); - }); -}; -exports.bind = bind; +exports.bind = (0, Chain_1.bind)(exports.Chain); +/** + * @category do notation + * @since 2.8.0 + */ +exports.apS = (0, Apply_1.apS)(exports.Apply); // ------------------------------------------------------------------------------------- -// pipeable sequence S +// legacy // ------------------------------------------------------------------------------------- /** - * @since 2.8.0 + * Alias of `flatMap`. + * + * @category legacy + * @since 2.5.0 + */ +exports.chain = exports.flatMap; +// ------------------------------------------------------------------------------------- +// deprecated +// ------------------------------------------------------------------------------------- +/** + * Use `ReadonlyNonEmptyArray` module instead. + * + * @category zone of death + * @since 2.5.0 + * @deprecated + */ +exports.range = RNEA.range; +/** + * Use [`prepend`](#prepend) instead. + * + * @category zone of death + * @since 2.5.0 + * @deprecated + */ +exports.cons = RNEA.cons; +/** + * Use [`append`](#append) instead. + * + * @category zone of death + * @since 2.5.0 + * @deprecated + */ +exports.snoc = RNEA.snoc; +/** + * Use [`prependAll`](#prependall) instead. + * + * @category zone of death + * @since 2.9.0 + * @deprecated + */ +exports.prependToAll = exports.prependAll; +/** + * This instance is deprecated, use small, specific instances instead. + * For example if a function needs a `Functor` instance, pass `RA.Functor` instead of `RA.readonlyArray` + * (where `RA` is from `import RA from 'fp-ts/ReadonlyArray'`) + * + * @category zone of death + * @since 2.5.0 + * @deprecated */ -var apS = function (name, fb) { - return function_1.flow(exports.map(function (a) { return function (b) { return function_1.bind_(a, name, b); }; }), exports.ap(fb)); +exports.readonlyArray = { + URI: exports.URI, + compact: exports.compact, + separate: exports.separate, + map: _map, + ap: _ap, + of: exports.of, + chain: exports.flatMap, + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + mapWithIndex: _mapWithIndex, + partitionMapWithIndex: _partitionMapWithIndex, + partitionWithIndex: _partitionWithIndex, + filterMapWithIndex: _filterMapWithIndex, + filterWithIndex: _filterWithIndex, + alt: _alt, + zero: exports.zero, + unfold: exports.unfold, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, + sequence: exports.sequence, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex, + traverseWithIndex: _traverseWithIndex, + extend: _extend, + wither: _wither, + wilt: _wilt }; -exports.apS = apS; /***/ }), @@ -13450,7 +17583,11 @@ exports.apS = apS; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -13467,509 +17604,865 @@ var __importStar = (this && this.__importStar) || function (mod) { __setModuleDefault(result, mod); return result; }; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.reduceRight = exports.reduceWithIndex = exports.reduce = exports.mapWithIndex = exports.map = exports.flatten = exports.extend = exports.duplicate = exports.chainFirst = exports.chain = exports.apSecond = exports.apFirst = exports.ap = exports.alt = exports.altW = exports.foldMap = exports.foldMapWithIndex = exports.intersperse = exports.prependToAll = exports.unzip = exports.zip = exports.zipWith = exports.fold = exports.concat = exports.of = exports.filterWithIndex = exports.filter = exports.modifyAt = exports.updateAt = exports.insertAt = exports.sort = exports.init = exports.last = exports.groupBy = exports.groupSort = exports.group = exports.getEq = exports.getSemigroup = exports.max = exports.min = exports.reverse = exports.tail = exports.head = exports.getShow = exports.unsnoc = exports.uncons = exports.fromArray = exports.fromReadonlyArray = exports.snoc = exports.cons = void 0; -exports.apS = exports.bind = exports.bindTo = exports.Do = exports.readonlyNonEmptyArray = exports.Comonad = exports.Alt = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.Monad = exports.Applicative = exports.FunctorWithIndex = exports.Functor = exports.URI = exports.extract = exports.traverseWithIndex = exports.sequence = exports.traverse = exports.reduceRightWithIndex = void 0; +exports.reduceRight = exports.foldMap = exports.reduce = exports.mapWithIndex = exports.map = exports.flatten = exports.duplicate = exports.extend = exports.flatMap = exports.ap = exports.alt = exports.altW = exports.of = exports.chunksOf = exports.splitAt = exports.chop = exports.chainWithIndex = exports.intersperse = exports.prependAll = exports.unzip = exports.zip = exports.zipWith = exports.modifyAt = exports.updateAt = exports.sort = exports.groupBy = exports.group = exports.reverse = exports.concat = exports.concatW = exports.fromArray = exports.unappend = exports.unprepend = exports.range = exports.replicate = exports.makeBy = exports.fromReadonlyArray = exports.rotate = exports.union = exports.sortBy = exports.uniq = exports.unsafeUpdateAt = exports.unsafeInsertAt = exports.append = exports.appendW = exports.prepend = exports.prependW = exports.isOutOfBound = exports.isNonEmpty = exports.empty = void 0; +exports.groupSort = exports.chain = exports.intercalate = exports.updateLast = exports.modifyLast = exports.updateHead = exports.modifyHead = exports.matchRight = exports.matchLeft = exports.concatAll = exports.max = exports.min = exports.init = exports.last = exports.tail = exports.head = exports.apS = exports.bind = exports["let"] = exports.bindTo = exports.Do = exports.Comonad = exports.Alt = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.Monad = exports.chainFirst = exports.Chain = exports.Applicative = exports.apSecond = exports.apFirst = exports.Apply = exports.FunctorWithIndex = exports.Pointed = exports.flap = exports.Functor = exports.getUnionSemigroup = exports.getEq = exports.getSemigroup = exports.getShow = exports.URI = exports.extract = exports.traverseWithIndex = exports.sequence = exports.traverse = exports.reduceRightWithIndex = exports.foldMapWithIndex = exports.reduceWithIndex = void 0; +exports.readonlyNonEmptyArray = exports.fold = exports.prependToAll = exports.insertAt = exports.snoc = exports.cons = exports.unsnoc = exports.uncons = exports.filterWithIndex = exports.filter = void 0; +var Apply_1 = __nccwpck_require__(205); +var Chain_1 = __nccwpck_require__(2372); +var Eq_1 = __nccwpck_require__(6964); var function_1 = __nccwpck_require__(6985); -var Option_1 = __nccwpck_require__(2569); -var RA = __importStar(__nccwpck_require__(4234)); -var Semigroup_1 = __nccwpck_require__(6339); +var Functor_1 = __nccwpck_require__(5533); +var _ = __importStar(__nccwpck_require__(1840)); +var Ord_1 = __nccwpck_require__(6685); +var Se = __importStar(__nccwpck_require__(6339)); +// ------------------------------------------------------------------------------------- +// internal +// ------------------------------------------------------------------------------------- +/** + * @internal + */ +exports.empty = _.emptyReadonlyArray; +/** + * @internal + */ +exports.isNonEmpty = _.isNonEmpty; +/** + * @internal + */ +var isOutOfBound = function (i, as) { return i < 0 || i >= as.length; }; +exports.isOutOfBound = isOutOfBound; +/** + * @internal + */ +var prependW = function (head) { + return function (tail) { + return __spreadArray([head], tail, true); + }; +}; +exports.prependW = prependW; +/** + * @internal + */ +exports.prepend = exports.prependW; +/** + * @internal + */ +var appendW = function (end) { + return function (init) { + return __spreadArray(__spreadArray([], init, true), [end], false); + }; +}; +exports.appendW = appendW; +/** + * @internal + */ +exports.append = exports.appendW; +/** + * @internal + */ +var unsafeInsertAt = function (i, a, as) { + if ((0, exports.isNonEmpty)(as)) { + var xs = _.fromReadonlyNonEmptyArray(as); + xs.splice(i, 0, a); + return xs; + } + return [a]; +}; +exports.unsafeInsertAt = unsafeInsertAt; +/** + * @internal + */ +var unsafeUpdateAt = function (i, a, as) { + if (as[i] === a) { + return as; + } + else { + var xs = _.fromReadonlyNonEmptyArray(as); + xs[i] = a; + return xs; + } +}; +exports.unsafeUpdateAt = unsafeUpdateAt; /** - * Append an element to the front of an array, creating a new non empty array + * Remove duplicates from a `ReadonlyNonEmptyArray`, keeping the first occurrence of an element. * * @example - * import { cons } from 'fp-ts/ReadonlyNonEmptyArray' + * import { uniq } from 'fp-ts/ReadonlyNonEmptyArray' + * import * as N from 'fp-ts/number' * - * assert.deepStrictEqual(cons(1, [2, 3, 4]), [1, 2, 3, 4]) + * assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2]) * - * @category constructors - * @since 2.5.0 + * @since 2.11.0 */ -exports.cons = RA.cons; +var uniq = function (E) { + return function (as) { + if (as.length === 1) { + return as; + } + var out = [(0, exports.head)(as)]; + var rest = (0, exports.tail)(as); + var _loop_1 = function (a) { + if (out.every(function (o) { return !E.equals(o, a); })) { + out.push(a); + } + }; + for (var _i = 0, rest_1 = rest; _i < rest_1.length; _i++) { + var a = rest_1[_i]; + _loop_1(a); + } + return out; + }; +}; +exports.uniq = uniq; /** - * Append an element to the end of an array, creating a new non empty array + * Sort the elements of a `ReadonlyNonEmptyArray` in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`, + * etc... * * @example - * import { snoc } from 'fp-ts/ReadonlyNonEmptyArray' + * import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray' + * import { contramap } from 'fp-ts/Ord' + * import * as S from 'fp-ts/string' + * import * as N from 'fp-ts/number' + * import { pipe } from 'fp-ts/function' + * + * interface Person { + * name: string + * age: number + * } * - * assert.deepStrictEqual(snoc([1, 2, 3], 4), [1, 2, 3, 4]) + * const byName = pipe(S.Ord, contramap((p: Person) => p.name)) * - * @category constructors - * @since 2.5.0 + * const byAge = pipe(N.Ord, contramap((p: Person) => p.age)) + * + * const sortByNameByAge = RNEA.sortBy([byName, byAge]) + * + * const persons: RNEA.ReadonlyNonEmptyArray = [ + * { name: 'a', age: 1 }, + * { name: 'b', age: 3 }, + * { name: 'c', age: 2 }, + * { name: 'b', age: 2 } + * ] + * + * assert.deepStrictEqual(sortByNameByAge(persons), [ + * { name: 'a', age: 1 }, + * { name: 'b', age: 2 }, + * { name: 'b', age: 3 }, + * { name: 'c', age: 2 } + * ]) + * + * @since 2.11.0 + */ +var sortBy = function (ords) { + if ((0, exports.isNonEmpty)(ords)) { + var M = (0, Ord_1.getMonoid)(); + return (0, exports.sort)(ords.reduce(M.concat, M.empty)); + } + return function_1.identity; +}; +exports.sortBy = sortBy; +/** + * @since 2.11.0 */ -exports.snoc = RA.snoc; +var union = function (E) { + var uniqE = (0, exports.uniq)(E); + return function (second) { return function (first) { return uniqE((0, function_1.pipe)(first, concat(second))); }; }; +}; +exports.union = union; /** - * Builds a `ReadonlyNonEmptyArray` from an array returning `none` if `as` is an empty array + * Rotate a `ReadonlyNonEmptyArray` by `n` steps. * - * @category constructors - * @since 2.5.0 + * @example + * import { rotate } from 'fp-ts/ReadonlyNonEmptyArray' + * + * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3]) + * assert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2]) + * + * @since 2.11.0 */ -function fromReadonlyArray(as) { - return RA.isNonEmpty(as) ? Option_1.some(as) : Option_1.none; -} -exports.fromReadonlyArray = fromReadonlyArray; +var rotate = function (n) { + return function (as) { + var len = as.length; + var m = Math.round(n) % len; + if ((0, exports.isOutOfBound)(Math.abs(m), as) || m === 0) { + return as; + } + if (m < 0) { + var _a = (0, exports.splitAt)(-m)(as), f = _a[0], s = _a[1]; + return (0, function_1.pipe)(s, concat(f)); + } + else { + return (0, exports.rotate)(m - len)(as); + } + }; +}; +exports.rotate = rotate; +// ------------------------------------------------------------------------------------- +// constructors +// ------------------------------------------------------------------------------------- /** - * @category constructors + * Return a `ReadonlyNonEmptyArray` from a `ReadonlyArray` returning `none` if the input is empty. + * + * @category conversions * @since 2.5.0 */ -// tslint:disable-next-line: readonly-array -function fromArray(as) { - return fromReadonlyArray(RA.fromArray(as)); -} -exports.fromArray = fromArray; +var fromReadonlyArray = function (as) { + return (0, exports.isNonEmpty)(as) ? _.some(as) : _.none; +}; +exports.fromReadonlyArray = fromReadonlyArray; /** - * Produces a couple of the first element of the array, and a new array of the remaining elements, if any + * Return a `ReadonlyNonEmptyArray` of length `n` with element `i` initialized with `f(i)`. + * + * **Note**. `n` is normalized to a natural number. * * @example - * import { cons, uncons } from 'fp-ts/ReadonlyNonEmptyArray' + * import { makeBy } from 'fp-ts/ReadonlyNonEmptyArray' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(uncons(cons(1, [2, 3, 4])), [1, [2, 3, 4]]) + * const double = (n: number): number => n * 2 + * assert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8]) * - * @category destructors - * @since 2.9.0 - */ -function uncons(nea) { - return [nea[0], nea.slice(1)]; -} -exports.uncons = uncons; + * @category constructors + * @since 2.11.0 + */ +var makeBy = function (f) { + return function (n) { + var j = Math.max(0, Math.floor(n)); + var out = [f(0)]; + for (var i = 1; i < j; i++) { + out.push(f(i)); + } + return out; + }; +}; +exports.makeBy = makeBy; /** - * Produces a couple of a copy of the array without its last element, and that last element + * Create a `ReadonlyNonEmptyArray` containing a value repeated the specified number of times. + * + * **Note**. `n` is normalized to a natural number. * * @example - * import { snoc, unsnoc } from 'fp-ts/ReadonlyNonEmptyArray' + * import { replicate } from 'fp-ts/ReadonlyNonEmptyArray' + * import { pipe } from 'fp-ts/function' * - * assert.deepStrictEqual(unsnoc(snoc([1, 2, 3], 4)), [[1, 2, 3], 4]) + * assert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a']) * - * @category destructors - * @since 2.9.0 - */ -function unsnoc(nea) { - var l = nea.length - 1; - return [nea.slice(0, l), nea[l]]; -} -exports.unsnoc = unsnoc; -/** - * @category instances - * @since 2.5.0 - */ -exports.getShow = RA.getShow; -/** - * @since 2.5.0 + * @category constructors + * @since 2.11.0 */ -function head(nea) { - return nea[0]; -} -exports.head = head; +var replicate = function (a) { return (0, exports.makeBy)(function () { return a; }); }; +exports.replicate = replicate; /** - * @since 2.5.0 + * Create a `ReadonlyNonEmptyArray` containing a range of integers, including both endpoints. + * + * @example + * import { range } from 'fp-ts/ReadonlyNonEmptyArray' + * + * assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5]) + * + * @category constructors + * @since 2.11.0 */ -function tail(nea) { - return nea.slice(1); -} -exports.tail = tail; +var range = function (start, end) { + return start <= end ? (0, exports.makeBy)(function (i) { return start + i; })(end - start + 1) : [start]; +}; +exports.range = range; /** - * @category combinators - * @since 2.5.0 + * Return the tuple of the `head` and the `tail`. + * + * @example + * import { unprepend } from 'fp-ts/ReadonlyNonEmptyArray' + * + * assert.deepStrictEqual(unprepend([1, 2, 3, 4]), [1, [2, 3, 4]]) + * + * @since 2.9.0 */ -exports.reverse = RA.reverse; +var unprepend = function (as) { return [(0, exports.head)(as), (0, exports.tail)(as)]; }; +exports.unprepend = unprepend; /** - * @since 2.5.0 + * Return the tuple of the `init` and the `last`. + * + * @example + * import { unappend } from 'fp-ts/ReadonlyNonEmptyArray' + * + * assert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4]) + * + * @since 2.9.0 */ -function min(ord) { - var S = Semigroup_1.getMeetSemigroup(ord); - return function (nea) { return nea.reduce(S.concat); }; -} -exports.min = min; +var unappend = function (as) { return [(0, exports.init)(as), (0, exports.last)(as)]; }; +exports.unappend = unappend; /** + * @category conversions * @since 2.5.0 */ -function max(ord) { - var S = Semigroup_1.getJoinSemigroup(ord); - return function (nea) { return nea.reduce(S.concat); }; +var fromArray = function (as) { return (0, exports.fromReadonlyArray)(as.slice()); }; +exports.fromArray = fromArray; +function concatW(second) { + return function (first) { return first.concat(second); }; } -exports.max = max; -/** - * Builds a `Semigroup` instance for `ReadonlyNonEmptyArray` - * - * @category instances - * @since 2.5.0 - */ -function getSemigroup() { - return { - concat: concat - }; +exports.concatW = concatW; +function concat(x, y) { + return y ? x.concat(y) : function (y) { return y.concat(x); }; } -exports.getSemigroup = getSemigroup; +exports.concat = concat; /** - * @example - * import { getEq, cons } from 'fp-ts/ReadonlyNonEmptyArray' - * import { eqNumber } from 'fp-ts/Eq' - * - * const E = getEq(eqNumber) - * assert.strictEqual(E.equals(cons(1, [2]), [1, 2]), true) - * assert.strictEqual(E.equals(cons(1, [2]), [1, 3]), false) - * - * @category instances * @since 2.5.0 */ -exports.getEq = RA.getEq; +var reverse = function (as) { + return as.length === 1 ? as : __spreadArray([(0, exports.last)(as)], as.slice(0, -1).reverse(), true); +}; +exports.reverse = reverse; function group(E) { return function (as) { var len = as.length; if (len === 0) { - return RA.empty; + return exports.empty; } - // tslint:disable-next-line: readonly-array - var r = []; + var out = []; var head = as[0]; var nea = [head]; for (var i = 1; i < len; i++) { - var x = as[i]; - if (E.equals(x, head)) { - nea.push(x); + var a = as[i]; + if (E.equals(a, head)) { + nea.push(a); } else { - r.push(nea); - head = x; + out.push(nea); + head = a; nea = [head]; } } - r.push(nea); - return r; + out.push(nea); + return out; }; } exports.group = group; -function groupSort(O) { - var sortO = RA.sort(O); - var groupO = group(O); - return function (as) { return groupO(sortO(as)); }; -} -exports.groupSort = groupSort; /** * Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning * function on each element, and grouping the results according to values returned * * @example - * import { cons, groupBy } from 'fp-ts/ReadonlyNonEmptyArray' + * import { groupBy } from 'fp-ts/ReadonlyNonEmptyArray' * - * assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['foo', 'bar', 'foobar']), { - * '3': cons('foo', ['bar']), - * '6': cons('foobar', []) + * assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), { + * '1': ['a', 'b'], + * '2': ['ab'] * }) * - * @category constructors * @since 2.5.0 */ -function groupBy(f) { +var groupBy = function (f) { return function (as) { - var r = {}; + var out = {}; for (var _i = 0, as_1 = as; _i < as_1.length; _i++) { var a = as_1[_i]; var k = f(a); - if (r.hasOwnProperty(k)) { - r[k].push(a); + if (_.has.call(out, k)) { + out[k].push(a); } else { - r[k] = [a]; + out[k] = [a]; } } - return r; + return out; }; -} +}; exports.groupBy = groupBy; /** * @since 2.5.0 */ -function last(nea) { - return nea[nea.length - 1]; -} -exports.last = last; -/** - * Get all but the last element of a non empty array, creating a new array. - * - * @example - * import { init } from 'fp-ts/ReadonlyNonEmptyArray' - * - * assert.deepStrictEqual(init([1, 2, 3]), [1, 2]) - * assert.deepStrictEqual(init([1]), []) - * - * @since 2.5.0 - */ -function init(nea) { - return nea.slice(0, -1); -} -exports.init = init; -/** - * @category combinators - * @since 2.5.0 - */ -function sort(O) { - return RA.sort(O); -} +var sort = function (O) { + return function (as) { + return as.length === 1 ? as : as.slice().sort(O.compare); + }; +}; exports.sort = sort; /** * @since 2.5.0 */ -function insertAt(i, a) { - return RA.insertAt(i, a); -} -exports.insertAt = insertAt; -/** - * @since 2.5.0 - */ -function updateAt(i, a) { - return RA.updateAt(i, a); -} +var updateAt = function (i, a) { + return (0, exports.modifyAt)(i, function () { return a; }); +}; exports.updateAt = updateAt; /** * @since 2.5.0 */ -function modifyAt(i, f) { - return RA.modifyAt(i, f); -} +var modifyAt = function (i, f) { + return function (as) { + return (0, exports.isOutOfBound)(i, as) ? _.none : _.some((0, exports.unsafeUpdateAt)(i, f(as[i]), as)); + }; +}; exports.modifyAt = modifyAt; -function filter(predicate) { - return filterWithIndex(function (_, a) { return predicate(a); }); -} -exports.filter = filter; -/** - * @since 2.5.0 - */ -function filterWithIndex(predicate) { - return function (nea) { return fromReadonlyArray(nea.filter(function (a, i) { return predicate(i, a); })); }; -} -exports.filterWithIndex = filterWithIndex; -/** - * Wrap a value into the type constructor. - * - * @category Applicative - * @since 2.5.0 - */ -exports.of = RA.of; -function concat(fx, fy) { - return fx.concat(fy); -} -exports.concat = concat; -/** - * @since 2.5.0 - */ -function fold(S) { - return function (fa) { return fa.reduce(S.concat); }; -} -exports.fold = fold; -/** - * @category combinators - * @since 2.5.1 - */ -exports.zipWith = RA.zipWith; /** - * @category combinators * @since 2.5.1 */ -exports.zip = RA.zip; +var zipWith = function (as, bs, f) { + var cs = [f(as[0], bs[0])]; + var len = Math.min(as.length, bs.length); + for (var i = 1; i < len; i++) { + cs[i] = f(as[i], bs[i]); + } + return cs; +}; +exports.zipWith = zipWith; +function zip(as, bs) { + if (bs === undefined) { + return function (bs) { return zip(bs, as); }; + } + return (0, exports.zipWith)(as, bs, function (a, b) { return [a, b]; }); +} +exports.zip = zip; /** * @since 2.5.1 */ -exports.unzip = RA.unzip; +var unzip = function (abs) { + var fa = [abs[0][0]]; + var fb = [abs[0][1]]; + for (var i = 1; i < abs.length; i++) { + fa[i] = abs[i][0]; + fb[i] = abs[i][1]; + } + return [fa, fb]; +}; +exports.unzip = unzip; /** - * Prepend an element to every member of an array + * Prepend an element to every member of a `ReadonlyNonEmptyArray`. * * @example - * import { cons, prependToAll } from 'fp-ts/ReadonlyNonEmptyArray' + * import { prependAll } from 'fp-ts/ReadonlyNonEmptyArray' * - * assert.deepStrictEqual(prependToAll(9)(cons(1, [2, 3, 4])), cons(9, [1, 9, 2, 9, 3, 9, 4])) + * assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4]) * - * @category combinators - * @since 2.9.0 + * @since 2.10.0 */ -exports.prependToAll = RA.prependToAll; +var prependAll = function (middle) { + return function (as) { + var out = [middle, as[0]]; + for (var i = 1; i < as.length; i++) { + out.push(middle, as[i]); + } + return out; + }; +}; +exports.prependAll = prependAll; /** - * Places an element in between members of an array + * Places an element in between members of a `ReadonlyNonEmptyArray`. * * @example - * import { cons, intersperse } from 'fp-ts/ReadonlyNonEmptyArray' + * import { intersperse } from 'fp-ts/ReadonlyNonEmptyArray' * - * assert.deepStrictEqual(intersperse(9)(cons(1, [2, 3, 4])), cons(1, [9, 2, 9, 3, 9, 4])) + * assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4]) * - * @category combinators * @since 2.9.0 */ -exports.intersperse = RA.intersperse; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -var map_ = RA.Functor.map; -var mapWithIndex_ = RA.FunctorWithIndex.mapWithIndex; -var ap_ = RA.Applicative.ap; -var chain_ = RA.Monad.chain; -var extend_ = RA.Extend.extend; -var reduce_ = RA.Foldable.reduce; -var foldMap_ = RA.Foldable.foldMap; -var reduceRight_ = RA.Foldable.reduceRight; -var traverse_ = RA.Traversable.traverse; -var alt_ = RA.Alt.alt; -var reduceWithIndex_ = RA.FoldableWithIndex.reduceWithIndex; -var foldMapWithIndex_ = RA.FoldableWithIndex - .foldMapWithIndex; -var reduceRightWithIndex_ = RA.FoldableWithIndex - .reduceRightWithIndex; -var traverseWithIndex_ = RA.TraversableWithIndex - .traverseWithIndex; -// ------------------------------------------------------------------------------------- -// pipeables -// ------------------------------------------------------------------------------------- +var intersperse = function (middle) { + return function (as) { + var rest = (0, exports.tail)(as); + return (0, exports.isNonEmpty)(rest) ? (0, function_1.pipe)(rest, (0, exports.prependAll)(middle), (0, exports.prepend)((0, exports.head)(as))) : as; + }; +}; +exports.intersperse = intersperse; /** - * @category FoldableWithIndex - * @since 2.5.0 + * @category sequencing + * @since 2.10.0 */ -var foldMapWithIndex = function (S) { return function (f) { return function (fa) { return fa.slice(1).reduce(function (s, a, i) { return S.concat(s, f(i + 1, a)); }, f(0, fa[0])); }; }; }; -exports.foldMapWithIndex = foldMapWithIndex; +var chainWithIndex = function (f) { + return function (as) { + var out = _.fromReadonlyNonEmptyArray(f(0, (0, exports.head)(as))); + for (var i = 1; i < as.length; i++) { + out.push.apply(out, f(i, as[i])); + } + return out; + }; +}; +exports.chainWithIndex = chainWithIndex; +/** + * A useful recursion pattern for processing a `ReadonlyNonEmptyArray` to produce a new `ReadonlyNonEmptyArray`, often used for "chopping" up the input + * `ReadonlyNonEmptyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `ReadonlyNonEmptyArray` and produce a + * value and the tail of the `ReadonlyNonEmptyArray`. + * + * @since 2.10.0 + */ +var chop = function (f) { + return function (as) { + var _a = f(as), b = _a[0], rest = _a[1]; + var out = [b]; + var next = rest; + while ((0, exports.isNonEmpty)(next)) { + var _b = f(next), b_1 = _b[0], rest_2 = _b[1]; + out.push(b_1); + next = rest_2; + } + return out; + }; +}; +exports.chop = chop; +/** + * Splits a `ReadonlyNonEmptyArray` into two pieces, the first piece has max `n` elements. + * + * @since 2.10.0 + */ +var splitAt = function (n) { + return function (as) { + var m = Math.max(1, n); + return m >= as.length ? [as, exports.empty] : [(0, function_1.pipe)(as.slice(1, m), (0, exports.prepend)((0, exports.head)(as))), as.slice(m)]; + }; +}; +exports.splitAt = splitAt; +/** + * Splits a `ReadonlyNonEmptyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of + * the `ReadonlyNonEmptyArray`. + * + * @since 2.10.0 + */ +var chunksOf = function (n) { return (0, exports.chop)((0, exports.splitAt)(n)); }; +exports.chunksOf = chunksOf; +var _map = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }; +/* istanbul ignore next */ +var _mapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.mapWithIndex)(f)); }; +var _ap = function (fab, fa) { return (0, function_1.pipe)(fab, (0, exports.ap)(fa)); }; +/* istanbul ignore next */ +var _extend = function (wa, f) { return (0, function_1.pipe)(wa, (0, exports.extend)(f)); }; +/* istanbul ignore next */ +var _reduce = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduce)(b, f)); }; +/* istanbul ignore next */ +var _foldMap = function (M) { + var foldMapM = (0, exports.foldMap)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapM(f)); }; +}; +/* istanbul ignore next */ +var _reduceRight = function (fa, b, f) { return (0, function_1.pipe)(fa, (0, exports.reduceRight)(b, f)); }; +/* istanbul ignore next */ +var _traverse = function (F) { + var traverseF = (0, exports.traverse)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseF(f)); }; +}; +/* istanbul ignore next */ +var _alt = function (fa, that) { return (0, function_1.pipe)(fa, (0, exports.alt)(that)); }; +/* istanbul ignore next */ +var _reduceWithIndex = function (fa, b, f) { + return (0, function_1.pipe)(fa, (0, exports.reduceWithIndex)(b, f)); +}; +/* istanbul ignore next */ +var _foldMapWithIndex = function (M) { + var foldMapWithIndexM = (0, exports.foldMapWithIndex)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapWithIndexM(f)); }; +}; +/* istanbul ignore next */ +var _reduceRightWithIndex = function (fa, b, f) { + return (0, function_1.pipe)(fa, (0, exports.reduceRightWithIndex)(b, f)); +}; +/* istanbul ignore next */ +var _traverseWithIndex = function (F) { + var traverseWithIndexF = (0, exports.traverseWithIndex)(F); + return function (ta, f) { return (0, function_1.pipe)(ta, traverseWithIndexF(f)); }; +}; /** - * @category Foldable + * @category constructors * @since 2.5.0 */ -var foldMap = function (S) { return function (f) { return function (fa) { - return fa.slice(1).reduce(function (s, a) { return S.concat(s, f(a)); }, f(fa[0])); -}; }; }; -exports.foldMap = foldMap; +exports.of = _.singleton; /** * Less strict version of [`alt`](#alt). * - * @category Alt + * The `W` suffix (short for **W**idening) means that the return types will be merged. + * + * @example + * import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3] as RNEA.ReadonlyNonEmptyArray, + * RNEA.altW(() => ['a', 'b']) + * ), + * [1, 2, 3, 'a', 'b'] + * ) + * + * @category error handling * @since 2.9.0 */ -exports.altW = RA.altW; +var altW = function (that) { + return function (as) { + return (0, function_1.pipe)(as, concatW(that())); + }; +}; +exports.altW = altW; /** * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to * types of kind `* -> *`. * - * @category Alt + * In case of `ReadonlyNonEmptyArray` concatenates the inputs into a single array. + * + * @example + * import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * RNEA.alt(() => [4, 5]) + * ), + * [1, 2, 3, 4, 5] + * ) + * + * @category error handling * @since 2.6.2 */ -exports.alt = RA.alt; +exports.alt = exports.altW; /** - * @category Apply * @since 2.5.0 */ -exports.ap = RA.ap; +var ap = function (as) { return (0, exports.flatMap)(function (f) { return (0, function_1.pipe)(as, (0, exports.map)(f)); }); }; +exports.ap = ap; /** - * Combine two effectful actions, keeping only the result of the first. + * @example + * import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray' + * import { pipe } from 'fp-ts/function' * - * Derivable from `Apply`. + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * RNEA.flatMap((n) => [`a${n}`, `b${n}`]) + * ), + * ['a1', 'b1', 'a2', 'b2', 'a3', 'b3'] + * ) * - * @category combinators - * @since 2.5.0 + * @category sequencing + * @since 2.14.0 */ -exports.apFirst = RA.apFirst; +exports.flatMap = (0, function_1.dual)(2, function (ma, f) { + return (0, function_1.pipe)(ma, (0, exports.chainWithIndex)(function (i, a) { return f(a, i); })); +}); /** - * Combine two effectful actions, keeping only the result of the second. - * - * Derivable from `Apply`. - * - * @category combinators * @since 2.5.0 */ -exports.apSecond = RA.apSecond; +var extend = function (f) { + return function (as) { + var next = (0, exports.tail)(as); + var out = [f(as)]; + while ((0, exports.isNonEmpty)(next)) { + out.push(f(next)); + next = (0, exports.tail)(next); + } + return out; + }; +}; +exports.extend = extend; /** - * Composes computations in sequence, using the return value of one computation to determine the next computation. - * - * @category Monad * @since 2.5.0 */ -exports.chain = RA.chain; +exports.duplicate = +/*#__PURE__*/ (0, exports.extend)(function_1.identity); /** - * Composes computations in sequence, using the return value of one computation to determine the next computation and - * keeping only the result of the first. - * - * Derivable from `Monad`. - * - * @category combinators + * @category sequencing * @since 2.5.0 */ -exports.chainFirst = RA.chainFirst; +exports.flatten = +/*#__PURE__*/ (0, exports.flatMap)(function_1.identity); /** - * Derivable from `Extend`. + * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types + * use the type constructor `F` to represent some computational context. * - * @category combinators + * @category mapping * @since 2.5.0 */ -exports.duplicate = RA.duplicate; +var map = function (f) { + return (0, exports.mapWithIndex)(function (_, a) { return f(a); }); +}; +exports.map = map; /** - * @category Extend + * @category mapping * @since 2.5.0 */ -exports.extend = RA.extend; +var mapWithIndex = function (f) { + return function (as) { + var out = [f(0, (0, exports.head)(as))]; + for (var i = 1; i < as.length; i++) { + out.push(f(i, as[i])); + } + return out; + }; +}; +exports.mapWithIndex = mapWithIndex; /** - * Derivable from `Monad`. - * - * @category combinators + * @category folding * @since 2.5.0 */ -exports.flatten = RA.flatten; +var reduce = function (b, f) { + return (0, exports.reduceWithIndex)(b, function (_, b, a) { return f(b, a); }); +}; +exports.reduce = reduce; /** - * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types - * use the type constructor `F` to represent some computational context. + * **Note**. The constraint is relaxed: a `Semigroup` instead of a `Monoid`. * - * @category Functor + * @category folding * @since 2.5.0 */ -exports.map = RA.map; +var foldMap = function (S) { + return function (f) { + return function (as) { + return as.slice(1).reduce(function (s, a) { return S.concat(s, f(a)); }, f(as[0])); + }; + }; +}; +exports.foldMap = foldMap; /** - * @category FunctorWithIndex + * @category folding * @since 2.5.0 */ -exports.mapWithIndex = RA.mapWithIndex; +var reduceRight = function (b, f) { + return (0, exports.reduceRightWithIndex)(b, function (_, b, a) { return f(b, a); }); +}; +exports.reduceRight = reduceRight; /** - * @category Foldable + * @category folding * @since 2.5.0 */ -exports.reduce = RA.reduce; +var reduceWithIndex = function (b, f) { + return function (as) { + return as.reduce(function (b, a, i) { return f(i, b, a); }, b); + }; +}; +exports.reduceWithIndex = reduceWithIndex; /** - * @category FoldableWithIndex + * **Note**. The constraint is relaxed: a `Semigroup` instead of a `Monoid`. + * + * @category folding * @since 2.5.0 */ -exports.reduceWithIndex = RA.reduceWithIndex; +var foldMapWithIndex = function (S) { + return function (f) { + return function (as) { + return as.slice(1).reduce(function (s, a, i) { return S.concat(s, f(i + 1, a)); }, f(0, as[0])); + }; + }; +}; +exports.foldMapWithIndex = foldMapWithIndex; /** - * @category Foldable + * @category folding * @since 2.5.0 */ -exports.reduceRight = RA.reduceRight; +var reduceRightWithIndex = function (b, f) { + return function (as) { + return as.reduceRight(function (b, a, i) { return f(i, a, b); }, b); + }; +}; +exports.reduceRightWithIndex = reduceRightWithIndex; /** - * @category FoldableWithIndex - * @since 2.5.0 + * @category traversing + * @since 2.6.3 */ -exports.reduceRightWithIndex = RA.reduceRightWithIndex; +var traverse = function (F) { + var traverseWithIndexF = (0, exports.traverseWithIndex)(F); + return function (f) { return traverseWithIndexF(function (_, a) { return f(a); }); }; +}; +exports.traverse = traverse; /** + * @category traversing * @since 2.6.3 */ -exports.traverse = RA.traverse; +var sequence = function (F) { return (0, exports.traverseWithIndex)(F)(function_1.SK); }; +exports.sequence = sequence; /** + * @category sequencing * @since 2.6.3 */ -exports.sequence = RA.sequence; +var traverseWithIndex = function (F) { + return function (f) { + return function (as) { + var out = F.map(f(0, (0, exports.head)(as)), exports.of); + for (var i = 1; i < as.length; i++) { + out = F.ap(F.map(out, function (bs) { return function (b) { return (0, function_1.pipe)(bs, (0, exports.append)(b)); }; }), f(i, as[i])); + } + return out; + }; + }; +}; +exports.traverseWithIndex = traverseWithIndex; /** + * @category Comonad * @since 2.6.3 */ -exports.traverseWithIndex = RA.traverseWithIndex; +exports.extract = _.head; /** - * @since 2.6.3 + * @category type lambdas + * @since 2.5.0 */ -exports.extract = head; -// ------------------------------------------------------------------------------------- -// instances -// ------------------------------------------------------------------------------------- +exports.URI = 'ReadonlyNonEmptyArray'; /** * @category instances * @since 2.5.0 */ -exports.URI = 'ReadonlyNonEmptyArray'; +var getShow = function (S) { return ({ + show: function (as) { return "[".concat(as.map(S.show).join(', '), "]"); } +}); }; +exports.getShow = getShow; +/** + * Builds a `Semigroup` instance for `ReadonlyNonEmptyArray` + * + * @category instances + * @since 2.5.0 + */ +var getSemigroup = function () { return ({ + concat: concat +}); }; +exports.getSemigroup = getSemigroup; +/** + * @example + * import { getEq } from 'fp-ts/ReadonlyNonEmptyArray' + * import * as N from 'fp-ts/number' + * + * const E = getEq(N.Eq) + * assert.strictEqual(E.equals([1, 2], [1, 2]), true) + * assert.strictEqual(E.equals([1, 2], [1, 3]), false) + * + * @category instances + * @since 2.5.0 + */ +var getEq = function (E) { + return (0, Eq_1.fromEquals)(function (xs, ys) { return xs.length === ys.length && xs.every(function (x, i) { return E.equals(x, ys[i]); }); }); +}; +exports.getEq = getEq; +/** + * @since 2.11.0 + */ +var getUnionSemigroup = function (E) { + var unionE = (0, exports.union)(E); + return { + concat: function (first, second) { return unionE(second)(first); } + }; +}; +exports.getUnionSemigroup = getUnionSemigroup; /** * @category instances * @since 2.7.0 */ exports.Functor = { URI: exports.URI, - map: map_ + map: _map +}; +/** + * @category mapping + * @since 2.10.0 + */ +exports.flap = (0, Functor_1.flap)(exports.Functor); +/** + * @category instances + * @since 2.10.0 + */ +exports.Pointed = { + URI: exports.URI, + of: exports.of }; /** * @category instances @@ -13977,29 +18470,80 @@ exports.Functor = { */ exports.FunctorWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_ + map: _map, + mapWithIndex: _mapWithIndex +}; +/** + * @category instances + * @since 2.10.0 + */ +exports.Apply = { + URI: exports.URI, + map: _map, + ap: _ap }; +/** + * Combine two effectful actions, keeping only the result of the first. + * + * @since 2.5.0 + */ +exports.apFirst = (0, Apply_1.apFirst)(exports.Apply); +/** + * Combine two effectful actions, keeping only the result of the second. + * + * @since 2.5.0 + */ +exports.apSecond = (0, Apply_1.apSecond)(exports.Apply); /** * @category instances * @since 2.7.0 */ exports.Applicative = { URI: exports.URI, - map: map_, - ap: ap_, + map: _map, + ap: _ap, of: exports.of }; +/** + * @category instances + * @since 2.10.0 + */ +exports.Chain = { + URI: exports.URI, + map: _map, + ap: _ap, + chain: exports.flatMap +}; +/** + * Composes computations in sequence, using the return value of one computation to determine the next computation and + * keeping only the result of the first. + * + * @example + * import * as RA from 'fp-ts/ReadonlyArray' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual( + * pipe( + * [1, 2, 3], + * RA.chainFirst(() => ['a', 'b']) + * ), + * [1, 1, 2, 2, 3, 3] + * ) + * + * @category sequencing + * @since 2.5.0 + */ +exports.chainFirst = (0, Chain_1.chainFirst)(exports.Chain); /** * @category instances * @since 2.7.0 */ exports.Monad = { URI: exports.URI, - map: map_, - ap: ap_, + map: _map, + ap: _ap, of: exports.of, - chain: chain_ + chain: exports.flatMap }; /** * @category instances @@ -14007,9 +18551,9 @@ exports.Monad = { */ exports.Foldable = { URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_ + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight }; /** * @category instances @@ -14017,12 +18561,12 @@ exports.Foldable = { */ exports.FoldableWithIndex = { URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_ + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex }; /** * @category instances @@ -14030,11 +18574,11 @@ exports.FoldableWithIndex = { */ exports.Traversable = { URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: _map, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, sequence: exports.sequence }; /** @@ -14043,17 +18587,17 @@ exports.Traversable = { */ exports.TraversableWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: _map, + mapWithIndex: _mapWithIndex, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, sequence: exports.sequence, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverseWithIndex: traverseWithIndex_ + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex, + traverseWithIndex: _traverseWithIndex }; /** * @category instances @@ -14061,8 +18605,8 @@ exports.TraversableWithIndex = { */ exports.Alt = { URI: exports.URI, - map: map_, - alt: alt_ + map: _map, + alt: _alt }; /** * @category instances @@ -14070,197 +18614,482 @@ exports.Alt = { */ exports.Comonad = { URI: exports.URI, - map: map_, - extend: extend_, + map: _map, + extend: _extend, extract: exports.extract }; -// TODO: remove in v3 -/** - * @category instances - * @since 2.5.0 - */ -exports.readonlyNonEmptyArray = { - URI: exports.URI, - of: exports.of, - map: map_, - mapWithIndex: mapWithIndex_, - ap: ap_, - chain: chain_, - extend: extend_, - extract: exports.extract, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: exports.sequence, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverseWithIndex: traverseWithIndex_, - alt: alt_ -}; // ------------------------------------------------------------------------------------- // do notation // ------------------------------------------------------------------------------------- /** + * @category do notation * @since 2.9.0 */ -exports.Do = -/*#__PURE__*/ -exports.of({}); +exports.Do = (0, exports.of)(_.emptyRecord); /** + * @category do notation * @since 2.8.0 */ -var bindTo = function (name) { return exports.map(function_1.bindTo_(name)); }; -exports.bindTo = bindTo; +exports.bindTo = (0, Functor_1.bindTo)(exports.Functor); +var let_ = /*#__PURE__*/ (0, Functor_1.let)(exports.Functor); +exports["let"] = let_; /** + * @category do notation * @since 2.8.0 */ -var bind = function (name, f) { - return exports.chain(function (a) { - return function_1.pipe(f(a), exports.map(function (b) { return function_1.bind_(a, name, b); })); - }); +exports.bind = (0, Chain_1.bind)(exports.Chain); +/** + * @category do notation + * @since 2.8.0 + */ +exports.apS = (0, Apply_1.apS)(exports.Apply); +// ------------------------------------------------------------------------------------- +// utils +// ------------------------------------------------------------------------------------- +/** + * @since 2.5.0 + */ +exports.head = exports.extract; +/** + * @since 2.5.0 + */ +exports.tail = _.tail; +/** + * @since 2.5.0 + */ +var last = function (as) { return as[as.length - 1]; }; +exports.last = last; +/** + * Get all but the last element of a non empty array, creating a new array. + * + * @example + * import { init } from 'fp-ts/ReadonlyNonEmptyArray' + * + * assert.deepStrictEqual(init([1, 2, 3]), [1, 2]) + * assert.deepStrictEqual(init([1]), []) + * + * @since 2.5.0 + */ +var init = function (as) { return as.slice(0, -1); }; +exports.init = init; +/** + * @since 2.5.0 + */ +var min = function (O) { + var S = Se.min(O); + return function (as) { return as.reduce(S.concat); }; }; -exports.bind = bind; +exports.min = min; +/** + * @since 2.5.0 + */ +var max = function (O) { + var S = Se.max(O); + return function (as) { return as.reduce(S.concat); }; +}; +exports.max = max; +/** + * @since 2.10.0 + */ +var concatAll = function (S) { + return function (as) { + return as.reduce(S.concat); + }; +}; +exports.concatAll = concatAll; +/** + * Break a `ReadonlyArray` into its first element and remaining elements. + * + * @category pattern matching + * @since 2.11.0 + */ +var matchLeft = function (f) { + return function (as) { + return f((0, exports.head)(as), (0, exports.tail)(as)); + }; +}; +exports.matchLeft = matchLeft; +/** + * Break a `ReadonlyArray` into its initial elements and the last element. + * + * @category pattern matching + * @since 2.11.0 + */ +var matchRight = function (f) { + return function (as) { + return f((0, exports.init)(as), (0, exports.last)(as)); + }; +}; +exports.matchRight = matchRight; +/** + * Apply a function to the head, creating a new `ReadonlyNonEmptyArray`. + * + * @since 2.11.0 + */ +var modifyHead = function (f) { + return function (as) { + return __spreadArray([f((0, exports.head)(as))], (0, exports.tail)(as), true); + }; +}; +exports.modifyHead = modifyHead; +/** + * Change the head, creating a new `ReadonlyNonEmptyArray`. + * + * @since 2.11.0 + */ +var updateHead = function (a) { return (0, exports.modifyHead)(function () { return a; }); }; +exports.updateHead = updateHead; +/** + * Apply a function to the last element, creating a new `ReadonlyNonEmptyArray`. + * + * @since 2.11.0 + */ +var modifyLast = function (f) { + return function (as) { + return (0, function_1.pipe)((0, exports.init)(as), (0, exports.append)(f((0, exports.last)(as)))); + }; +}; +exports.modifyLast = modifyLast; +/** + * Change the last element, creating a new `ReadonlyNonEmptyArray`. + * + * @since 2.11.0 + */ +var updateLast = function (a) { return (0, exports.modifyLast)(function () { return a; }); }; +exports.updateLast = updateLast; +/** + * Places an element in between members of a `ReadonlyNonEmptyArray`, then folds the results using the provided `Semigroup`. + * + * @example + * import * as S from 'fp-ts/string' + * import { intercalate } from 'fp-ts/ReadonlyNonEmptyArray' + * + * assert.deepStrictEqual(intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c') + * + * @since 2.12.0 + */ +var intercalate = function (S) { + var concatAllS = (0, exports.concatAll)(S); + return function (middle) { return (0, function_1.flow)((0, exports.intersperse)(middle), concatAllS); }; +}; +exports.intercalate = intercalate; // ------------------------------------------------------------------------------------- -// pipeable sequence S +// legacy // ------------------------------------------------------------------------------------- /** - * @since 2.8.0 + * Alias of `flatMap`. + * + * @category legacy + * @since 2.5.0 + */ +exports.chain = exports.flatMap; +function groupSort(O) { + var sortO = (0, exports.sort)(O); + var groupO = group(O); + return function (as) { return ((0, exports.isNonEmpty)(as) ? groupO(sortO(as)) : exports.empty); }; +} +exports.groupSort = groupSort; +function filter(predicate) { + return (0, exports.filterWithIndex)(function (_, a) { return predicate(a); }); +} +exports.filter = filter; +/** + * Use [`filterWithIndex`](./ReadonlyArray.ts.html#filterwithindex) instead. + * + * @category zone of death + * @since 2.5.0 + * @deprecated */ -var apS = function (name, fb) { - return function_1.flow(exports.map(function (a) { return function (b) { return function_1.bind_(a, name, b); }; }), exports.ap(fb)); +var filterWithIndex = function (predicate) { + return function (as) { + return (0, exports.fromReadonlyArray)(as.filter(function (a, i) { return predicate(i, a); })); + }; +}; +exports.filterWithIndex = filterWithIndex; +/** + * Use [`unprepend`](#unprepend) instead. + * + * @category zone of death + * @since 2.10.0 + * @deprecated + */ +exports.uncons = exports.unprepend; +/** + * Use [`unappend`](#unappend) instead. + * + * @category zone of death + * @since 2.10.0 + * @deprecated + */ +exports.unsnoc = exports.unappend; +function cons(head, tail) { + return tail === undefined ? (0, exports.prepend)(head) : (0, function_1.pipe)(tail, (0, exports.prepend)(head)); +} +exports.cons = cons; +/** + * Use [`append`](./ReadonlyArray.ts.html#append) instead. + * + * @category zone of death + * @since 2.5.0 + * @deprecated + */ +var snoc = function (init, end) { return (0, function_1.pipe)(init, concat([end])); }; +exports.snoc = snoc; +/** + * Use [`insertAt`](./ReadonlyArray.ts.html#insertat) instead. + * + * @category zone of death + * @since 2.5.0 + * @deprecated + */ +var insertAt = function (i, a) { + return function (as) { + return i < 0 || i > as.length ? _.none : _.some((0, exports.unsafeInsertAt)(i, a, as)); + }; +}; +exports.insertAt = insertAt; +/** + * Use [`prependAll`](#prependall) instead. + * + * @category zone of death + * @since 2.9.0 + * @deprecated + */ +exports.prependToAll = exports.prependAll; +/** + * Use [`concatAll`](#concatall) instead. + * + * @category zone of death + * @since 2.5.0 + * @deprecated + */ +exports.fold = exports.concatAll; +/** + * This instance is deprecated, use small, specific instances instead. + * For example if a function needs a `Functor` instance, pass `RNEA.Functor` instead of `RNEA.readonlyNonEmptyArray` + * (where `RNEA` is from `import RNEA from 'fp-ts/ReadonlyNonEmptyArray'`) + * + * @category zone of death + * @since 2.5.0 + * @deprecated + */ +exports.readonlyNonEmptyArray = { + URI: exports.URI, + of: exports.of, + map: _map, + mapWithIndex: _mapWithIndex, + ap: _ap, + chain: exports.flatMap, + extend: _extend, + extract: exports.extract, + reduce: _reduce, + foldMap: _foldMap, + reduceRight: _reduceRight, + traverse: _traverse, + sequence: exports.sequence, + reduceWithIndex: _reduceWithIndex, + foldMapWithIndex: _foldMapWithIndex, + reduceRightWithIndex: _reduceRightWithIndex, + traverseWithIndex: _traverseWithIndex, + alt: _alt }; -exports.apS = apS; /***/ }), /***/ 1897: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.URI = exports.separate = exports.compact = exports.reduceRight = exports.foldMap = exports.reduce = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports.elem = exports.some = exports.every = exports.fromFoldableMap = exports.fromFoldable = exports.filterWithIndex = exports.filterMapWithIndex = exports.partitionWithIndex = exports.partitionMapWithIndex = exports.wilt = exports.wither = exports.sequence = exports.traverse = exports.traverseWithIndex = exports.singleton = exports.reduceRightWithIndex = exports.foldMapWithIndex = exports.reduceWithIndex = exports.map = exports.mapWithIndex = exports.empty = exports.lookup = exports.getMonoid = exports.getEq = exports.isSubrecord = exports.pop = exports.modifyAt = exports.updateAt = exports.deleteAt = exports.hasOwnProperty = exports.insertAt = exports.toUnfoldable = exports.toReadonlyArray = exports.collect = exports.keys = exports.isEmpty = exports.size = exports.getShow = exports.toRecord = exports.fromRecord = void 0; -exports.readonlyRecord = exports.Witherable = exports.TraversableWithIndex = exports.Traversable = exports.FilterableWithIndex = exports.Filterable = exports.Compactable = exports.FoldableWithIndex = exports.Foldable = exports.FunctorWithIndex = exports.Functor = void 0; +exports._partition = exports._filterMap = exports._filter = exports._reduceRight = exports._foldMap = exports._reduce = exports._mapWithIndex = exports._map = exports.difference = exports.intersection = exports.union = exports.elem = exports.some = exports.every = exports.fromEntries = exports.toEntries = exports.fromFoldableMap = exports.fromFoldable = exports.filterWithIndex = exports.filterMapWithIndex = exports.partitionWithIndex = exports.partitionMapWithIndex = exports.wilt = exports.wither = exports.sequence = exports.traverse = exports.traverseWithIndex = exports.singleton = exports.reduceRightWithIndex = exports.foldMapWithIndex = exports.reduceWithIndex = exports.map = exports.mapWithIndex = exports.empty = exports.lookup = exports.isSubrecord = exports.pop = exports.modifyAt = exports.updateAt = exports.deleteAt = exports.has = exports.upsertAt = exports.toUnfoldable = exports.toReadonlyArray = exports.collect = exports.keys = exports.isEmpty = exports.size = exports.toRecord = exports.fromRecord = void 0; +exports.readonlyRecord = exports.hasOwnProperty = exports.insertAt = exports.Witherable = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.getDifferenceMagma = exports.getIntersectionSemigroup = exports.getUnionMonoid = exports.getUnionSemigroup = exports.getWitherable = exports.getTraversableWithIndex = exports.getTraversable = exports.FilterableWithIndex = exports.Filterable = exports.Compactable = exports.getFoldableWithIndex = exports.getFoldable = exports.FunctorWithIndex = exports.flap = exports.Functor = exports.getMonoid = exports.getEq = exports.getShow = exports.URI = exports.separate = exports.compact = exports.reduceRight = exports.foldMap = exports.reduce = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports._sequence = exports._traverse = exports._filterWithIndex = exports._filterMapWithIndex = exports._partitionWithIndex = exports._partitionMapWithIndex = exports._reduceRightWithIndex = exports._foldMapWithIndex = exports._reduceWithIndex = exports._partitionMap = void 0; var Eq_1 = __nccwpck_require__(6964); var function_1 = __nccwpck_require__(6985); -var Option_1 = __nccwpck_require__(2569); +var Functor_1 = __nccwpck_require__(5533); +var _ = __importStar(__nccwpck_require__(1840)); +var Separated_1 = __nccwpck_require__(5877); +var S = __importStar(__nccwpck_require__(5189)); +var Witherable_1 = __nccwpck_require__(4384); /** - * @category constructors + * Builds a `ReadonlyRecord` by copying a `Record`. + * + * @example + * import { ReadonlyRecord, fromRecord } from "fp-ts/ReadonlyRecord" + * + * const x: Record = { a: 1, b: 2 }; + * const y: ReadonlyRecord = fromRecord(x); + * assert.deepStrictEqual(x,y); + * // `y.a = 5` gives compiler error + * + * @category conversions * @since 2.5.0 */ -function fromRecord(r) { - return Object.assign({}, r); -} +var fromRecord = function (r) { return Object.assign({}, r); }; exports.fromRecord = fromRecord; /** - * @category destructors + * Builds a mutable `Record` from a `ReadonlyRecord`. + * + * @example + * import { ReadonlyRecord, toRecord } from "fp-ts/ReadonlyRecord" + * + * const x: ReadonlyRecord = { a: 1, b: 2 }; + * const y: Record = toRecord(x); + * assert.deepStrictEqual(x,y); + * y.a = 5; // it's ok, y is mutable + * + * @category conversions * @since 2.5.0 */ -function toRecord(r) { - return Object.assign({}, r); -} +var toRecord = function (r) { return Object.assign({}, r); }; exports.toRecord = toRecord; /** - * @category instances - * @since 2.5.0 - */ -function getShow(S) { - return { - show: function (r) { - var elements = collect(function (k, a) { return JSON.stringify(k) + ": " + S.show(a); })(r).join(', '); - return elements === '' ? '{}' : "{ " + elements + " }"; - } - }; -} -exports.getShow = getShow; -/** - * Calculate the number of key/value pairs in a record + * Calculate the number of key/value pairs in a `ReadonlyRecord`, + * + * @example + * import { size } from "fp-ts/ReadonlyRecord"; + * + * assert.deepStrictEqual(size({ a: true, b: 2, c: "three" }), 3); * * @since 2.5.0 */ -function size(r) { - return Object.keys(r).length; -} +var size = function (r) { return Object.keys(r).length; }; exports.size = size; /** - * Test whether a record is empty + * Test whether a `ReadonlyRecord` is empty. + * + * @example + * import { isEmpty } from "fp-ts/ReadonlyRecord" * + * assert.deepStrictEqual(isEmpty({}), true); + * assert.deepStrictEqual(isEmpty({ a: 3 }), false); * @since 2.5.0 */ -function isEmpty(r) { - return Object.keys(r).length === 0; -} +var isEmpty = function (r) { + for (var k in r) { + if (_.has.call(r, k)) { + return false; + } + } + return true; +}; exports.isEmpty = isEmpty; +var keys_ = function (O) { + return function (r) { + return Object.keys(r).sort(O.compare); + }; +}; /** * @since 2.5.0 */ -function keys(r) { - return Object.keys(r).sort(); +exports.keys = keys_(S.Ord); +function collect(O) { + if (typeof O === 'function') { + return collect(S.Ord)(O); + } + var keysO = keys_(O); + return function (f) { + return function (r) { + var out = []; + for (var _i = 0, _a = keysO(r); _i < _a.length; _i++) { + var key = _a[_i]; + out.push(f(key, r[key])); + } + return out; + }; + }; } -exports.keys = keys; +exports.collect = collect; /** - * Map a record into an array + * Get a sorted `ReadonlyArray` of the key/value pairs contained in a `ReadonlyRecord`. * * @example - * import {collect} from 'fp-ts/ReadonlyRecord' + * import { toReadonlyArray } from 'fp-ts/ReadonlyRecord' * - * const x: { a: string, b: boolean } = { a: 'foo', b: false } - * assert.deepStrictEqual( - * collect((key, val) => ({key: key, value: val}))(x), - * [{key: 'a', value: 'foo'}, {key: 'b', value: false}] - * ) + * const x = { c: 3, a: "foo", b: false }; + * assert.deepStrictEqual(toReadonlyArray(x), [ + * ["a", "foo"], + * ["b", false], + * ["c", 3], + * ]); * - * @since 2.5.0 - */ -function collect(f) { - return function (r) { - // tslint:disable-next-line: readonly-array - var out = []; - for (var _i = 0, _a = keys(r); _i < _a.length; _i++) { - var key = _a[_i]; - out.push(f(key, r[key])); - } - return out; - }; -} -exports.collect = collect; -/** - * @category destructors + * @category conversions * @since 2.5.0 */ exports.toReadonlyArray = -/*#__PURE__*/ -collect(function (k, a) { return [k, a]; }); +/*#__PURE__*/ collect(S.Ord)(function (k, a) { return [k, a]; }); function toUnfoldable(U) { return function (r) { - var arr = exports.toReadonlyArray(r); - var len = arr.length; - return U.unfold(0, function (b) { return (b < len ? Option_1.some([arr[b], b + 1]) : Option_1.none); }); + var sas = (0, exports.toReadonlyArray)(r); + var len = sas.length; + return U.unfold(0, function (b) { return (b < len ? _.some([sas[b], b + 1]) : _.none); }); }; } exports.toUnfoldable = toUnfoldable; -function insertAt(k, a) { +/** + * Insert or replace a key/value pair in a `ReadonlyRecord`. + * + * @example + * import { upsertAt } from 'fp-ts/ReadonlyRecord' + * + * assert.deepStrictEqual(upsertAt("a", 5)({ a: 1, b: 2 }), { a: 5, b: 2 }); + * assert.deepStrictEqual(upsertAt("c", 5)({ a: 1, b: 2 }), { a: 1, b: 2, c: 5 }); + * + * @since 2.10.0 + */ +var upsertAt = function (k, a) { return function (r) { - if (r[k] === a) { + if (_.has.call(r, k) && r[k] === a) { return r; } var out = Object.assign({}, r); out[k] = a; return out; }; -} -exports.insertAt = insertAt; -var _hasOwnProperty = Object.prototype.hasOwnProperty; -function hasOwnProperty(k, r) { - return _hasOwnProperty.call(r === undefined ? this : r, k); -} -exports.hasOwnProperty = hasOwnProperty; +}; +exports.upsertAt = upsertAt; +/** + * Test whether or not a key exists in a `ReadonlyRecord`. + * + * Note. This function is not pipeable because is a `Refinement`. + * + * @example + * import { has } from 'fp-ts/ReadonlyRecord' + * + * assert.deepStrictEqual(has("a", { a: 1, b: 2 }), true); + * assert.deepStrictEqual(has("c", { a: 1, b: 2 }), false); + * + * @since 2.10.0 + */ +var has = function (k, r) { return _.has.call(r, k); }; +exports.has = has; function deleteAt(k) { return function (r) { - if (!_hasOwnProperty.call(r, k)) { + if (!_.has.call(r, k)) { return r; } var out = Object.assign({}, r); @@ -14270,41 +19099,69 @@ function deleteAt(k) { } exports.deleteAt = deleteAt; /** + * Replace a key/value pair in a `ReadonlyRecord`. + * + * @returns If the specified key exists it returns an `Option` containing a new `Record` + * with the entry updated, otherwise it returns `None` + * + * @example + * import { updateAt } from 'fp-ts/ReadonlyRecord' + * import { option } from 'fp-ts' + * + * assert.deepStrictEqual(updateAt("a", 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 })); + * assert.deepStrictEqual(updateAt("c", 3)({ a: 1, b: 2 }), option.none); + * * @since 2.5.0 */ -function updateAt(k, a) { +var updateAt = function (k, a) { return function (r) { - if (!hasOwnProperty(k, r)) { - return Option_1.none; + if (!(0, exports.has)(k, r)) { + return _.none; } if (r[k] === a) { - return Option_1.some(r); + return _.some(r); } var out = Object.assign({}, r); out[k] = a; - return Option_1.some(out); + return _.some(out); }; -} +}; exports.updateAt = updateAt; /** + * Applies a mapping function to one specific key/value pair in a `ReadonlyRecord`. + * + * @returns If the specified key exists it returns an `Option` containing a new `Record` + * with the entry updated, otherwise it returns `None` + * + * @example + * import { modifyAt } from 'fp-ts/ReadonlyRecord' + * import { option } from 'fp-ts' + * + * assert.deepStrictEqual(modifyAt("a", (x: number) => x * 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 })); + * assert.deepStrictEqual(modifyAt("c", (x: number) => x * 3)({ a: 1, b: 2 }), option.none); + * * @since 2.5.0 */ -function modifyAt(k, f) { +var modifyAt = function (k, f) { return function (r) { - if (!hasOwnProperty(k, r)) { - return Option_1.none; + if (!(0, exports.has)(k, r)) { + return _.none; + } + var next = f(r[k]); + if (next === r[k]) { + return _.some(r); } var out = Object.assign({}, r); - out[k] = f(r[k]); - return Option_1.some(out); + out[k] = next; + return _.some(out); }; -} +}; exports.modifyAt = modifyAt; function pop(k) { var deleteAtk = deleteAt(k); return function (r) { var oa = lookup(k, r); - return Option_1.isNone(oa) ? Option_1.none : Option_1.some([oa.value, deleteAtk(r)]); + return _.isNone(oa) ? _.none : _.some([oa.value, deleteAtk(r)]); }; } exports.pop = pop; @@ -14315,7 +19172,7 @@ function isSubrecord(E) { return function (that) { return isSubrecordE_1(that, me); }; } for (var k in me) { - if (!_hasOwnProperty.call(that, k) || !E.equals(me[k], that[k])) { + if (!_.has.call(that, k) || !E.equals(me[k], that[k])) { return false; } } @@ -14323,41 +19180,11 @@ function isSubrecord(E) { }; } exports.isSubrecord = isSubrecord; -function getEq(E) { - var isSubrecordE = isSubrecord(E); - return Eq_1.fromEquals(function (x, y) { return isSubrecordE(x)(y) && isSubrecordE(y)(x); }); -} -exports.getEq = getEq; -function getMonoid(S) { - return { - concat: function (x, y) { - if (x === exports.empty) { - return y; - } - if (y === exports.empty) { - return x; - } - var keys = Object.keys(y); - var len = keys.length; - if (len === 0) { - return x; - } - var r = Object.assign({}, x); - for (var i = 0; i < len; i++) { - var k = keys[i]; - r[k] = _hasOwnProperty.call(x, k) ? S.concat(x[k], y[k]) : y[k]; - } - return r; - }, - empty: exports.empty - }; -} -exports.getMonoid = getMonoid; function lookup(k, r) { if (r === undefined) { return function (r) { return lookup(k, r); }; } - return _hasOwnProperty.call(r, k) ? Option_1.some(r[k]) : Option_1.none; + return _.has.call(r, k) ? _.some(r[k]) : _.none; } exports.lookup = lookup; /** @@ -14365,12 +19192,12 @@ exports.lookup = lookup; */ exports.empty = {}; function mapWithIndex(f) { - return function (fa) { + return function (r) { var out = {}; - var keys = Object.keys(fa); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - out[key] = f(key, fa[key]); + for (var k in r) { + if (_.has.call(r, k)) { + out[k] = f(k, r[k]); + } } return out; }; @@ -14380,162 +19207,169 @@ function map(f) { return mapWithIndex(function (_, a) { return f(a); }); } exports.map = map; -function reduceWithIndex(b, f) { - return function (fa) { +function reduceWithIndex() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (args.length === 2) { + return reduceWithIndex(S.Ord).apply(void 0, args); + } + var keysO = keys_(args[0]); + return function (b, f) { return function (fa) { var out = b; - var ks = keys(fa); + var ks = keysO(fa); var len = ks.length; for (var i = 0; i < len; i++) { var k = ks[i]; out = f(k, out, fa[k]); } return out; - }; + }; }; } exports.reduceWithIndex = reduceWithIndex; -function foldMapWithIndex(M) { - return function (f) { return function (fa) { - var out = M.empty; - var ks = keys(fa); - var len = ks.length; - for (var i = 0; i < len; i++) { - var k = ks[i]; - out = M.concat(out, f(k, fa[k])); - } - return out; - }; }; +function foldMapWithIndex(O) { + if ('compare' in O) { + var keysO_1 = keys_(O); + return function (M) { + return function (f) { + return function (fa) { + var out = M.empty; + var ks = keysO_1(fa); + var len = ks.length; + for (var i = 0; i < len; i++) { + var k = ks[i]; + out = M.concat(out, f(k, fa[k])); + } + return out; + }; + }; + }; + } + return foldMapWithIndex(S.Ord)(O); } exports.foldMapWithIndex = foldMapWithIndex; -function reduceRightWithIndex(b, f) { - return function (fa) { +function reduceRightWithIndex() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (args.length === 2) { + return reduceRightWithIndex(S.Ord).apply(void 0, args); + } + var keysO = keys_(args[0]); + return function (b, f) { return function (fa) { var out = b; - var ks = keys(fa); + var ks = keysO(fa); var len = ks.length; for (var i = len - 1; i >= 0; i--) { var k = ks[i]; out = f(k, fa[k], out); } return out; - }; + }; }; } exports.reduceRightWithIndex = reduceRightWithIndex; /** - * Create a record with one key/value pair + * Create a `ReadonlyRecord` with one key/value pair. + * + * @example + * import { singleton } from "fp-ts/ReadonlyRecord"; + * + * assert.deepStrictEqual(singleton("a", 1), { a: 1 }); * * @category constructors * @since 2.5.0 */ -function singleton(k, a) { +var singleton = function (k, a) { var _a; - return _a = {}, _a[k] = a, _a; -} + return (_a = {}, _a[k] = a, _a); +}; exports.singleton = singleton; function traverseWithIndex(F) { - return function (f) { return function (ta) { - var ks = keys(ta); - if (ks.length === 0) { - return F.of(exports.empty); - } - var fr = F.of({}); - var _loop_1 = function (key) { - fr = F.ap(F.map(fr, function (r) { return function (b) { - r[key] = b; - return r; - }; }), f(key, ta[key])); - }; - for (var _i = 0, ks_1 = ks; _i < ks_1.length; _i++) { - var key = ks_1[_i]; - _loop_1(key); - } - return fr; - }; }; + var traverseWithIndexOF = _traverseWithIndex(S.Ord)(F); + return function (f) { return function (ta) { return traverseWithIndexOF(ta, f); }; }; } exports.traverseWithIndex = traverseWithIndex; function traverse(F) { - var traverseWithIndexF = traverseWithIndex(F); - return function (f) { return traverseWithIndexF(function (_, a) { return f(a); }); }; + var traverseOF = (0, exports._traverse)(S.Ord)(F); + return function (f) { return function (ta) { return traverseOF(ta, f); }; }; } exports.traverse = traverse; function sequence(F) { - return traverseWithIndex(F)(function (_, a) { return a; }); + return (0, exports._sequence)(S.Ord)(F); } exports.sequence = sequence; /** - * @category Witherable + * @category filtering * @since 2.6.5 */ var wither = function (F) { var traverseF = traverse(F); - return function (f) { return function (fa) { return F.map(function_1.pipe(fa, traverseF(f)), exports.compact); }; }; + return function (f) { return function (fa) { return F.map((0, function_1.pipe)(fa, traverseF(f)), exports.compact); }; }; }; exports.wither = wither; /** - * @category Witherable + * @category filtering * @since 2.6.5 */ var wilt = function (F) { var traverseF = traverse(F); - return function (f) { return function (fa) { return F.map(function_1.pipe(fa, traverseF(f)), exports.separate); }; }; + return function (f) { return function (fa) { return F.map((0, function_1.pipe)(fa, traverseF(f)), exports.separate); }; }; }; exports.wilt = wilt; function partitionMapWithIndex(f) { - return function (fa) { + return function (r) { var left = {}; var right = {}; - var keys = Object.keys(fa); - for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) { - var key = keys_2[_i]; - var e = f(key, fa[key]); - switch (e._tag) { - case 'Left': - left[key] = e.left; - break; - case 'Right': - right[key] = e.right; - break; + for (var k in r) { + if (_.has.call(r, k)) { + var e = f(k, r[k]); + switch (e._tag) { + case 'Left': + left[k] = e.left; + break; + case 'Right': + right[k] = e.right; + break; + } } } - return { - left: left, - right: right - }; + return (0, Separated_1.separated)(left, right); }; } exports.partitionMapWithIndex = partitionMapWithIndex; function partitionWithIndex(predicateWithIndex) { - return function (fa) { + return function (r) { var left = {}; var right = {}; - var keys = Object.keys(fa); - for (var _i = 0, keys_3 = keys; _i < keys_3.length; _i++) { - var key = keys_3[_i]; - var a = fa[key]; - if (predicateWithIndex(key, a)) { - right[key] = a; - } - else { - left[key] = a; + for (var k in r) { + if (_.has.call(r, k)) { + var a = r[k]; + if (predicateWithIndex(k, a)) { + right[k] = a; + } + else { + left[k] = a; + } } } - return { - left: left, - right: right - }; + return (0, Separated_1.separated)(left, right); }; } exports.partitionWithIndex = partitionWithIndex; function filterMapWithIndex(f) { - return function (fa) { - var r = {}; - var keys = Object.keys(fa); - for (var _i = 0, keys_4 = keys; _i < keys_4.length; _i++) { - var key = keys_4[_i]; - var optionB = f(key, fa[key]); - if (Option_1.isSome(optionB)) { - r[key] = optionB.value; + return function (r) { + var out = {}; + for (var k in r) { + if (_.has.call(r, k)) { + var ob = f(k, r[k]); + if (_.isSome(ob)) { + out[k] = ob.value; + } } } - return r; + return out; }; } exports.filterMapWithIndex = filterMapWithIndex; @@ -14544,7 +19378,7 @@ function filterWithIndex(predicateWithIndex) { var out = {}; var changed = false; for (var key in fa) { - if (_hasOwnProperty.call(fa, key)) { + if (_.has.call(fa, key)) { var a = fa[key]; if (predicateWithIndex(key, a)) { out[key] = a; @@ -14567,15 +19401,44 @@ function fromFoldableMap(M, F) { return function (ta, f) { return F.reduce(ta, {}, function (r, a) { var _a = f(a), k = _a[0], b = _a[1]; - r[k] = _hasOwnProperty.call(r, k) ? M.concat(r[k], b) : b; + r[k] = _.has.call(r, k) ? M.concat(r[k], b) : b; return r; }); }; } exports.fromFoldableMap = fromFoldableMap; /** - * @since 2.5.0 + * Alias of [`toReadonlyArray`](#toreadonlyarray). + * + * @example + * import { toEntries } from 'fp-ts/ReadonlyRecord' + * + * assert.deepStrictEqual(toEntries({ b: 2, a: 1 }), [['a', 1], ['b', 2]]) + * + * @category conversions + * @since 2.12.0 + */ +exports.toEntries = exports.toReadonlyArray; +/** + * Converts a `ReadonlyArray` of `[key, value]` tuples into a `ReadonlyRecord`. + * + * @example + * import { fromEntries } from 'fp-ts/ReadonlyRecord' + * + * assert.deepStrictEqual(fromEntries([['a', 1], ['b', 2], ['a', 3]]), { b: 2, a: 3 }) + * + * @since 2.12.0 + * @category conversions */ +var fromEntries = function (fa) { + var out = {}; + for (var _i = 0, fa_1 = fa; _i < fa_1.length; _i++) { + var a = fa_1[_i]; + out[a[0]] = a[1]; + } + return out; +}; +exports.fromEntries = fromEntries; function every(predicate) { return function (r) { for (var k in r) { @@ -14588,6 +19451,14 @@ function every(predicate) { } exports.every = every; /** + * Test if at least one value in a `ReadonlyRecord` satisfies the predicate. + * + * @example + * import { some } from "fp-ts/ReadonlyRecord" + * + * assert.deepStrictEqual(some((n: number) => n >= 0)({ a: 1, b: -2 }), true); + * assert.deepStrictEqual(some((n: number) => n >= 0)({ a: -1, b: -2 }), false); + * * @since 2.5.0 */ function some(predicate) { @@ -14616,83 +19487,265 @@ function elem(E) { }; } exports.elem = elem; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -var map_ = function (fa, f) { return function_1.pipe(fa, map(f)); }; -/* istanbul ignore next */ -var mapWithIndex_ = function (fa, f) { return function_1.pipe(fa, mapWithIndex(f)); }; +/** + * Union of two `ReadonlyRecord`s. + * Takes two `ReadonlyRecord`s and produces a `ReadonlyRecord` combining all the + * entries of the two inputs. + * It uses the `concat` function of the provided `Magma` to + * combine the elements with the same key. + * + * @example + * import { union } from "fp-ts/ReadonlyRecord"; + * import { Magma } from "fp-ts/Magma"; + * + * const m1: Magma = { concat: (x: number, y: number) => x + y }; + * assert.deepStrictEqual(union(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4, b: 2, c: 3 }); + * const m2: Magma = { concat: (x: number) => x }; + * assert.deepStrictEqual(union(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 }); + * + * @since 2.11.0 + */ +var union = function (M) { + return function (second) { + return function (first) { + if ((0, exports.isEmpty)(first)) { + return second; + } + if ((0, exports.isEmpty)(second)) { + return first; + } + var out = {}; + for (var k in first) { + if ((0, exports.has)(k, second)) { + out[k] = M.concat(first[k], second[k]); + } + else { + out[k] = first[k]; + } + } + for (var k in second) { + if (!(0, exports.has)(k, out)) { + out[k] = second[k]; + } + } + return out; + }; + }; +}; +exports.union = union; +/** + * Intersection of two `ReadonlyRecord`s. + * Takes two `ReadonlyRecord`s and produces a `ReadonlyRecord` combining only the + * entries of the two inputswith the same key. + * It uses the `concat` function of the provided `Magma` to + * combine the elements. + * + * @example + * import { intersection } from "fp-ts/ReadonlyRecord"; + * import { Magma } from "fp-ts/Magma"; + * + * const m1: Magma = { concat: (x: number, y: number) => x + y }; + * assert.deepStrictEqual(intersection(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4}); + * const m2: Magma = { concat: (x: number) => x }; + * assert.deepStrictEqual(intersection(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1}); + * + * @since 2.11.0 + */ +var intersection = function (M) { + return function (second) { + return function (first) { + if ((0, exports.isEmpty)(first) || (0, exports.isEmpty)(second)) { + return exports.empty; + } + var out = {}; + for (var k in first) { + if ((0, exports.has)(k, second)) { + out[k] = M.concat(first[k], second[k]); + } + } + return out; + }; + }; +}; +exports.intersection = intersection; +/** + * Difference between two `ReadonlyRecord`s. + * Takes two `ReadonlyRecord`s and produces a `ReadonlyRecord` composed by the + * entries of the two inputs, removing the entries with the same + * key in both inputs. + * + * @example + * import { difference } from "fp-ts/ReadonlyRecord"; + * + * assert.deepStrictEqual(difference({ a: 1 })({ a: 1, b: 2 }), { b: 2 }); + * assert.deepStrictEqual(difference({ a: 3 })({ a: 1, b: 2 }), { b: 2 }); + * assert.deepStrictEqual(difference({ a: 3, c: 3 })({ a: 1, b: 2 }), { b: 2, c: 3 }); + * + * @since 2.11.0 + */ +var difference = function (second) { + return function (first) { + if ((0, exports.isEmpty)(first)) { + return second; + } + if ((0, exports.isEmpty)(second)) { + return first; + } + var out = {}; + for (var k in first) { + if (!(0, exports.has)(k, second)) { + out[k] = first[k]; + } + } + for (var k in second) { + if (!(0, exports.has)(k, first)) { + out[k] = second[k]; + } + } + return out; + }; +}; +exports.difference = difference; +/** @internal */ +var _map = function (fa, f) { return (0, function_1.pipe)(fa, map(f)); }; +exports._map = _map; +/** @internal */ /* istanbul ignore next */ -var reduce_ = function (fa, b, f) { return function_1.pipe(fa, exports.reduce(b, f)); }; +var _mapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, mapWithIndex(f)); }; +exports._mapWithIndex = _mapWithIndex; +/** @internal */ /* istanbul ignore next */ -var foldMap_ = function (M) { - var foldMapM = exports.foldMap(M); - return function (fa, f) { return function_1.pipe(fa, foldMapM(f)); }; +var _reduce = function (O) { + var reduceO = reduce(O); + return function (fa, b, f) { return (0, function_1.pipe)(fa, reduceO(b, f)); }; }; +exports._reduce = _reduce; +/** @internal */ +var _foldMap = function (O) { return function (M) { + var foldMapM = foldMap(O)(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapM(f)); }; +}; }; +exports._foldMap = _foldMap; +/** @internal */ /* istanbul ignore next */ -var reduceRight_ = function (fa, b, f) { return function_1.pipe(fa, exports.reduceRight(b, f)); }; -/* istanbul ignore next */ -var traverse_ = function (F) { - var traverseF = traverse(F); - return function (ta, f) { return function_1.pipe(ta, traverseF(f)); }; +var _reduceRight = function (O) { + var reduceRightO = reduceRight(O); + return function (fa, b, f) { return (0, function_1.pipe)(fa, reduceRightO(b, f)); }; }; +exports._reduceRight = _reduceRight; +/** @internal */ /* istanbul ignore next */ -var filter_ = function (fa, predicate) { - return function_1.pipe(fa, exports.filter(predicate)); +var _filter = function (fa, predicate) { + return (0, function_1.pipe)(fa, (0, exports.filter)(predicate)); }; +exports._filter = _filter; +/** @internal */ /* istanbul ignore next */ -var filterMap_ = function (fa, f) { return function_1.pipe(fa, exports.filterMap(f)); }; +var _filterMap = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.filterMap)(f)); }; +exports._filterMap = _filterMap; +/** @internal */ /* istanbul ignore next */ -var partition_ = function (fa, predicate) { return function_1.pipe(fa, exports.partition(predicate)); }; +var _partition = function (fa, predicate) { return (0, function_1.pipe)(fa, (0, exports.partition)(predicate)); }; +exports._partition = _partition; +/** @internal */ /* istanbul ignore next */ -var partitionMap_ = function (fa, f) { return function_1.pipe(fa, exports.partitionMap(f)); }; +var _partitionMap = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.partitionMap)(f)); }; +exports._partitionMap = _partitionMap; +/** @internal */ /* istanbul ignore next */ -var reduceWithIndex_ = function (fa, b, f) { - return function_1.pipe(fa, reduceWithIndex(b, f)); +var _reduceWithIndex = function (O) { + var reduceWithIndexO = reduceWithIndex(O); + return function (fa, b, f) { return (0, function_1.pipe)(fa, reduceWithIndexO(b, f)); }; }; -/* istanbul ignore next */ -var foldMapWithIndex_ = function (M) { - var foldMapWithIndexM = foldMapWithIndex(M); - return function (fa, f) { return function_1.pipe(fa, foldMapWithIndexM(f)); }; +exports._reduceWithIndex = _reduceWithIndex; +/** @internal */ +var _foldMapWithIndex = function (O) { + var foldMapWithIndexO = foldMapWithIndex(O); + return function (M) { + var foldMapWithIndexM = foldMapWithIndexO(M); + return function (fa, f) { return (0, function_1.pipe)(fa, foldMapWithIndexM(f)); }; + }; }; +exports._foldMapWithIndex = _foldMapWithIndex; +/** @internal */ /* istanbul ignore next */ -var reduceRightWithIndex_ = function (fa, b, f) { - return function_1.pipe(fa, reduceRightWithIndex(b, f)); +var _reduceRightWithIndex = function (O) { + var reduceRightWithIndexO = reduceRightWithIndex(O); + return function (fa, b, f) { return (0, function_1.pipe)(fa, reduceRightWithIndexO(b, f)); }; }; +exports._reduceRightWithIndex = _reduceRightWithIndex; +/** @internal */ /* istanbul ignore next */ -var partitionMapWithIndex_ = function (fa, f) { return function_1.pipe(fa, partitionMapWithIndex(f)); }; +var _partitionMapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, partitionMapWithIndex(f)); }; +exports._partitionMapWithIndex = _partitionMapWithIndex; +/** @internal */ /* istanbul ignore next */ -var partitionWithIndex_ = function (fa, predicateWithIndex) { - return function_1.pipe(fa, partitionWithIndex(predicateWithIndex)); +var _partitionWithIndex = function (fa, predicateWithIndex) { + return (0, function_1.pipe)(fa, partitionWithIndex(predicateWithIndex)); }; +exports._partitionWithIndex = _partitionWithIndex; +/** @internal */ /* istanbul ignore next */ -var filterMapWithIndex_ = function (fa, f) { - return function_1.pipe(fa, filterMapWithIndex(f)); -}; -/* istanbul ignore next */ -var filterWithIndex_ = function (fa, predicateWithIndex) { - return function_1.pipe(fa, filterWithIndex(predicateWithIndex)); -}; +var _filterMapWithIndex = function (fa, f) { return (0, function_1.pipe)(fa, filterMapWithIndex(f)); }; +exports._filterMapWithIndex = _filterMapWithIndex; +/** @internal */ /* istanbul ignore next */ -var traverseWithIndex_ = function (F) { - var traverseWithIndexF = traverseWithIndex(F); - return function (ta, f) { return function_1.pipe(ta, traverseWithIndexF(f)); }; +var _filterWithIndex = function (fa, predicateWithIndex) { return (0, function_1.pipe)(fa, filterWithIndex(predicateWithIndex)); }; +exports._filterWithIndex = _filterWithIndex; +/** @internal */ +var _traverse = function (O) { + var traverseWithIndexO = _traverseWithIndex(O); + return function (F) { + var traverseWithIndexOF = traverseWithIndexO(F); + return function (ta, f) { return traverseWithIndexOF(ta, (0, function_1.flow)(function_1.SK, f)); }; + }; }; -/* istanbul ignore next */ -var wither_ = function (F) { - var witherF = exports.wither(F); - return function (fa, f) { return function_1.pipe(fa, witherF(f)); }; +exports._traverse = _traverse; +/** @internal */ +var _sequence = function (O) { + var traverseO = (0, exports._traverse)(O); + return function (F) { + var traverseOF = traverseO(F); + return function (ta) { return traverseOF(ta, function_1.identity); }; + }; }; -/* istanbul ignore next */ -var wilt_ = function (F) { - var wiltF = exports.wilt(F); - return function (fa, f) { return function_1.pipe(fa, wiltF(f)); }; +exports._sequence = _sequence; +var _traverseWithIndex = function (O) { + return function (F) { + var keysO = keys_(O); + return function (ta, f) { + var ks = keysO(ta); + if (ks.length === 0) { + return F.of(exports.empty); + } + var fr = F.of({}); + var _loop_1 = function (key) { + fr = F.ap(F.map(fr, function (r) { return function (b) { + var _a; + return Object.assign({}, r, (_a = {}, _a[key] = b, _a)); + }; }), f(key, ta[key])); + }; + for (var _i = 0, ks_1 = ks; _i < ks_1.length; _i++) { + var key = ks_1[_i]; + _loop_1(key); + } + return fr; + }; + }; }; -// ------------------------------------------------------------------------------------- -// pipeables -// ------------------------------------------------------------------------------------- /** - * @category Filterable + * Given a `Predicate`, it produces a new `ReadonlyRecord` keeping only the entries with a + * value that satisfies the provided predicate. + * + * @example + * import { filter } from "fp-ts/ReadonlyRecord" + * + * assert.deepStrictEqual(filter((s: string) => s.length < 4)({ a: "foo", b: "bar", c: "verylong" }), { + * a: "foo", + * b: "bar", + * }); + * + * @category filtering * @since 2.5.0 */ var filter = function (predicate) { @@ -14700,13 +19753,41 @@ var filter = function (predicate) { }; exports.filter = filter; /** - * @category Filterable + * Maps a `ReadonlyRecord` with an iterating function that returns an `Option` + * and it keeps only the `Some` values discarding the `None`s. + * + * @example + * import { filterMap } from "fp-ts/ReadonlyRecord" + * import { option } from "fp-ts" + * + * const f = (s: string) => s.length < 4 ? option.some(`${s} is short`): option.none + * assert.deepStrictEqual(filterMap(f)({ a: "foo", b: "bar", c: "verylong" }), { + * a: "foo is short", + * b: "bar is short", + * }); + * + * @category filtering * @since 2.5.0 */ var filterMap = function (f) { return filterMapWithIndex(function (_, a) { return f(a); }); }; exports.filterMap = filterMap; /** - * @category Filterable + * Partition a `ReadonlyRecord` into two parts according to a `Predicate`. + * + * @example + * import { partition } from "fp-ts/ReadonlyRecord" + * + * assert.deepStrictEqual(partition((s: string) => s.length < 4)({ a: "foo", b: "bar", c: "verylong" }), { + * left:{ + * c: "verylong" + * }, + * right: { + * a: "foo", + * b: "bar", + * }, + * }); + * + * @category filtering * @since 2.5.0 */ var partition = function (predicate) { @@ -14714,129 +19795,243 @@ var partition = function (predicate) { }; exports.partition = partition; /** - * @category Filterable + * Maps a `ReadonlyRecord` with a function returning an `Either` and + * partitions the resulting `ReadonlyRecord` into `Left`s and `Right`s. + * + * @example + * import { partitionMap } from "fp-ts/ReadonlyRecord" + * import { either } from "fp-ts" + * + * const f = (s: string) => (s.length < 4 ? either.right(`${s} is short`) : either.left(`${s} is not short`)); + * assert.deepStrictEqual(partitionMap(f)({ a: "foo", b: "bar", c: "verylong" }), { + * left: { + * c: "verylong is not short", + * }, + * right: { + * a: "foo is short", + * b: "bar is short", + * }, + * }); + * + * @category filtering * @since 2.5.0 */ var partitionMap = function (f) { return partitionMapWithIndex(function (_, a) { return f(a); }); }; exports.partitionMap = partitionMap; -/** - * @category Foldable - * @since 2.5.0 - */ -var reduce = function (b, f) { - return reduceWithIndex(b, function (_, b, a) { return f(b, a); }); -}; +function reduce() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (args.length === 1) { + var reduceWithIndexO_1 = reduceWithIndex(args[0]); + return function (b, f) { return reduceWithIndexO_1(b, function (_, b, a) { return f(b, a); }); }; + } + return reduce(S.Ord).apply(void 0, args); +} exports.reduce = reduce; -/** - * @category Foldable - * @since 2.5.0 - */ -var foldMap = function (M) { - var foldMapWithIndexM = foldMapWithIndex(M); - return function (f) { return foldMapWithIndexM(function (_, a) { return f(a); }); }; -}; +function foldMap(O) { + if ('compare' in O) { + var foldMapWithIndexO_1 = foldMapWithIndex(O); + return function (M) { + var foldMapWithIndexM = foldMapWithIndexO_1(M); + return function (f) { return foldMapWithIndexM(function (_, a) { return f(a); }); }; + }; + } + return foldMap(S.Ord)(O); +} exports.foldMap = foldMap; -/** - * @category Foldable - * @since 2.5.0 - */ -var reduceRight = function (b, f) { - return reduceRightWithIndex(b, function (_, a, b) { return f(a, b); }); -}; +function reduceRight() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (args.length === 1) { + var reduceRightWithIndexO_1 = reduceRightWithIndex(args[0]); + return function (b, f) { return reduceRightWithIndexO_1(b, function (_, b, a) { return f(b, a); }); }; + } + return reduceRight(S.Ord).apply(void 0, args); +} exports.reduceRight = reduceRight; /** - * @category Compactable + * Compact a `ReadonlyRecord` of `Option`s discarding the `None` values and + * keeping the `Some` values. + * + * @example + * import { compact } from 'fp-ts/ReadonlyRecord' + * import { option } from 'fp-ts' + * + * assert.deepStrictEqual(compact({ a: option.some("foo"), b: option.none, c: option.some("bar") }), { + * a: "foo", + * c: "bar", + * }); + * + * @category filtering * @since 2.5.0 */ -var compact = function (fa) { - var r = {}; - var keys = Object.keys(fa); - for (var _i = 0, keys_5 = keys; _i < keys_5.length; _i++) { - var key = keys_5[_i]; - var optionA = fa[key]; - if (Option_1.isSome(optionA)) { - r[key] = optionA.value; +var compact = function (r) { + var out = {}; + for (var k in r) { + if (_.has.call(r, k)) { + var oa = r[k]; + if (_.isSome(oa)) { + out[k] = oa.value; + } } } - return r; + return out; }; exports.compact = compact; /** - * @category Compactable + * Separate a `ReadonlyRecord` of `Either`s into `Left`s and `Right`s. + * + * @example + * import { separate } from 'fp-ts/ReadonlyRecord' + * import { either } from 'fp-ts' + * + * assert.deepStrictEqual( + * separate({ a: either.right("foo"), b: either.left("bar"), c: either.right("baz") }), + * { + * right: { + * a: "foo", + * c: "baz", + * }, + * left: { + * b: "bar", + * }, + * } + * ); + * + * @category filtering * @since 2.5.0 */ -var separate = function (fa) { +var separate = function (r) { var left = {}; var right = {}; - var keys = Object.keys(fa); - for (var _i = 0, keys_6 = keys; _i < keys_6.length; _i++) { - var key = keys_6[_i]; - var e = fa[key]; - switch (e._tag) { - case 'Left': - left[key] = e.left; - break; - case 'Right': - right[key] = e.right; - break; + for (var k in r) { + if (_.has.call(r, k)) { + var e = r[k]; + if (_.isLeft(e)) { + left[k] = e.left; + } + else { + right[k] = e.right; + } } } - return { - left: left, - right: right - }; + return (0, Separated_1.separated)(left, right); }; exports.separate = separate; -// ------------------------------------------------------------------------------------- -// instances -// ------------------------------------------------------------------------------------- /** - * @category instances + * @category type lambdas * @since 2.5.0 */ exports.URI = 'ReadonlyRecord'; +function getShow(O) { + if ('compare' in O) { + return function (S) { return ({ + show: function (r) { + var elements = collect(O)(function (k, a) { return "".concat(JSON.stringify(k), ": ").concat(S.show(a)); })(r).join(', '); + return elements === '' ? '{}' : "{ ".concat(elements, " }"); + } + }); }; + } + return getShow(S.Ord)(O); +} +exports.getShow = getShow; +function getEq(E) { + var isSubrecordE = isSubrecord(E); + return (0, Eq_1.fromEquals)(function (x, y) { return isSubrecordE(x)(y) && isSubrecordE(y)(x); }); +} +exports.getEq = getEq; +function getMonoid(S) { + return { + concat: function (first, second) { + if ((0, exports.isEmpty)(first)) { + return second; + } + if ((0, exports.isEmpty)(second)) { + return first; + } + var r = Object.assign({}, first); + for (var k in second) { + if (_.has.call(second, k)) { + r[k] = _.has.call(first, k) ? S.concat(first[k], second[k]) : second[k]; + } + } + return r; + }, + empty: exports.empty + }; +} +exports.getMonoid = getMonoid; /** * @category instances * @since 2.7.0 */ exports.Functor = { URI: exports.URI, - map: map_ + map: exports._map }; +/** + * Takes a value and a `ReadonlyRecord` of functions and returns a + * `ReadonlyRecord` by applying each function to the input value. + * + * @example + * import { flap } from "fp-ts/ReadonlyRecord" + * + * const fab = { x: (n: number) => `${n} times 2`, y: (n: number) => `${n * 2}` }; + * assert.deepStrictEqual(flap(3)(fab), { + * x: "3 times 2", + * y: "6", + * }); + * + * @category mapping + * @since 2.10.0 + */ +exports.flap = (0, Functor_1.flap)(exports.Functor); /** * @category instances * @since 2.7.0 */ exports.FunctorWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_ + map: exports._map, + mapWithIndex: exports._mapWithIndex }; /** - * @category instances - * @since 2.7.0 + * Produces a `Foldable` instance for a `ReadonlyRecord`, using the + * provided `Ord` to sort the `ReadonlyRecord`'s entries by key. + * + * @category folding + * @since 2.11.0 */ -exports.Foldable = { +var getFoldable = function (O) { return ({ URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_ -}; + reduce: (0, exports._reduce)(O), + foldMap: (0, exports._foldMap)(O), + reduceRight: (0, exports._reduceRight)(O) +}); }; +exports.getFoldable = getFoldable; /** - * @category instances - * @since 2.7.0 + * Produces a `FoldableWithIndex1` instance for a `ReadonlyRecord`, using the + * provided `Ord` to sort the `ReadonlyRecord`'s entries by key. + * + * @category folding + * @since 2.11.0 */ -exports.FoldableWithIndex = { +var getFoldableWithIndex = function (O) { return ({ URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_ -}; + reduce: (0, exports._reduce)(O), + foldMap: (0, exports._foldMap)(O), + reduceRight: (0, exports._reduceRight)(O), + reduceWithIndex: (0, exports._reduceWithIndex)(O), + foldMapWithIndex: (0, exports._foldMapWithIndex)(O), + reduceRightWithIndex: (0, exports._reduceRightWithIndex)(O) +}); }; +exports.getFoldableWithIndex = getFoldableWithIndex; /** * @category instances * @since 2.7.0 @@ -14852,13 +20047,13 @@ exports.Compactable = { */ exports.Filterable = { URI: exports.URI, - map: map_, + map: exports._map, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_ + filter: exports._filter, + filterMap: exports._filterMap, + partition: exports._partition, + partitionMap: exports._partitionMap }; /** * @category instances @@ -14866,101 +20061,315 @@ exports.Filterable = { */ exports.FilterableWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, + map: exports._map, + mapWithIndex: exports._mapWithIndex, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - filterMapWithIndex: filterMapWithIndex_, - filterWithIndex: filterWithIndex_, - partitionMapWithIndex: partitionMapWithIndex_, - partitionWithIndex: partitionWithIndex_ + filter: exports._filter, + filterMap: exports._filterMap, + partition: exports._partition, + partitionMap: exports._partitionMap, + filterMapWithIndex: exports._filterMapWithIndex, + filterWithIndex: exports._filterWithIndex, + partitionMapWithIndex: exports._partitionMapWithIndex, + partitionWithIndex: exports._partitionWithIndex +}; +/** + * Produces a `Traversable` instance for a `ReadonlyRecord`, using the + * provided `Ord` to sort the `ReadonlyRecord`'s entries by key. + * + * @category traversing + * @since 2.11.0 + */ +var getTraversable = function (O) { return ({ + URI: exports.URI, + map: exports._map, + reduce: (0, exports._reduce)(O), + foldMap: (0, exports._foldMap)(O), + reduceRight: (0, exports._reduceRight)(O), + traverse: (0, exports._traverse)(O), + sequence: (0, exports._sequence)(O) +}); }; +exports.getTraversable = getTraversable; +/** + * Produces a `TraversableWithIndex` instance for a `ReadonlyRecord`, using the + * provided `Ord` to sort the `ReadonlyRecord`'s entries by key. + * + * @category traversing + * @since 2.11.0 + */ +var getTraversableWithIndex = function (O) { return ({ + URI: exports.URI, + map: exports._map, + mapWithIndex: exports._mapWithIndex, + reduce: (0, exports._reduce)(O), + foldMap: (0, exports._foldMap)(O), + reduceRight: (0, exports._reduceRight)(O), + reduceWithIndex: (0, exports._reduceWithIndex)(O), + foldMapWithIndex: (0, exports._foldMapWithIndex)(O), + reduceRightWithIndex: (0, exports._reduceRightWithIndex)(O), + traverse: (0, exports._traverse)(O), + sequence: (0, exports._sequence)(O), + traverseWithIndex: _traverseWithIndex(O) +}); }; +exports.getTraversableWithIndex = getTraversableWithIndex; +/** + * @category filtering + * @since 2.11.0 + */ +var getWitherable = function (O) { + var T = (0, exports.getTraversable)(O); + return { + URI: exports.URI, + map: exports._map, + reduce: (0, exports._reduce)(O), + foldMap: (0, exports._foldMap)(O), + reduceRight: (0, exports._reduceRight)(O), + traverse: T.traverse, + sequence: T.sequence, + compact: exports.compact, + separate: exports.separate, + filter: exports._filter, + filterMap: exports._filterMap, + partition: exports._partition, + partitionMap: exports._partitionMap, + wither: (0, Witherable_1.witherDefault)(T, exports.Compactable), + wilt: (0, Witherable_1.wiltDefault)(T, exports.Compactable) + }; +}; +exports.getWitherable = getWitherable; +/** + * Given a `Semigroup` in the base type, it produces a `Semigroup` + * in the `ReadonlyRecord` of the base type. + * The resulting `Semigroup` concatenates two `ReadonlyRecord`s by + * `union`. + * + * @example + * import { getUnionSemigroup, ReadonlyRecord } from "fp-ts/ReadonlyRecord" + * import { Semigroup } from "fp-ts/Semigroup" + * + * const sNumber: Semigroup = { concat: (x, y) => x - y }; + * const sReadonlyRecord: Semigroup> = getUnionSemigroup(sNumber); + * assert.deepStrictEqual(sReadonlyRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { a: 1, b: -1, c: 4 }); + * + * @category instances + * @since 2.11.0 + */ +var getUnionSemigroup = function (S) { + var unionS = (0, exports.union)(S); + return { + concat: function (first, second) { return unionS(second)(first); } + }; +}; +exports.getUnionSemigroup = getUnionSemigroup; +/** + * Same as `getMonoid`. + * Returns a `Monoid` instance for `ReadonlyRecord`s given a `Semigroup` + * instance for the base type. + * The `Monoid` makes the union of two `ReadonlyRecord`s combining the + * entries that have the same key with the provided `Semigroup`. + * + * @example + * import { SemigroupSum } from 'fp-ts/number' + * import { getUnionMonoid } from 'fp-ts/ReadonlyRecord' + * + * const M = getUnionMonoid(SemigroupSum); + * assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579 , bar: 234, baz: 567 }); + * + * @category instances + * @since 2.11.0 + */ +var getUnionMonoid = function (S) { return ({ + concat: (0, exports.getUnionSemigroup)(S).concat, + empty: exports.empty +}); }; +exports.getUnionMonoid = getUnionMonoid; +/** + * Given a `Semigroup` in the base type, it produces a `Semigroup` + * in the `ReadonlyRecord` of the base type. + * The resulting `Semigroup` concatenates two `ReadonlyRecord`s by + * `intersection`. + * + * @example + * import { getIntersectionSemigroup, ReadonlyRecord } from "fp-ts/ReadonlyRecord" + * import { Semigroup } from "fp-ts/Semigroup" + * + * const sNumber: Semigroup = { concat: (x, y) => x - y }; + * const sReadonlyRecord: Semigroup> = getIntersectionSemigroup(sNumber); + * assert.deepStrictEqual(sReadonlyRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { b: -1 }); + * + * @category instances + * @since 2.11.0 + */ +var getIntersectionSemigroup = function (S) { + var intersectionS = (0, exports.intersection)(S); + return { + concat: function (first, second) { return intersectionS(second)(first); } + }; }; +exports.getIntersectionSemigroup = getIntersectionSemigroup; /** + * Produces a `Magma` with a `concat` function that combines + * two `ReadonlyRecord`s by making the `difference`. + * + * @example + * import { getDifferenceMagma, difference, ReadonlyRecord } from "fp-ts/ReadonlyRecord" + * import { Magma } from "fp-ts/Magma" + * + * const r1 = { a: 3, c: 3 }; + * const r2 = { a: 1, b: 2 }; + * const m: Magma> = getDifferenceMagma(); + * assert.deepStrictEqual(m.concat(r1, r2), difference(r2)(r1)); + * assert.deepStrictEqual(m.concat(r1, r2), { c: 3, b: 2 }); + * * @category instances + * @since 2.11.0 + */ +var getDifferenceMagma = function () { return ({ + concat: function (first, second) { return (0, exports.difference)(second)(first); } +}); }; +exports.getDifferenceMagma = getDifferenceMagma; +// ------------------------------------------------------------------------------------- +// deprecated +// ------------------------------------------------------------------------------------- +/** + * Use `getFoldable` instead. + * + * @category zone of death + * @since 2.7.0 + * @deprecated + */ +exports.Foldable = { + URI: exports.URI, + reduce: /*#__PURE__*/ (0, exports._reduce)(S.Ord), + foldMap: /*#__PURE__*/ (0, exports._foldMap)(S.Ord), + reduceRight: /*#__PURE__*/ (0, exports._reduceRight)(S.Ord) +}; +/** + * Use `getFoldableWithIndex` instead. + * + * @category zone of death + * @since 2.7.0 + * @deprecated + */ +exports.FoldableWithIndex = { + URI: exports.URI, + reduce: /*#__PURE__*/ (0, exports._reduce)(S.Ord), + foldMap: /*#__PURE__*/ (0, exports._foldMap)(S.Ord), + reduceRight: /*#__PURE__*/ (0, exports._reduceRight)(S.Ord), + reduceWithIndex: /*#__PURE__*/ (0, exports._reduceWithIndex)(S.Ord), + foldMapWithIndex: /*#__PURE__*/ (0, exports._foldMapWithIndex)(S.Ord), + reduceRightWithIndex: /*#__PURE__*/ (0, exports._reduceRightWithIndex)(S.Ord) +}; +/** + * Use `getTraversable` instead. + * + * @category zone of death * @since 2.7.0 + * @deprecated */ exports.Traversable = { URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: exports._map, + reduce: /*#__PURE__*/ (0, exports._reduce)(S.Ord), + foldMap: /*#__PURE__*/ (0, exports._foldMap)(S.Ord), + reduceRight: /*#__PURE__*/ (0, exports._reduceRight)(S.Ord), + traverse: /*#__PURE__*/ (0, exports._traverse)(S.Ord), sequence: sequence }; /** - * @category instances + * Use `getTraversableWithIndex` instead. + * + * @category zone of death * @since 2.7.0 + * @deprecated */ exports.TraversableWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverse: traverse_, + map: exports._map, + mapWithIndex: exports._mapWithIndex, + reduce: /*#__PURE__*/ (0, exports._reduce)(S.Ord), + foldMap: /*#__PURE__*/ (0, exports._foldMap)(S.Ord), + reduceRight: /*#__PURE__*/ (0, exports._reduceRight)(S.Ord), + reduceWithIndex: /*#__PURE__*/ (0, exports._reduceWithIndex)(S.Ord), + foldMapWithIndex: /*#__PURE__*/ (0, exports._foldMapWithIndex)(S.Ord), + reduceRightWithIndex: /*#__PURE__*/ (0, exports._reduceRightWithIndex)(S.Ord), + traverse: /*#__PURE__*/ (0, exports._traverse)(S.Ord), sequence: sequence, - traverseWithIndex: traverseWithIndex_ + traverseWithIndex: /*#__PURE__*/ _traverseWithIndex(S.Ord) }; +var _wither = /*#__PURE__*/ (0, Witherable_1.witherDefault)(exports.Traversable, exports.Compactable); +var _wilt = /*#__PURE__*/ (0, Witherable_1.wiltDefault)(exports.Traversable, exports.Compactable); /** - * @category instances + * Use `getWitherable` instead. + * + * @category zone of death * @since 2.7.0 + * @deprecated */ exports.Witherable = { URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: exports._map, + reduce: /*#__PURE__*/ (0, exports._reduce)(S.Ord), + foldMap: /*#__PURE__*/ (0, exports._foldMap)(S.Ord), + reduceRight: /*#__PURE__*/ (0, exports._reduceRight)(S.Ord), + traverse: /*#__PURE__*/ (0, exports._traverse)(S.Ord), sequence: sequence, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - wither: wither_, - wilt: wilt_ + filter: exports._filter, + filterMap: exports._filterMap, + partition: exports._partition, + partitionMap: exports._partitionMap, + wither: _wither, + wilt: _wilt }; -// TODO: remove in v3 /** - * @category instances + * Use [`upsertAt`](#upsertat) instead. + * + * @category zone of death + * @since 2.5.0 + * @deprecated + */ +exports.insertAt = exports.upsertAt; +function hasOwnProperty(k, r) { + return _.has.call(r === undefined ? this : r, k); +} +exports.hasOwnProperty = hasOwnProperty; +/** + * This instance is deprecated, use small, specific instances instead. + * For example if a function needs a `Functor` instance, pass `RR.Functor` instead of `RR.readonlyRecord` + * (where `RR` is from `import RR from 'fp-ts/ReadonlyRecord'`) + * + * @category zone of death * @since 2.5.0 + * @deprecated */ exports.readonlyRecord = { URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: exports._map, + reduce: /*#__PURE__*/ (0, exports._reduce)(S.Ord), + foldMap: /*#__PURE__*/ (0, exports._foldMap)(S.Ord), + reduceRight: /*#__PURE__*/ (0, exports._reduceRight)(S.Ord), + traverse: /*#__PURE__*/ (0, exports._traverse)(S.Ord), sequence: sequence, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - mapWithIndex: mapWithIndex_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - filterMapWithIndex: filterMapWithIndex_, - filterWithIndex: filterWithIndex_, - partitionMapWithIndex: partitionMapWithIndex_, - partitionWithIndex: partitionWithIndex_, - traverseWithIndex: traverseWithIndex_, - wither: wither_, - wilt: wilt_ + filter: exports._filter, + filterMap: exports._filterMap, + partition: exports._partition, + partitionMap: exports._partitionMap, + mapWithIndex: exports._mapWithIndex, + reduceWithIndex: /*#__PURE__*/ (0, exports._reduceWithIndex)(S.Ord), + foldMapWithIndex: /*#__PURE__*/ (0, exports._foldMapWithIndex)(S.Ord), + reduceRightWithIndex: /*#__PURE__*/ (0, exports._reduceRightWithIndex)(S.Ord), + filterMapWithIndex: exports._filterMapWithIndex, + filterWithIndex: exports._filterWithIndex, + partitionMapWithIndex: exports._partitionMapWithIndex, + partitionWithIndex: exports._partitionWithIndex, + traverseWithIndex: /*#__PURE__*/ _traverseWithIndex(S.Ord), + wither: _wither, + wilt: _wilt }; @@ -14971,9 +20380,24 @@ exports.readonlyRecord = { "use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -14991,128 +20415,292 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.FunctorWithIndex = exports.Functor = exports.URI = exports.separate = exports.compact = exports.reduceRight = exports.reduce = exports.partitionMap = exports.partition = exports.foldMap = exports.filterMap = exports.filter = exports.elem = exports.some = exports.every = exports.fromFoldableMap = exports.fromFoldable = exports.filterWithIndex = exports.filterMapWithIndex = exports.partitionWithIndex = exports.partitionMapWithIndex = exports.wilt = exports.wither = exports.sequence = exports.traverse = exports.traverseWithIndex = exports.singleton = exports.reduceRightWithIndex = exports.foldMapWithIndex = exports.reduceWithIndex = exports.map = exports.mapWithIndex = exports.empty = exports.lookup = exports.getMonoid = exports.getEq = exports.isSubrecord = exports.pop = exports.modifyAt = exports.updateAt = exports.deleteAt = exports.hasOwnProperty = exports.insertAt = exports.toUnfoldable = exports.toArray = exports.collect = exports.keys = exports.isEmpty = exports.size = exports.getShow = void 0; -exports.record = exports.Witherable = exports.TraversableWithIndex = exports.Traversable = exports.FilterableWithIndex = exports.Filterable = exports.Compactable = exports.FoldableWithIndex = exports.Foldable = void 0; +exports.getShow = exports.URI = exports.separate = exports.compact = exports.reduceRight = exports.foldMap = exports.reduce = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports.difference = exports.intersection = exports.union = exports.elem = exports.some = exports.every = exports.fromFoldableMap = exports.fromEntries = exports.toEntries = exports.fromFoldable = exports.filterWithIndex = exports.filterMapWithIndex = exports.partitionWithIndex = exports.partitionMapWithIndex = exports.wilt = exports.wither = exports.sequence = exports.traverse = exports.traverseWithIndex = exports.singleton = exports.reduceRightWithIndex = exports.foldMapWithIndex = exports.reduceWithIndex = exports.map = exports.mapWithIndex = exports.lookup = exports.isSubrecord = exports.pop = exports.modifyAt = exports.updateAt = exports.deleteAt = exports.has = exports.upsertAt = exports.toUnfoldable = exports.toArray = exports.collect = exports.keys = exports.isEmpty = exports.size = void 0; +exports.record = exports.hasOwnProperty = exports.insertAt = exports.empty = exports.Witherable = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.getDifferenceMagma = exports.getIntersectionSemigroup = exports.getUnionMonoid = exports.getUnionSemigroup = exports.getWitherable = exports.getTraversableWithIndex = exports.getTraversable = exports.FilterableWithIndex = exports.Filterable = exports.Compactable = exports.getFoldableWithIndex = exports.getFoldable = exports.FunctorWithIndex = exports.flap = exports.Functor = exports.getMonoid = exports.getEq = void 0; +var A = __importStar(__nccwpck_require__(3834)); +var function_1 = __nccwpck_require__(6985); +var Functor_1 = __nccwpck_require__(5533); +var _ = __importStar(__nccwpck_require__(1840)); var RR = __importStar(__nccwpck_require__(1897)); -/* tslint:disable:readonly-array */ +var Se = __importStar(__nccwpck_require__(6339)); +var S = __importStar(__nccwpck_require__(5189)); +var Witherable_1 = __nccwpck_require__(4384); // ------------------------------------------------------------------------------------- // model // ------------------------------------------------------------------------------------- /** - * @since 2.0.0 - */ -exports.getShow = RR.getShow; -/** - * Calculate the number of key/value pairs in a record + * Calculate the number of key/value pairs in a `Record`. + * + * @example + * import { size } from "fp-ts/Record"; + * + * assert.deepStrictEqual(size({ a: true, b: 2, c: "three" }), 3); * * @since 2.0.0 */ exports.size = RR.size; /** - * Test whether a record is empty + * Test whether a `Record` is empty. + * + * @example + * import { isEmpty } from "fp-ts/Record"; + * + * assert.deepStrictEqual(isEmpty({}), true); + * assert.deepStrictEqual(isEmpty({ a: 3 }), false); * * @since 2.0.0 */ exports.isEmpty = RR.isEmpty; +var keys_ = function (O) { + return function (r) { + return Object.keys(r).sort(O.compare); + }; +}; /** - * @since 2.0.0 - */ -exports.keys = RR.keys; -/** - * Map a record into an array + * The keys of a `Record`, sorted alphabetically. * * @example - * import {collect} from 'fp-ts/Record' + * import { keys } from "fp-ts/Record"; * - * const x: { a: string, b: boolean } = { a: 'foo', b: false } - * assert.deepStrictEqual( - * collect((key, val) => ({key: key, value: val}))(x), - * [{key: 'a', value: 'foo'}, {key: 'b', value: false}] - * ) + * assert.deepStrictEqual(keys({ c: 1, a: 2, b: 3 }), ["a", "b", "c"]); * * @since 2.0.0 */ -exports.collect = RR.collect; +exports.keys = keys_(S.Ord); +function collect(O) { + if (typeof O === 'function') { + return collect(S.Ord)(O); + } + var keysO = keys_(O); + return function (f) { + return function (r) { + var out = []; + for (var _i = 0, _a = keysO(r); _i < _a.length; _i++) { + var key = _a[_i]; + out.push(f(key, r[key])); + } + return out; + }; + }; +} +exports.collect = collect; /** + * Get a sorted `Array` of the key/value pairs contained in a `Record`. + * Sorted alphabetically by key. + * + * @example + * import { toArray } from 'fp-ts/Record' + * + * const x = { c: 3, a: "foo", b: false }; + * assert.deepStrictEqual(toArray(x), [ + * ["a", "foo"], + * ["b", false], + * ["c", 3], + * ]); + * + * @category conversions * @since 2.0.0 */ -exports.toArray = RR.toReadonlyArray; +exports.toArray = collect(S.Ord)(function (k, a) { return [ + k, + a +]; }); function toUnfoldable(U) { - return RR.toUnfoldable(U); + return function (r) { + var sas = (0, exports.toArray)(r); + var len = sas.length; + return U.unfold(0, function (b) { return (b < len ? _.some([sas[b], b + 1]) : _.none); }); + }; } exports.toUnfoldable = toUnfoldable; -function insertAt(k, a) { - return RR.insertAt(k, a); -} -exports.insertAt = insertAt; /** - * @since 2.0.0 + * Insert or replace a key/value pair in a `Record`. + * + * @example + * import { upsertAt } from 'fp-ts/Record' + * + * assert.deepStrictEqual(upsertAt("a", 5)({ a: 1, b: 2 }), { a: 5, b: 2 }); + * assert.deepStrictEqual(upsertAt("c", 5)({ a: 1, b: 2 }), { a: 1, b: 2, c: 5 }); + * + * @since 2.10.0 */ -exports.hasOwnProperty = RR.hasOwnProperty; +exports.upsertAt = RR.upsertAt; +/** + * Test whether or not a key exists in a `Record`. + * + * Note. This function is not pipeable because is a `Refinement`. + * + * @example + * import { has } from 'fp-ts/Record' + * + * assert.deepStrictEqual(has("a", { a: 1, b: 2 }), true); + * assert.deepStrictEqual(has("c", { a: 1, b: 2 }), false); + * + * @since 2.10.0 + */ +exports.has = RR.has; function deleteAt(k) { - return RR.deleteAt(k); + return function (r) { + if (!_.has.call(r, k)) { + return r; + } + var out = Object.assign({}, r); + delete out[k]; + return out; + }; } exports.deleteAt = deleteAt; /** + * Replace a key/value pair in a `Record`. + * + * @returns If the specified key exists it returns an `Option` containing a new `Record` + * with the entry updated, otherwise it returns `None` + * + * @example + * import { updateAt } from 'fp-ts/Record' + * import { option } from 'fp-ts' + * + * assert.deepStrictEqual(updateAt("a", 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 })); + * assert.deepStrictEqual(updateAt("c", 3)({ a: 1, b: 2 }), option.none); + * * @since 2.0.0 */ -exports.updateAt = RR.updateAt; +var updateAt = function (k, a) { + return (0, exports.modifyAt)(k, function () { return a; }); +}; +exports.updateAt = updateAt; /** + * Applies a mapping function to one spcific key/value pair in a `Record`. + * + * @returns If the specified key exists it returns an `Option` containing a new `Record` + * with the entry updated, otherwise it returns `None` + * + * @example + * import { modifyAt } from 'fp-ts/Record' + * import { option } from 'fp-ts' + * + * assert.deepStrictEqual(modifyAt("a", (x: number) => x * 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 })); + * assert.deepStrictEqual(modifyAt("c", (x: number) => x * 3)({ a: 1, b: 2 }), option.none); + * * @since 2.0.0 */ -exports.modifyAt = RR.modifyAt; +var modifyAt = function (k, f) { + return function (r) { + if (!(0, exports.has)(k, r)) { + return _.none; + } + var out = Object.assign({}, r); + out[k] = f(r[k]); + return _.some(out); + }; +}; +exports.modifyAt = modifyAt; function pop(k) { - return RR.pop(k); + var deleteAtk = deleteAt(k); + return function (r) { + var oa = (0, exports.lookup)(k, r); + return _.isNone(oa) ? _.none : _.some([oa.value, deleteAtk(r)]); + }; } exports.pop = pop; // TODO: remove non-curried overloading in v3 /** - * Test whether one record contains all of the keys and values contained in another record + * Test whether one `Record` contains all of the keys and values + * contained in another `Record`. + * + * @example + * import { isSubrecord } from 'fp-ts/Record' + * import { string } from 'fp-ts' + * + * assert.deepStrictEqual( + * isSubrecord(string.Eq)({ a: "foo", b: "bar", c: "baz" })({ a: "foo", b: "bar", c: "baz" }), + * true + * ); + * assert.deepStrictEqual( + * isSubrecord(string.Eq)({ a: "foo", b: "bar", c: "baz" })({ a: "foo", c: "baz" }), + * true + * ); + * assert.deepStrictEqual( + * isSubrecord(string.Eq)({ a: "foo", b: "bar", c: "baz" })({ a: "foo", b: "not-bar", c: "baz" }), + * false + * ); + * assert.deepStrictEqual( + * isSubrecord(string.Eq)({ a: "foo", b: "bar" })({ a: "foo", b: "bar", c: "baz" }), + * false + * ); * * @since 2.0.0 */ exports.isSubrecord = RR.isSubrecord; -function getEq(E) { - return RR.getEq(E); -} -exports.getEq = getEq; -function getMonoid(S) { - return RR.getMonoid(S); -} -exports.getMonoid = getMonoid; // TODO: remove non-curried overloading in v3 /** - * Lookup the value for a key in a record + * Lookup the value for a key in a `Record`. + * + * @returns If the specified key exists it returns an `Option` containing the value, + * otherwise it returns `None` + * + * @example + * import { lookup } from 'fp-ts/Record' + * import { option } from 'fp-ts' + * + * assert.deepStrictEqual(lookup("b")({ a: "foo", b: "bar" }), option.some("bar")); + * assert.deepStrictEqual(lookup("c")({ a: "foo", b: "bar" }), option.none); * * @since 2.0.0 */ exports.lookup = RR.lookup; /** + * Map a `Record` passing the key/value pairs to the iterating function. + * + * @example + * import { mapWithIndex } from "fp-ts/Record"; + * + * const f = (k: string, n: number) => `${k.toUpperCase()}-${n}`; + * assert.deepStrictEqual(mapWithIndex(f)({ a: 3, b: 5 }), { a: "A-3", b: "B-5" }); + * * @since 2.0.0 */ -exports.empty = {}; -function mapWithIndex(f) { - return RR.mapWithIndex(f); -} -exports.mapWithIndex = mapWithIndex; -function map(f) { - return RR.map(f); -} -exports.map = map; -function reduceWithIndex(b, f) { - return RR.reduceWithIndex(b, f); +exports.mapWithIndex = RR.mapWithIndex; +/** + * Map a `Record` passing the values to the iterating function. + * + * @example + * import { map } from "fp-ts/Record"; + * + * const f = (n: number) => `-${n}-`; + * assert.deepStrictEqual(map(f)({ a: 3, b: 5 }), { a: "-3-", b: "-5-" }); + * + * @category mapping + * @since 2.0.0 + */ +exports.map = RR.map; +function reduceWithIndex() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return args.length === 1 ? RR.reduceWithIndex(args[0]) : RR.reduceWithIndex(S.Ord).apply(void 0, args); } exports.reduceWithIndex = reduceWithIndex; -function foldMapWithIndex(M) { - return RR.foldMapWithIndex(M); +function foldMapWithIndex(O) { + return 'compare' in O ? RR.foldMapWithIndex(O) : RR.foldMapWithIndex(S.Ord)(O); } exports.foldMapWithIndex = foldMapWithIndex; -function reduceRightWithIndex(b, f) { - return RR.reduceRightWithIndex(b, f); +function reduceRightWithIndex() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return args.length === 1 ? RR.reduceRightWithIndex(args[0]) : RR.reduceRightWithIndex(S.Ord).apply(void 0, args); } exports.reduceRightWithIndex = reduceRightWithIndex; /** - * Create a record with one key/value pair + * Create a `Record` with one key/value pair. + * + * @example + * import { singleton } from "fp-ts/Record"; + * + * assert.deepStrictEqual(singleton("a", 1), { a: 1 }); * * @since 2.0.0 */ @@ -15130,27 +20718,67 @@ function sequence(F) { } exports.sequence = sequence; /** - * @category Witherable + * @category filtering * @since 2.6.5 */ -exports.wither = RR.wither; +var wither = function (F) { + var traverseF = traverse(F); + return function (f) { return function (fa) { return F.map((0, function_1.pipe)(fa, traverseF(f)), exports.compact); }; }; +}; +exports.wither = wither; /** - * @category Witherable + * @category filtering * @since 2.6.5 */ -exports.wilt = RR.wilt; -function partitionMapWithIndex(f) { - return RR.partitionMapWithIndex(f); -} -exports.partitionMapWithIndex = partitionMapWithIndex; +var wilt = function (F) { + var traverseF = traverse(F); + return function (f) { return function (fa) { return F.map((0, function_1.pipe)(fa, traverseF(f)), exports.separate); }; }; +}; +exports.wilt = wilt; +/** + * Maps a `Record` with a function returning an `Either` and + * partitions the resulting `Record` into `Left`s and `Right`s. + * + * @example + * import { partitionMapWithIndex } from "fp-ts/Record" + * import { either } from "fp-ts" + * + * const f = (key: string, a: number) => + * a >= 0 ? either.right(`${key} is >= 0 (${a})`) : either.left(`${key} is < 0 (${a})`); + * assert.deepStrictEqual(partitionMapWithIndex(f)({ a: -1, b: 2, c: 123 }), { + * left: { + * a: "a is < 0 (-1)", + * }, + * right: { + * b: "b is >= 0 (2)", + * c: "c is >= 0 (123)", + * }, + * }); + * + * @since 2.0.0 + */ +exports.partitionMapWithIndex = RR.partitionMapWithIndex; function partitionWithIndex(predicateWithIndex) { return RR.partitionWithIndex(predicateWithIndex); } exports.partitionWithIndex = partitionWithIndex; -function filterMapWithIndex(f) { - return RR.filterMapWithIndex(f); -} -exports.filterMapWithIndex = filterMapWithIndex; +/** + * Maps a `Record` with an iterating function that takes key and value and + * returns an `Option`, keeping only the `Some` values and discarding `None`s. + * + * @example + * import { filterMapWithIndex } from "fp-ts/Record" + * import { option } from "fp-ts" + * + * const f = (key: string, a: number) => (a >= 0 ? option.some(`${key}${a}`) : option.none); + * assert.deepStrictEqual(filterMapWithIndex(f)({ a: -1, b: 2, c: 3 }), { + * b: "b2", + * c: "c3", + * }); + * + * @since 2.0.0 + */ +exports.filterMapWithIndex = RR.filterMapWithIndex; function filterWithIndex(predicateWithIndex) { return RR.filterWithIndex(predicateWithIndex); } @@ -15159,148 +20787,448 @@ function fromFoldable(M, F) { return RR.fromFoldable(M, F); } exports.fromFoldable = fromFoldable; +/** + * Alias of [`toArray`](#toArray). + * + * @example + * import { toEntries } from 'fp-ts/Record' + * + * assert.deepStrictEqual(toEntries({ b: 2, a: 1 }), [['a', 1], ['b', 2]]) + * + * @since 2.12.0 + * @category conversions + */ +exports.toEntries = exports.toArray; +/** + * Converts an `Array` of `[key, value]` tuples into a `Record`. + * + * @example + * import { fromEntries } from 'fp-ts/Record' + * + * assert.deepStrictEqual(fromEntries([['a', 1], ['b', 2], ['a', 3]]), { b: 2, a: 3 }) + * + * @since 2.12.0 + * @category conversions + */ +var fromEntries = function (fa) { return fromFoldable(Se.last(), A.Foldable)(fa); }; +exports.fromEntries = fromEntries; function fromFoldableMap(M, F) { return RR.fromFoldableMap(M, F); } exports.fromFoldableMap = fromFoldableMap; /** + * Test if every value in a `Record` satisfies the predicate. + * + * @example + * import { every } from "fp-ts/Record" + * + * assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: 2 }), true); + * assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: -1 }), false); + * * @since 2.0.0 */ exports.every = RR.every; /** + * Test if at least one value in a `Record` satisfies the predicate. + * + * @example + * import { some } from "fp-ts/Record" + * + * assert.deepStrictEqual(some((n: number) => n >= 0)({ a: 1, b: -2 }), true); + * assert.deepStrictEqual(some((n: number) => n >= 0)({ a: -1, b: -2 }), false); + * * @since 2.0.0 */ exports.some = RR.some; // TODO: remove non-curried overloading in v3 /** + * Given an `Eq` checks if a `Record` contains an entry with + * value equal to a provided value. + * + * @example + * import { elem } from "fp-ts/Record" + * import { number } from "fp-ts" + * + * assert.deepStrictEqual(elem(number.Eq)(123, { foo: 123, bar: 234 }), true); + * assert.deepStrictEqual(elem(number.Eq)(-7, { foo: 123, bar: 234 }), false); + * * @since 2.0.0 */ exports.elem = RR.elem; -// ------------------------------------------------------------------------------------- -// non-pipeables -// ------------------------------------------------------------------------------------- -var map_ = RR.Functor.map; -var mapWithIndex_ = RR.FunctorWithIndex.mapWithIndex; -var reduce_ = RR.Foldable.reduce; -var foldMap_ = RR.Foldable.foldMap; -var reduceRight_ = RR.Foldable.reduceRight; -var reduceWithIndex_ = RR.FoldableWithIndex.reduceWithIndex; -var foldMapWithIndex_ = RR.FoldableWithIndex.foldMapWithIndex; -var reduceRightWithIndex_ = RR.FoldableWithIndex.reduceRightWithIndex; -var filter_ = RR.Filterable.filter; -var filterMap_ = RR.Filterable.filterMap; -var partition_ = RR.Filterable.partition; -var partitionMap_ = RR.Filterable.partitionMap; -var filterWithIndex_ = RR.FilterableWithIndex - .filterWithIndex; -var filterMapWithIndex_ = RR.FilterableWithIndex.filterMapWithIndex; -var partitionWithIndex_ = RR.FilterableWithIndex - .partitionWithIndex; -var partitionMapWithIndex_ = RR.FilterableWithIndex.partitionMapWithIndex; -var traverseWithIndex_ = RR.TraversableWithIndex - .traverseWithIndex; -var wither_ = RR.Witherable.wither; -var wilt_ = RR.Witherable.wilt; -var traverse_ = function (F) { - var traverseF = traverse(F); - return function (ta, f) { return traverseF(f)(ta); }; +/** + * Union of two `Record`s. + * Takes two `Record`s and produces a `Record` combining all the + * entries of the two inputs. + * It uses the `concat` function of the provided `Magma` to + * combine the elements with the same key. + * + * @example + * import { union } from "fp-ts/Record"; + * import { Magma } from "fp-ts/Magma"; + * + * const m1: Magma = { concat: (x: number, y: number) => x + y }; + * assert.deepStrictEqual(union(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4, b: 2, c: 3 }); + * const m2: Magma = { concat: (x: number) => x }; + * assert.deepStrictEqual(union(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 }); + * + * @since 2.11.0 + */ +var union = function (M) { + var unionM = RR.union(M); + return function (second) { return function (first) { + if ((0, exports.isEmpty)(first)) { + return __assign({}, second); + } + if ((0, exports.isEmpty)(second)) { + return __assign({}, first); + } + return unionM(second)(first); + }; }; }; -// ------------------------------------------------------------------------------------- -// pipeables -// ------------------------------------------------------------------------------------- +exports.union = union; /** - * @category Filterable - * @since 2.0.0 + * Intersection of two `Record`s. + * Takes two `Record`s and produces a `Record` combining only the + * entries of the two inputswith the same key. + * It uses the `concat` function of the provided `Magma` to + * combine the elements. + * + * @example + * import { intersection } from "fp-ts/Record"; + * import { Magma } from "fp-ts/Magma"; + * + * const m1: Magma = { concat: (x: number, y: number) => x + y }; + * assert.deepStrictEqual(intersection(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4}); + * const m2: Magma = { concat: (x: number) => x }; + * assert.deepStrictEqual(intersection(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1}); + * + * @since 2.11.0 */ -exports.filter = RR.filter; +var intersection = function (M) { + return function (second) { + return function (first) { + if ((0, exports.isEmpty)(first) || (0, exports.isEmpty)(second)) { + return {}; + } + return RR.intersection(M)(second)(first); + }; + }; +}; +exports.intersection = intersection; +/** + * Difference between two `Record`s. + * Takes two `Record`s and produces a `Record` composed by the + * entries of the two inputs, removing the entries with the same + * key in both inputs. + * + * @example + * import { difference } from "fp-ts/Record"; + * + * assert.deepStrictEqual(difference({ a: 1 })({ a: 1, b: 2 }), { b: 2 }); + * assert.deepStrictEqual(difference({ a: 3 })({ a: 1, b: 2 }), { b: 2 }); + * assert.deepStrictEqual(difference({ a: 3, c: 3 })({ a: 1, b: 2 }), { b: 2, c: 3 }); + * + * @since 2.11.0 + */ +var difference = function (second) { + return function (first) { + if ((0, exports.isEmpty)(first)) { + return __assign({}, second); + } + if ((0, exports.isEmpty)(second)) { + return __assign({}, first); + } + return RR.difference(second)(first); + }; +}; +exports.difference = difference; +var _map = RR._map; +var _mapWithIndex = RR._mapWithIndex; +var _reduce = RR._reduce; +var _foldMap = RR._foldMap; +var _reduceRight = RR._reduceRight; +var _filter = RR._filter; +var _filterMap = RR._filterMap; +var _partition = RR._partition; +var _partitionMap = RR._partitionMap; +var _reduceWithIndex = RR._reduceWithIndex; +var _foldMapWithIndex = RR._foldMapWithIndex; +var _reduceRightWithIndex = RR._reduceRightWithIndex; +var _partitionMapWithIndex = RR._partitionMapWithIndex; +var _partitionWithIndex = RR._partitionWithIndex; +var _filterMapWithIndex = RR._filterMapWithIndex; +var _filterWithIndex = RR._filterWithIndex; +var _traverse = RR._traverse; +var _sequence = RR._sequence; +var _traverseWithIndex = function (O) { + return function (F) { + var keysO = keys_(O); + return function (ta, f) { + var ks = keysO(ta); + if (ks.length === 0) { + return F.of({}); + } + var fr = F.of({}); + var _loop_1 = function (key) { + fr = F.ap(F.map(fr, function (r) { return function (b) { + r[key] = b; + return r; + }; }), f(key, ta[key])); + }; + for (var _i = 0, ks_1 = ks; _i < ks_1.length; _i++) { + var key = ks_1[_i]; + _loop_1(key); + } + return fr; + }; + }; +}; /** - * @category Filterable + * Given a `Predicate`, it produces a new `Record` keeping only the entries with a + * value that satisfies the provided predicate. + * + * @example + * import { filter } from "fp-ts/Record" + * + * assert.deepStrictEqual(filter((s: string) => s.length < 4)({ a: "foo", b: "bar", c: "verylong" }), { + * a: "foo", + * b: "bar", + * }); + * + * @category filtering * @since 2.0.0 */ -exports.filterMap = RR.filterMap; +exports.filter = RR.filter; /** - * @category Foldable + * Maps a `Record` with an iterating function that returns an `Option` + * and it keeps only the `Some` values discarding the `None`s. + * + * @example + * import { filterMap } from "fp-ts/Record" + * import { option } from "fp-ts" + * + * const f = (s: string) => s.length < 4 ? option.some(`${s} is short`): option.none + * assert.deepStrictEqual(filterMap(f)({ a: "foo", b: "bar", c: "verylong" }), { + * a: "foo is short", + * b: "bar is short", + * }); + * + * @category filtering * @since 2.0.0 */ -exports.foldMap = RR.foldMap; +exports.filterMap = RR.filterMap; /** - * @category Filterable + * Partition a `Record` into two parts according to a `Predicate`. + * + * @example + * import { partition } from "fp-ts/Record" + * + * assert.deepStrictEqual(partition((s: string) => s.length < 4)({ a: "foo", b: "bar", c: "verylong" }), { + * left:{ + * c: "verylong" + * }, + * right: { + * a: "foo", + * b: "bar", + * }, + * }); + * + * @category filtering * @since 2.0.0 */ exports.partition = RR.partition; /** - * @category Filterable + * Maps a `Record` with a function returning an `Either` and + * partitions the resulting `Record` into `Left`s and `Right`s. + * + * @example + * import { partitionMap } from "fp-ts/Record" + * import { either } from "fp-ts" + * + * const f = (s: string) => (s.length < 4 ? either.right(`${s} is short`) : either.left(`${s} is not short`)); + * assert.deepStrictEqual(partitionMap(f)({ a: "foo", b: "bar", c: "verylong" }), { + * left: { + * c: "verylong is not short", + * }, + * right: { + * a: "foo is short", + * b: "bar is short", + * }, + * }); + * + * @category filtering * @since 2.0.0 */ exports.partitionMap = RR.partitionMap; +function reduce() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return args.length === 1 ? RR.reduce(args[0]) : RR.reduce(S.Ord).apply(void 0, args); +} +exports.reduce = reduce; +function foldMap(O) { + return 'compare' in O ? RR.foldMap(O) : RR.foldMap(S.Ord)(O); +} +exports.foldMap = foldMap; +function reduceRight() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return args.length === 1 ? RR.reduceRight(args[0]) : RR.reduceRight(S.Ord).apply(void 0, args); +} +exports.reduceRight = reduceRight; /** - * @category Foldable + * Compact a `Record` of `Option`s discarding the `None` values and + * keeping the `Some` values. + * + * @example + * import { compact } from 'fp-ts/Record' + * import { option } from 'fp-ts' + * + * assert.deepStrictEqual(compact({ a: option.some("foo"), b: option.none, c: option.some("bar") }), { + * a: "foo", + * c: "bar", + * }); + * + * @category filtering * @since 2.0.0 */ -exports.reduce = RR.reduce; +exports.compact = RR.compact; /** - * @category Foldable + * Separate a `Record` of `Either`s into `Left`s and `Right`s. + * + * @example + * import { separate } from 'fp-ts/Record' + * import { either } from 'fp-ts' + * + * assert.deepStrictEqual( + * separate({ a: either.right("foo"), b: either.left("bar"), c: either.right("baz") }), + * { + * right: { + * a: "foo", + * c: "baz", + * }, + * left: { + * b: "bar", + * }, + * } + * ); + * + * @category filtering * @since 2.0.0 */ -exports.reduceRight = RR.reduceRight; +exports.separate = RR.separate; /** - * @category Compactable + * @category type lambdas * @since 2.0.0 */ -exports.compact = RR.compact; +exports.URI = 'Record'; +function getShow(O) { + return 'compare' in O ? RR.getShow(O) : RR.getShow(S.Ord)(O); +} +exports.getShow = getShow; /** - * @category Compactable + * Given an `Eq` for the base type, it produces an `Eq` + * for a `Record` of that base type. + * + * @example + * import { getEq } from "fp-ts/Record"; + * import { string } from "fp-ts"; + * import { Eq } from "fp-ts/Eq"; + * + * const eq: Eq> = getEq(string.Eq); + * assert.deepStrictEqual(eq.equals({ a: "foo" }, { b: "bar" }), false); + * assert.deepStrictEqual(eq.equals({ a: "foo" }, { a: "foo" }), true); + * + * @category instances * @since 2.0.0 */ -exports.separate = RR.separate; -// ------------------------------------------------------------------------------------- -// instances -// ------------------------------------------------------------------------------------- +exports.getEq = RR.getEq; /** + * Returns a `Monoid` instance for `Record`s, given a `Semigroup` + * instance for the base type. + * The `Monoid` makes the union of two `Record`s comining the + * overlapping entries with the provided `Semigroup`. + * + * @example + * import { SemigroupSum } from 'fp-ts/number' + * import { getMonoid } from 'fp-ts/Record' + * + * const M = getMonoid(SemigroupSum); + * assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579 , bar: 234, baz: 567 }); + * * @category instances * @since 2.0.0 */ -exports.URI = 'Record'; +exports.getMonoid = RR.getMonoid; /** * @category instances * @since 2.7.0 */ exports.Functor = { URI: exports.URI, - map: map_ + map: _map }; +/** + * Takes a value and a `Record` of functions and returns a + * `Record` by applying each function to the input value. + * + * @example + * import { flap } from "fp-ts/Record" + * + * const fab = { x: (n: number) => `${n} times 2`, y: (n: number) => `${n * 2}` }; + * assert.deepStrictEqual(flap(3)(fab), { + * x: "3 times 2", + * y: "6", + * }); + * + * @category mapping + * @since 2.10.0 + */ +exports.flap = (0, Functor_1.flap)(exports.Functor); /** * @category instances * @since 2.7.0 */ exports.FunctorWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_ + map: _map, + mapWithIndex: _mapWithIndex }; /** - * @category instances - * @since 2.7.0 + * Produces a `Foldable` instance for a `Record`, using the + * provided `Ord` to sort the `Record`'s entries by key. + * + * @category folding + * @since 2.11.0 */ -exports.Foldable = { +var getFoldable = function (O) { return ({ URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_ -}; + reduce: _reduce(O), + foldMap: _foldMap(O), + reduceRight: _reduceRight(O) +}); }; +exports.getFoldable = getFoldable; /** - * @category instances - * @since 2.7.0 + * Produces a `FoldableWithIndex1` instance for a `Record`, using the + * provided `Ord` to sort the `Record`'s entries by key. + * + * @category folding + * @since 2.11.0 */ -exports.FoldableWithIndex = { +var getFoldableWithIndex = function (O) { return ({ URI: exports.URI, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_ -}; + reduce: _reduce(O), + foldMap: _foldMap(O), + reduceRight: _reduceRight(O), + reduceWithIndex: _reduceWithIndex(O), + foldMapWithIndex: _foldMapWithIndex(O), + reduceRightWithIndex: _reduceRightWithIndex(O) +}); }; +exports.getFoldableWithIndex = getFoldableWithIndex; /** * @category instances * @since 2.7.0 @@ -15316,13 +21244,13 @@ exports.Compactable = { */ exports.Filterable = { URI: exports.URI, - map: map_, + map: _map, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_ + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap }; /** * @category instances @@ -15330,113 +21258,362 @@ exports.Filterable = { */ exports.FilterableWithIndex = { URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, + map: _map, + mapWithIndex: _mapWithIndex, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - filterMapWithIndex: filterMapWithIndex_, - filterWithIndex: filterWithIndex_, - partitionMapWithIndex: partitionMapWithIndex_, - partitionWithIndex: partitionWithIndex_ + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + filterMapWithIndex: _filterMapWithIndex, + filterWithIndex: _filterWithIndex, + partitionMapWithIndex: _partitionMapWithIndex, + partitionWithIndex: _partitionWithIndex }; /** - * @category instances - * @since 2.7.0 + * Produces a `Traversable` instance for a `Record`, using the + * provided `Ord` to sort the `Record`'s entries by key. + * + * @category traversing + * @since 2.11.0 */ -exports.Traversable = { +var getTraversable = function (O) { return ({ URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, - sequence: sequence -}; + map: _map, + reduce: _reduce(O), + foldMap: _foldMap(O), + reduceRight: _reduceRight(O), + traverse: _traverse(O), + sequence: _sequence(O) +}); }; +exports.getTraversable = getTraversable; /** - * @category instances - * @since 2.7.0 + * Produces a `TraversableWithIndex` instance for a `Record`, using the + * provided `Ord` to sort the `Record`'s entries by key. + * + * @category traversing + * @since 2.11.0 */ -exports.TraversableWithIndex = { +var getTraversableWithIndex = function (O) { return ({ URI: exports.URI, - map: map_, - mapWithIndex: mapWithIndex_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - traverse: traverse_, - sequence: sequence, - traverseWithIndex: traverseWithIndex_ -}; + map: _map, + mapWithIndex: _mapWithIndex, + reduce: _reduce(O), + foldMap: _foldMap(O), + reduceRight: _reduceRight(O), + reduceWithIndex: _reduceWithIndex(O), + foldMapWithIndex: _foldMapWithIndex(O), + reduceRightWithIndex: _reduceRightWithIndex(O), + traverse: _traverse(O), + sequence: _sequence(O), + traverseWithIndex: _traverseWithIndex(O) +}); }; +exports.getTraversableWithIndex = getTraversableWithIndex; /** - * @category instances - * @since 2.7.0 + * @category filtering + * @since 2.11.0 + */ +var getWitherable = function (O) { + var T = (0, exports.getTraversable)(O); + return { + URI: exports.URI, + map: _map, + reduce: _reduce(O), + foldMap: _foldMap(O), + reduceRight: _reduceRight(O), + traverse: T.traverse, + sequence: T.sequence, + compact: exports.compact, + separate: exports.separate, + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + wither: (0, Witherable_1.witherDefault)(T, exports.Compactable), + wilt: (0, Witherable_1.wiltDefault)(T, exports.Compactable) + }; +}; +exports.getWitherable = getWitherable; +/** + * Given a `Semigroup` in the base type, it produces a `Semigroup` + * in the `Record` of the base type. + * The resulting `Semigroup` concatenates two `Record`s by + * `union`. + * + * @example + * import { getUnionSemigroup } from "fp-ts/Record" + * import { Semigroup } from "fp-ts/Semigroup" + * + * const sNumber: Semigroup = { concat: (x, y) => x - y }; + * const sRecord: Semigroup> = getUnionSemigroup(sNumber); + * assert.deepStrictEqual(sRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { a: 1, b: -1, c: 4 }); + * + * @category instances + * @since 2.11.0 + */ +var getUnionSemigroup = function (S) { + var unionS = (0, exports.union)(S); + return { + concat: function (first, second) { return unionS(second)(first); } + }; +}; +exports.getUnionSemigroup = getUnionSemigroup; +/** + * Same as `getMonoid`. + * Returns a `Monoid` instance for `Record`s given a `Semigroup` + * instance for the base type. + * The `Monoid` makes the union of two `Record`s combining the + * entries that have the same key with the provided `Semigroup`. + * + * @example + * import { SemigroupSum } from 'fp-ts/number' + * import { getUnionMonoid } from 'fp-ts/Record' + * + * const M = getUnionMonoid(SemigroupSum); + * assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579 , bar: 234, baz: 567 }); + * + * @category instances + * @since 2.11.0 + */ +var getUnionMonoid = function (S) { return ({ + concat: (0, exports.getUnionSemigroup)(S).concat, + empty: {} +}); }; +exports.getUnionMonoid = getUnionMonoid; +/** + * Given a `Semigroup` in the base type, it produces a `Semigroup` + * in the `Record` of the base type. + * The resulting `Semigroup` concatenates two `Record`s by + * `intersection`. + * + * @example + * import { getIntersectionSemigroup } from "fp-ts/Record" + * import { Semigroup } from "fp-ts/Semigroup" + * + * const sNumber: Semigroup = { concat: (x, y) => x - y }; + * const sRecord: Semigroup> = getIntersectionSemigroup(sNumber); + * assert.deepStrictEqual(sRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { b: -1 }); + * + * @category instances + * @since 2.11.0 + */ +var getIntersectionSemigroup = function (S) { + var intersectionS = (0, exports.intersection)(S); + return { + concat: function (first, second) { return intersectionS(second)(first); } + }; +}; +exports.getIntersectionSemigroup = getIntersectionSemigroup; +/** + * Produces a `Magma` with a `concat` function that combines + * two `Record`s by making the `difference`. + * + * @example + * import { getDifferenceMagma, difference } from "fp-ts/Record" + * import { Magma } from "fp-ts/Magma" + * + * const r1 = { a: 3, c: 3 }; + * const r2 = { a: 1, b: 2 }; + * const m: Magma> = getDifferenceMagma(); + * assert.deepStrictEqual(m.concat(r1, r2), difference(r2)(r1)); + * assert.deepStrictEqual(m.concat(r1, r2), { c: 3, b: 2 }); + * + * @category instances + * @since 2.11.0 + */ +var getDifferenceMagma = function () { return ({ + concat: function (first, second) { return (0, exports.difference)(second)(first); } +}); }; +exports.getDifferenceMagma = getDifferenceMagma; +// ------------------------------------------------------------------------------------- +// deprecated +// ------------------------------------------------------------------------------------- +/** + * Use `getFoldable` instead. + * + * @category zone of death + * @since 2.7.0 + * @deprecated + */ +exports.Foldable = { + URI: exports.URI, + reduce: /*#__PURE__*/ _reduce(S.Ord), + foldMap: /*#__PURE__*/ _foldMap(S.Ord), + reduceRight: /*#__PURE__*/ _reduceRight(S.Ord) +}; +/** + * Use `getFoldableWithIndex` instead. + * + * @category zone of death + * @since 2.7.0 + * @deprecated + */ +exports.FoldableWithIndex = { + URI: exports.URI, + reduce: /*#__PURE__*/ _reduce(S.Ord), + foldMap: /*#__PURE__*/ _foldMap(S.Ord), + reduceRight: /*#__PURE__*/ _reduceRight(S.Ord), + reduceWithIndex: /*#__PURE__*/ _reduceWithIndex(S.Ord), + foldMapWithIndex: /*#__PURE__*/ _foldMapWithIndex(S.Ord), + reduceRightWithIndex: /*#__PURE__*/ _reduceRightWithIndex(S.Ord) +}; +/** + * Use `getTraversable` instead. + * + * @category zone of death + * @since 2.7.0 + * @deprecated + */ +exports.Traversable = { + URI: exports.URI, + map: _map, + reduce: /*#__PURE__*/ _reduce(S.Ord), + foldMap: /*#__PURE__*/ _foldMap(S.Ord), + reduceRight: /*#__PURE__*/ _reduceRight(S.Ord), + traverse: /*#__PURE__*/ _traverse(S.Ord), + sequence: sequence +}; +/** + * Use the `getTraversableWithIndex` instead. + * + * @category zone of death + * @since 2.7.0 + * @deprecated + */ +exports.TraversableWithIndex = { + URI: exports.URI, + map: _map, + mapWithIndex: _mapWithIndex, + reduce: /*#__PURE__*/ _reduce(S.Ord), + foldMap: /*#__PURE__*/ _foldMap(S.Ord), + reduceRight: /*#__PURE__*/ _reduceRight(S.Ord), + reduceWithIndex: /*#__PURE__*/ _reduceWithIndex(S.Ord), + foldMapWithIndex: /*#__PURE__*/ _foldMapWithIndex(S.Ord), + reduceRightWithIndex: /*#__PURE__*/ _reduceRightWithIndex(S.Ord), + traverse: /*#__PURE__*/ _traverse(S.Ord), + sequence: sequence, + traverseWithIndex: /*#__PURE__*/ _traverseWithIndex(S.Ord) +}; +var _wither = /*#__PURE__*/ (0, Witherable_1.witherDefault)(exports.Traversable, exports.Compactable); +var _wilt = /*#__PURE__*/ (0, Witherable_1.wiltDefault)(exports.Traversable, exports.Compactable); +/** + * Use `getWitherable` instead. + * + * @category zone of death + * @since 2.7.0 + * @deprecated */ exports.Witherable = { URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: _map, + reduce: /*#__PURE__*/ _reduce(S.Ord), + foldMap: /*#__PURE__*/ _foldMap(S.Ord), + reduceRight: /*#__PURE__*/ _reduceRight(S.Ord), + traverse: /*#__PURE__*/ _traverse(S.Ord), sequence: sequence, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - wither: wither_, - wilt: wilt_ + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + wither: _wither, + wilt: _wilt }; -// TODO: remove in v3 /** - * @category instances + * Use a new `{}` instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.empty = {}; +/** + * Use [`upsertAt`](#upsertat) instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated + */ +exports.insertAt = exports.upsertAt; +/** + * Use [`has`](#has) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated + */ +exports.hasOwnProperty = RR.hasOwnProperty; +/** + * This instance is deprecated, use small, specific instances instead. + * For example if a function needs a `Functor` instance, pass `R.Functor` instead of `R.record` + * (where `R` is from `import R from 'fp-ts/Record'`) + * + * @category zone of death + * @since 2.0.0 + * @deprecated */ exports.record = { URI: exports.URI, - map: map_, - reduce: reduce_, - foldMap: foldMap_, - reduceRight: reduceRight_, - traverse: traverse_, + map: _map, + reduce: /*#__PURE__*/ _reduce(S.Ord), + foldMap: /*#__PURE__*/ _foldMap(S.Ord), + reduceRight: /*#__PURE__*/ _reduceRight(S.Ord), + traverse: /*#__PURE__*/ _traverse(S.Ord), sequence: sequence, compact: exports.compact, separate: exports.separate, - filter: filter_, - filterMap: filterMap_, - partition: partition_, - partitionMap: partitionMap_, - mapWithIndex: mapWithIndex_, - reduceWithIndex: reduceWithIndex_, - foldMapWithIndex: foldMapWithIndex_, - reduceRightWithIndex: reduceRightWithIndex_, - filterMapWithIndex: filterMapWithIndex_, - filterWithIndex: filterWithIndex_, - partitionMapWithIndex: partitionMapWithIndex_, - partitionWithIndex: partitionWithIndex_, - traverseWithIndex: traverseWithIndex_, - wither: wither_, - wilt: wilt_ + filter: _filter, + filterMap: _filterMap, + partition: _partition, + partitionMap: _partitionMap, + mapWithIndex: _mapWithIndex, + reduceWithIndex: /*#__PURE__*/ _reduceWithIndex(S.Ord), + foldMapWithIndex: /*#__PURE__*/ _foldMapWithIndex(S.Ord), + reduceRightWithIndex: /*#__PURE__*/ _reduceRightWithIndex(S.Ord), + filterMapWithIndex: _filterMapWithIndex, + filterWithIndex: _filterWithIndex, + partitionMapWithIndex: _partitionMapWithIndex, + partitionWithIndex: _partitionWithIndex, + traverseWithIndex: /*#__PURE__*/ _traverseWithIndex(S.Ord), + wither: _wither, + wilt: _wilt }; /***/ }), /***/ 6339: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getIntercalateSemigroup = exports.semigroupVoid = exports.semigroupString = exports.semigroupProduct = exports.semigroupSum = exports.semigroupAny = exports.semigroupAll = exports.getObjectSemigroup = exports.getJoinSemigroup = exports.getMeetSemigroup = exports.getStructSemigroup = exports.getFunctionSemigroup = exports.getDualSemigroup = exports.getTupleSemigroup = exports.getLastSemigroup = exports.getFirstSemigroup = exports.fold = void 0; +exports.semigroupProduct = exports.semigroupSum = exports.semigroupString = exports.getFunctionSemigroup = exports.semigroupAny = exports.semigroupAll = exports.fold = exports.getIntercalateSemigroup = exports.getMeetSemigroup = exports.getJoinSemigroup = exports.getDualSemigroup = exports.getStructSemigroup = exports.getTupleSemigroup = exports.getFirstSemigroup = exports.getLastSemigroup = exports.getObjectSemigroup = exports.semigroupVoid = exports.concatAll = exports.last = exports.first = exports.intercalate = exports.tuple = exports.struct = exports.reverse = exports.constant = exports.max = exports.min = void 0; /** * If a type `A` can form a `Semigroup` it has an **associative** binary operation. * @@ -15477,492 +21654,822 @@ exports.getIntercalateSemigroup = exports.semigroupVoid = exports.semigroupStrin * @since 2.0.0 */ var function_1 = __nccwpck_require__(6985); -var Ord_1 = __nccwpck_require__(6685); -function fold(S) { - return function (startWith, as) { - if (as === undefined) { - var foldS_1 = fold(S); - return function (as) { return foldS_1(startWith, as); }; - } - return as.reduce(S.concat, startWith); - }; -} -exports.fold = fold; +var _ = __importStar(__nccwpck_require__(1840)); +var M = __importStar(__nccwpck_require__(179)); +var Or = __importStar(__nccwpck_require__(6685)); +// ------------------------------------------------------------------------------------- +// constructors +// ------------------------------------------------------------------------------------- /** - * Always return the first argument. + * Get a semigroup where `concat` will return the minimum, based on the provided order. * * @example + * import * as N from 'fp-ts/number' * import * as S from 'fp-ts/Semigroup' * - * assert.deepStrictEqual(S.getFirstSemigroup().concat(1, 2), 1) - * - * @category instances - * @since 2.0.0 - */ -function getFirstSemigroup() { - return { concat: function_1.identity }; -} -exports.getFirstSemigroup = getFirstSemigroup; -/** - * Always return the last argument. - * - * @example - * import * as S from 'fp-ts/Semigroup' + * const S1 = S.min(N.Ord) * - * assert.deepStrictEqual(S.getLastSemigroup().concat(1, 2), 2) + * assert.deepStrictEqual(S1.concat(1, 2), 1) * - * @category instances - * @since 2.0.0 + * @category constructors + * @since 2.10.0 */ -function getLastSemigroup() { - return { concat: function (_, y) { return y; } }; -} -exports.getLastSemigroup = getLastSemigroup; +var min = function (O) { return ({ + concat: Or.min(O) +}); }; +exports.min = min; /** - * Given a tuple of semigroups returns a semigroup for the tuple. + * Get a semigroup where `concat` will return the maximum, based on the provided order. * * @example + * import * as N from 'fp-ts/number' * import * as S from 'fp-ts/Semigroup' * - * const S1 = S.getTupleSemigroup(S.semigroupString, S.semigroupSum) - * assert.deepStrictEqual(S1.concat(['a', 1], ['b', 2]), ['ab', 3]) + * const S1 = S.max(N.Ord) * - * const S2 = S.getTupleSemigroup(S.semigroupString, S.semigroupSum, S.semigroupAll) - * assert.deepStrictEqual(S2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false]) + * assert.deepStrictEqual(S1.concat(1, 2), 2) * - * @category instances - * @since 2.0.0 + * @category constructors + * @since 2.10.0 */ -function getTupleSemigroup() { - var semigroups = []; - for (var _i = 0; _i < arguments.length; _i++) { - semigroups[_i] = arguments[_i]; - } - return { - concat: function (x, y) { return semigroups.map(function (s, i) { return s.concat(x[i], y[i]); }); } - }; -} -exports.getTupleSemigroup = getTupleSemigroup; +var max = function (O) { return ({ + concat: Or.max(O) +}); }; +exports.max = max; /** - * The dual of a `Semigroup`, obtained by swapping the arguments of `concat`. - * - * @example - * import * as S from 'fp-ts/Semigroup' - * - * assert.deepStrictEqual(S.getDualSemigroup(S.semigroupString).concat('a', 'b'), 'ba') - * - * @category instances - * @since 2.0.0 + * @category constructors + * @since 2.10.0 */ -function getDualSemigroup(S) { - return { - concat: function (x, y) { return S.concat(y, x); } - }; -} -exports.getDualSemigroup = getDualSemigroup; +var constant = function (a) { return ({ + concat: function () { return a; } +}); }; +exports.constant = constant; +// ------------------------------------------------------------------------------------- +// combinators +// ------------------------------------------------------------------------------------- /** - * Unary functions form a semigroup as long as you can provide a semigroup for the codomain. + * The dual of a `Semigroup`, obtained by swapping the arguments of `concat`. * * @example - * import { Predicate } from 'fp-ts/function' - * import * as S from 'fp-ts/Semigroup' - * - * const f: Predicate = (n) => n <= 2 - * const g: Predicate = (n) => n >= 0 - * - * const S1 = S.getFunctionSemigroup(S.semigroupAll)() - * - * assert.deepStrictEqual(S1.concat(f, g)(1), true) - * assert.deepStrictEqual(S1.concat(f, g)(3), false) - * - * const S2 = S.getFunctionSemigroup(S.semigroupAny)() + * import { reverse } from 'fp-ts/Semigroup' + * import * as S from 'fp-ts/string' * - * assert.deepStrictEqual(S2.concat(f, g)(1), true) - * assert.deepStrictEqual(S2.concat(f, g)(3), true) + * assert.deepStrictEqual(reverse(S.Semigroup).concat('a', 'b'), 'ba') * - * @category instances - * @since 2.0.0 + * @since 2.10.0 */ -function getFunctionSemigroup(S) { - return function () { return ({ - concat: function (f, g) { return function (a) { return S.concat(f(a), g(a)); }; } - }); }; -} -exports.getFunctionSemigroup = getFunctionSemigroup; +exports.reverse = M.reverse; /** * Given a struct of semigroups returns a semigroup for the struct. * * @example - * import * as S from 'fp-ts/Semigroup' + * import { struct } from 'fp-ts/Semigroup' + * import * as N from 'fp-ts/number' * * interface Point { * readonly x: number * readonly y: number * } * - * const semigroupPoint = S.getStructSemigroup({ - * x: S.semigroupSum, - * y: S.semigroupSum + * const S = struct({ + * x: N.SemigroupSum, + * y: N.SemigroupSum * }) * - * assert.deepStrictEqual(semigroupPoint.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 }) + * assert.deepStrictEqual(S.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 }) * - * @category instances - * @since 2.0.0 + * @since 2.10.0 */ -function getStructSemigroup(semigroups) { - return { - concat: function (x, y) { - var r = {}; - for (var _i = 0, _a = Object.keys(semigroups); _i < _a.length; _i++) { - var key = _a[_i]; - r[key] = semigroups[key].concat(x[key], y[key]); +var struct = function (semigroups) { return ({ + concat: function (first, second) { + var r = {}; + for (var k in semigroups) { + if (_.has.call(semigroups, k)) { + r[k] = semigroups[k].concat(first[k], second[k]); } - return r; } - }; -} -exports.getStructSemigroup = getStructSemigroup; + return r; + } +}); }; +exports.struct = struct; /** - * Get a semigroup where `concat` will return the minimum, based on the provided order. + * Given a tuple of semigroups returns a semigroup for the tuple. * * @example - * import * as O from 'fp-ts/Ord' - * import * as S from 'fp-ts/Semigroup' + * import { tuple } from 'fp-ts/Semigroup' + * import * as B from 'fp-ts/boolean' + * import * as N from 'fp-ts/number' + * import * as S from 'fp-ts/string' * - * const S1 = S.getMeetSemigroup(O.ordNumber) + * const S1 = tuple(S.Semigroup, N.SemigroupSum) + * assert.deepStrictEqual(S1.concat(['a', 1], ['b', 2]), ['ab', 3]) * - * assert.deepStrictEqual(S1.concat(1, 2), 1) + * const S2 = tuple(S.Semigroup, N.SemigroupSum, B.SemigroupAll) + * assert.deepStrictEqual(S2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false]) * - * @category instances - * @since 2.0.0 + * @since 2.10.0 */ -function getMeetSemigroup(O) { - return { - concat: Ord_1.min(O) - }; -} -exports.getMeetSemigroup = getMeetSemigroup; +var tuple = function () { + var semigroups = []; + for (var _i = 0; _i < arguments.length; _i++) { + semigroups[_i] = arguments[_i]; + } + return ({ + concat: function (first, second) { return semigroups.map(function (s, i) { return s.concat(first[i], second[i]); }); } + }); +}; +exports.tuple = tuple; /** - * Get a semigroup where `concat` will return the maximum, based on the provided order. + * Between each pair of elements insert `middle`. * * @example - * import * as O from 'fp-ts/Ord' - * import * as S from 'fp-ts/Semigroup' + * import { intercalate } from 'fp-ts/Semigroup' + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' * - * const S1 = S.getJoinSemigroup(O.ordNumber) + * const S1 = pipe(S.Semigroup, intercalate(' + ')) * - * assert.deepStrictEqual(S1.concat(1, 2), 2) + * assert.strictEqual(S1.concat('a', 'b'), 'a + b') * - * @category instances - * @since 2.0.0 + * @since 2.10.0 */ -function getJoinSemigroup(O) { - return { - concat: Ord_1.max(O) - }; -} -exports.getJoinSemigroup = getJoinSemigroup; +var intercalate = function (middle) { + return function (S) { return ({ + concat: function (x, y) { return S.concat(x, S.concat(middle, y)); } + }); }; +}; +exports.intercalate = intercalate; +// ------------------------------------------------------------------------------------- +// instances +// ------------------------------------------------------------------------------------- /** - * Return a semigroup for objects, preserving their type. + * Always return the first argument. * * @example * import * as S from 'fp-ts/Semigroup' * - * interface Person { - * name: string - * age: number - * } - * - * const S1 = S.getObjectSemigroup() - * assert.deepStrictEqual(S1.concat({ name: 'name', age: 23 }, { name: 'name', age: 24 }), { name: 'name', age: 24 }) + * assert.deepStrictEqual(S.first().concat(1, 2), 1) * * @category instances - * @since 2.0.0 + * @since 2.10.0 */ -function getObjectSemigroup() { - return { - concat: function (x, y) { return Object.assign({}, x, y); } - }; -} -exports.getObjectSemigroup = getObjectSemigroup; +var first = function () { return ({ concat: function_1.identity }); }; +exports.first = first; /** - * `boolean` semigroup under conjunction. + * Always return the last argument. * * @example * import * as S from 'fp-ts/Semigroup' * - * assert.deepStrictEqual(S.semigroupAll.concat(true, true), true) - * assert.deepStrictEqual(S.semigroupAll.concat(true, false), false) + * assert.deepStrictEqual(S.last().concat(1, 2), 2) * * @category instances - * @since 2.0.0 + * @since 2.10.0 */ -exports.semigroupAll = { - concat: function (x, y) { return x && y; } -}; +var last = function () { return ({ concat: function (_, y) { return y; } }); }; +exports.last = last; +// ------------------------------------------------------------------------------------- +// utils +// ------------------------------------------------------------------------------------- /** - * `boolean` semigroup under disjunction. + * Given a sequence of `as`, concat them and return the total. + * + * If `as` is empty, return the provided `startWith` value. * * @example - * import * as S from 'fp-ts/Semigroup' + * import { concatAll } from 'fp-ts/Semigroup' + * import * as N from 'fp-ts/number' * - * assert.deepStrictEqual(S.semigroupAny.concat(true, true), true) - * assert.deepStrictEqual(S.semigroupAny.concat(true, false), true) - * assert.deepStrictEqual(S.semigroupAny.concat(false, false), false) + * const sum = concatAll(N.SemigroupSum)(0) * - * @category instances - * @since 2.0.0 + * assert.deepStrictEqual(sum([1, 2, 3]), 6) + * assert.deepStrictEqual(sum([]), 0) + * + * @since 2.10.0 */ -exports.semigroupAny = { - concat: function (x, y) { return x || y; } -}; +exports.concatAll = M.concatAll; +// ------------------------------------------------------------------------------------- +// deprecated +// ------------------------------------------------------------------------------------- /** - * `number` semigroup under addition. - * - * @example - * import * as S from 'fp-ts/Semigroup' + * Use `void` module instead. * - * assert.deepStrictEqual(S.semigroupSum.concat(2, 3), 5) - * - * @category instances + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.semigroupSum = { - concat: function (x, y) { return x + y; } -}; +exports.semigroupVoid = (0, exports.constant)(undefined); /** - * `number` semigroup under multiplication. - * - * @example - * import * as S from 'fp-ts/Semigroup' + * Use [`getAssignSemigroup`](./struct.ts.html#getAssignSemigroup) instead. * - * assert.deepStrictEqual(S.semigroupProduct.concat(2, 3), 6) - * - * @category instances + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.semigroupProduct = { - concat: function (x, y) { return x * y; } -}; +var getObjectSemigroup = function () { return ({ + concat: function (first, second) { return Object.assign({}, first, second); } +}); }; +exports.getObjectSemigroup = getObjectSemigroup; /** - * `string` semigroup under concatenation. - * - * @example - * import * as S from 'fp-ts/Semigroup' + * Use [`last`](#last) instead. * - * assert.deepStrictEqual(S.semigroupString.concat('a', 'b'), 'ab') - * - * @category instances + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.semigroupString = { - concat: function (x, y) { return x + y; } -}; +exports.getLastSemigroup = exports.last; /** - * @category instances + * Use [`first`](#first) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.semigroupVoid = { - concat: function () { return undefined; } -}; +exports.getFirstSemigroup = exports.first; /** - * You can glue items between and stay associative. - * - * @example - * import * as S from 'fp-ts/Semigroup' - * - * const S1 = S.getIntercalateSemigroup(' ')(S.semigroupString) + * Use [`tuple`](#tuple) instead. * - * assert.strictEqual(S1.concat('a', 'b'), 'a b') - * assert.strictEqual(S1.concat(S1.concat('a', 'b'), 'c'), S1.concat('a', S1.concat('b', 'c'))) - * - * @category instances - * @since 2.5.0 - */ -function getIntercalateSemigroup(a) { - return function (S) { return ({ - concat: function (x, y) { return S.concat(x, S.concat(a, y)); } - }); }; -} -exports.getIntercalateSemigroup = getIntercalateSemigroup; - - -/***/ }), - -/***/ 6985: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/** + * @category zone of death * @since 2.0.0 + * @deprecated */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.bindTo_ = exports.bind_ = exports.hole = exports.pipe = exports.untupled = exports.tupled = exports.absurd = exports.decrement = exports.increment = exports.tuple = exports.flow = exports.flip = exports.constVoid = exports.constUndefined = exports.constNull = exports.constFalse = exports.constTrue = exports.constant = exports.not = exports.unsafeCoerce = exports.identity = void 0; +exports.getTupleSemigroup = exports.tuple; /** + * Use [`struct`](#struct) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function identity(a) { - return a; -} -exports.identity = identity; +exports.getStructSemigroup = exports.struct; /** + * Use [`reverse`](#reverse) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.unsafeCoerce = identity; +exports.getDualSemigroup = exports.reverse; /** + * Use [`max`](#max) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function not(predicate) { - return function (a) { return !predicate(a); }; -} -exports.not = not; +exports.getJoinSemigroup = exports.max; /** + * Use [`min`](#min) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function constant(a) { - return function () { return a; }; -} -exports.constant = constant; +exports.getMeetSemigroup = exports.min; /** - * A thunk that returns always `true`. + * Use [`intercalate`](#intercalate) instead. * - * @since 2.0.0 + * @category zone of death + * @since 2.5.0 + * @deprecated */ -exports.constTrue = -/*#__PURE__*/ -constant(true); +exports.getIntercalateSemigroup = exports.intercalate; +function fold(S) { + var concatAllS = (0, exports.concatAll)(S); + return function (startWith, as) { return (as === undefined ? concatAllS(startWith) : concatAllS(startWith)(as)); }; +} +exports.fold = fold; /** - * A thunk that returns always `false`. + * Use [`SemigroupAll`](./boolean.ts.html#SemigroupAll) instead. * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.constFalse = -/*#__PURE__*/ -constant(false); +exports.semigroupAll = { + concat: function (x, y) { return x && y; } +}; /** - * A thunk that returns always `null`. + * Use [`SemigroupAny`](./boolean.ts.html#SemigroupAny) instead. * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.constNull = -/*#__PURE__*/ -constant(null); +exports.semigroupAny = { + concat: function (x, y) { return x || y; } +}; /** - * A thunk that returns always `undefined`. + * Use [`getSemigroup`](./function.ts.html#getSemigroup) instead. * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.constUndefined = -/*#__PURE__*/ -constant(undefined); +exports.getFunctionSemigroup = function_1.getSemigroup; /** - * A thunk that returns always `void`. + * Use [`Semigroup`](./string.ts.html#Semigroup) instead. * + * @category zone of death * @since 2.0.0 + * @deprecated */ -exports.constVoid = exports.constUndefined; -// TODO: remove in v3 +exports.semigroupString = { + concat: function (x, y) { return x + y; } +}; /** - * Flips the order of the arguments of a function of two arguments. + * Use [`SemigroupSum`](./number.ts.html#SemigroupSum) instead. * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function flip(f) { - return function (b, a) { return f(a, b); }; -} -exports.flip = flip; -function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) { - switch (arguments.length) { - case 1: - return ab; - case 2: - return function () { - return bc(ab.apply(this, arguments)); - }; - case 3: - return function () { - return cd(bc(ab.apply(this, arguments))); - }; - case 4: - return function () { - return de(cd(bc(ab.apply(this, arguments)))); - }; - case 5: - return function () { - return ef(de(cd(bc(ab.apply(this, arguments))))); - }; - case 6: - return function () { - return fg(ef(de(cd(bc(ab.apply(this, arguments)))))); - }; - case 7: - return function () { - return gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))); - }; - case 8: - return function () { - return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))); - }; - case 9: - return function () { - return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))); - }; - } - return; -} -exports.flow = flow; +exports.semigroupSum = { + concat: function (x, y) { return x + y; } +}; /** + * Use [`SemigroupProduct`](./number.ts.html#SemigroupProduct) instead. + * + * @category zone of death * @since 2.0.0 + * @deprecated */ -function tuple() { - var t = []; - for (var _i = 0; _i < arguments.length; _i++) { - t[_i] = arguments[_i]; - } - return t; -} -exports.tuple = tuple; +exports.semigroupProduct = { + concat: function (x, y) { return x * y; } +}; + + +/***/ }), + +/***/ 5877: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + /** - * @since 2.0.0 + * ```ts + * interface Separated { + * readonly left: E + * readonly right: A + * } + * ``` + * + * Represents a result of separating a whole into two parts. + * + * @since 2.10.0 */ -function increment(n) { - return n + 1; -} -exports.increment = increment; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.right = exports.left = exports.flap = exports.Functor = exports.Bifunctor = exports.URI = exports.bimap = exports.mapLeft = exports.map = exports.separated = void 0; +var function_1 = __nccwpck_require__(6985); +var Functor_1 = __nccwpck_require__(5533); +// ------------------------------------------------------------------------------------- +// constructors +// ------------------------------------------------------------------------------------- /** - * @since 2.0.0 + * @category constructors + * @since 2.10.0 */ -function decrement(n) { - return n - 1; -} -exports.decrement = decrement; +var separated = function (left, right) { return ({ left: left, right: right }); }; +exports.separated = separated; +var _map = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }; +var _mapLeft = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.mapLeft)(f)); }; +var _bimap = function (fa, g, f) { return (0, function_1.pipe)(fa, (0, exports.bimap)(g, f)); }; /** - * @since 2.0.0 + * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types + * use the type constructor `F` to represent some computational context. + * + * @category mapping + * @since 2.10.0 */ -function absurd(_) { - throw new Error('Called `absurd` function which should be uncallable'); -} -exports.absurd = absurd; +var map = function (f) { + return function (fa) { + return (0, exports.separated)((0, exports.left)(fa), f((0, exports.right)(fa))); + }; +}; +exports.map = map; /** - * Creates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument. - * - * @example - * import { tupled } from 'fp-ts/function' - * - * const add = tupled((x: number, y: number): number => x + y) - * - * assert.strictEqual(add([1, 2]), 3) + * Map a function over the first type argument of a bifunctor. * - * @since 2.4.0 + * @category error handling + * @since 2.10.0 */ -function tupled(f) { - return function (a) { return f.apply(void 0, a); }; -} -exports.tupled = tupled; +var mapLeft = function (f) { + return function (fa) { + return (0, exports.separated)(f((0, exports.left)(fa)), (0, exports.right)(fa)); + }; +}; +exports.mapLeft = mapLeft; /** - * Inverse function of `tupled` + * Map a pair of functions over the two type arguments of the bifunctor. + * + * @category mapping + * @since 2.10.0 + */ +var bimap = function (f, g) { + return function (fa) { + return (0, exports.separated)(f((0, exports.left)(fa)), g((0, exports.right)(fa))); + }; +}; +exports.bimap = bimap; +/** + * @category type lambdas + * @since 2.10.0 + */ +exports.URI = 'Separated'; +/** + * @category instances + * @since 2.10.0 + */ +exports.Bifunctor = { + URI: exports.URI, + mapLeft: _mapLeft, + bimap: _bimap +}; +/** + * @category instances + * @since 2.10.0 + */ +exports.Functor = { + URI: exports.URI, + map: _map +}; +/** + * @category mapping + * @since 2.10.0 + */ +exports.flap = (0, Functor_1.flap)(exports.Functor); +// ------------------------------------------------------------------------------------- +// utils +// ------------------------------------------------------------------------------------- +/** + * @since 2.10.0 + */ +var left = function (s) { return s.left; }; +exports.left = left; +/** + * @since 2.10.0 + */ +var right = function (s) { return s.right; }; +exports.right = right; + + +/***/ }), + +/***/ 4384: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.filterE = exports.witherDefault = exports.wiltDefault = void 0; +var _ = __importStar(__nccwpck_require__(1840)); +function wiltDefault(T, C) { + return function (F) { + var traverseF = T.traverse(F); + return function (wa, f) { return F.map(traverseF(wa, f), C.separate); }; + }; +} +exports.wiltDefault = wiltDefault; +function witherDefault(T, C) { + return function (F) { + var traverseF = T.traverse(F); + return function (wa, f) { return F.map(traverseF(wa, f), C.compact); }; + }; +} +exports.witherDefault = witherDefault; +function filterE(W) { + return function (F) { + var witherF = W.wither(F); + return function (predicate) { return function (ga) { return witherF(ga, function (a) { return F.map(predicate(a), function (b) { return (b ? _.some(a) : _.none); }); }); }; }; + }; +} +exports.filterE = filterE; + + +/***/ }), + +/***/ 9734: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.guard = void 0; +function guard(F, P) { + return function (b) { return (b ? P.of(undefined) : F.zero()); }; +} +exports.guard = guard; + + +/***/ }), + +/***/ 6985: +/***/ (function(__unused_webpack_module, exports) { + +"use strict"; + +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.dual = exports.getEndomorphismMonoid = exports.not = exports.SK = exports.hole = exports.pipe = exports.untupled = exports.tupled = exports.absurd = exports.decrement = exports.increment = exports.tuple = exports.flow = exports.flip = exports.constVoid = exports.constUndefined = exports.constNull = exports.constFalse = exports.constTrue = exports.constant = exports.unsafeCoerce = exports.identity = exports.apply = exports.getRing = exports.getSemiring = exports.getMonoid = exports.getSemigroup = exports.getBooleanAlgebra = void 0; +// ------------------------------------------------------------------------------------- +// instances +// ------------------------------------------------------------------------------------- +/** + * @category instances + * @since 2.10.0 + */ +var getBooleanAlgebra = function (B) { + return function () { return ({ + meet: function (x, y) { return function (a) { return B.meet(x(a), y(a)); }; }, + join: function (x, y) { return function (a) { return B.join(x(a), y(a)); }; }, + zero: function () { return B.zero; }, + one: function () { return B.one; }, + implies: function (x, y) { return function (a) { return B.implies(x(a), y(a)); }; }, + not: function (x) { return function (a) { return B.not(x(a)); }; } + }); }; +}; +exports.getBooleanAlgebra = getBooleanAlgebra; +/** + * Unary functions form a semigroup as long as you can provide a semigroup for the codomain. + * + * @example + * import { Predicate, getSemigroup } from 'fp-ts/function' + * import * as B from 'fp-ts/boolean' + * + * const f: Predicate = (n) => n <= 2 + * const g: Predicate = (n) => n >= 0 + * + * const S1 = getSemigroup(B.SemigroupAll)() + * + * assert.deepStrictEqual(S1.concat(f, g)(1), true) + * assert.deepStrictEqual(S1.concat(f, g)(3), false) + * + * const S2 = getSemigroup(B.SemigroupAny)() + * + * assert.deepStrictEqual(S2.concat(f, g)(1), true) + * assert.deepStrictEqual(S2.concat(f, g)(3), true) + * + * @category instances + * @since 2.10.0 + */ +var getSemigroup = function (S) { + return function () { return ({ + concat: function (f, g) { return function (a) { return S.concat(f(a), g(a)); }; } + }); }; +}; +exports.getSemigroup = getSemigroup; +/** + * Unary functions form a monoid as long as you can provide a monoid for the codomain. + * + * @example + * import { Predicate } from 'fp-ts/Predicate' + * import { getMonoid } from 'fp-ts/function' + * import * as B from 'fp-ts/boolean' + * + * const f: Predicate = (n) => n <= 2 + * const g: Predicate = (n) => n >= 0 + * + * const M1 = getMonoid(B.MonoidAll)() + * + * assert.deepStrictEqual(M1.concat(f, g)(1), true) + * assert.deepStrictEqual(M1.concat(f, g)(3), false) + * + * const M2 = getMonoid(B.MonoidAny)() + * + * assert.deepStrictEqual(M2.concat(f, g)(1), true) + * assert.deepStrictEqual(M2.concat(f, g)(3), true) + * + * @category instances + * @since 2.10.0 + */ +var getMonoid = function (M) { + var getSemigroupM = (0, exports.getSemigroup)(M); + return function () { return ({ + concat: getSemigroupM().concat, + empty: function () { return M.empty; } + }); }; +}; +exports.getMonoid = getMonoid; +/** + * @category instances + * @since 2.10.0 + */ +var getSemiring = function (S) { return ({ + add: function (f, g) { return function (x) { return S.add(f(x), g(x)); }; }, + zero: function () { return S.zero; }, + mul: function (f, g) { return function (x) { return S.mul(f(x), g(x)); }; }, + one: function () { return S.one; } +}); }; +exports.getSemiring = getSemiring; +/** + * @category instances + * @since 2.10.0 + */ +var getRing = function (R) { + var S = (0, exports.getSemiring)(R); + return { + add: S.add, + mul: S.mul, + one: S.one, + zero: S.zero, + sub: function (f, g) { return function (x) { return R.sub(f(x), g(x)); }; } + }; +}; +exports.getRing = getRing; +// ------------------------------------------------------------------------------------- +// utils +// ------------------------------------------------------------------------------------- +/** + * @since 2.11.0 + */ +var apply = function (a) { + return function (f) { + return f(a); + }; +}; +exports.apply = apply; +/** + * @since 2.0.0 + */ +function identity(a) { + return a; +} +exports.identity = identity; +/** + * @since 2.0.0 + */ +exports.unsafeCoerce = identity; +/** + * @since 2.0.0 + */ +function constant(a) { + return function () { return a; }; +} +exports.constant = constant; +/** + * A thunk that returns always `true`. + * + * @since 2.0.0 + */ +exports.constTrue = constant(true); +/** + * A thunk that returns always `false`. + * + * @since 2.0.0 + */ +exports.constFalse = constant(false); +/** + * A thunk that returns always `null`. + * + * @since 2.0.0 + */ +exports.constNull = constant(null); +/** + * A thunk that returns always `undefined`. + * + * @since 2.0.0 + */ +exports.constUndefined = constant(undefined); +/** + * A thunk that returns always `void`. + * + * @since 2.0.0 + */ +exports.constVoid = exports.constUndefined; +function flip(f) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (args.length > 1) { + return f(args[1], args[0]); + } + return function (a) { return f(a)(args[0]); }; + }; +} +exports.flip = flip; +function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) { + switch (arguments.length) { + case 1: + return ab; + case 2: + return function () { + return bc(ab.apply(this, arguments)); + }; + case 3: + return function () { + return cd(bc(ab.apply(this, arguments))); + }; + case 4: + return function () { + return de(cd(bc(ab.apply(this, arguments)))); + }; + case 5: + return function () { + return ef(de(cd(bc(ab.apply(this, arguments))))); + }; + case 6: + return function () { + return fg(ef(de(cd(bc(ab.apply(this, arguments)))))); + }; + case 7: + return function () { + return gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))); + }; + case 8: + return function () { + return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))); + }; + case 9: + return function () { + return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))); + }; + } + return; +} +exports.flow = flow; +/** + * @since 2.0.0 + */ +function tuple() { + var t = []; + for (var _i = 0; _i < arguments.length; _i++) { + t[_i] = arguments[_i]; + } + return t; +} +exports.tuple = tuple; +/** + * @since 2.0.0 + */ +function increment(n) { + return n + 1; +} +exports.increment = increment; +/** + * @since 2.0.0 + */ +function decrement(n) { + return n - 1; +} +exports.decrement = decrement; +/** + * @since 2.0.0 + */ +function absurd(_) { + throw new Error('Called `absurd` function which should be uncallable'); +} +exports.absurd = absurd; +/** + * Creates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument. + * + * @example + * import { tupled } from 'fp-ts/function' + * + * const add = tupled((x: number, y: number): number => x + y) + * + * assert.strictEqual(add([1, 2]), 3) + * + * @since 2.4.0 + */ +function tupled(f) { + return function (a) { return f.apply(void 0, a); }; +} +exports.tupled = tupled; +/** + * Inverse function of `tupled` * * @since 2.4.0 */ @@ -15976,7 +22483,7 @@ function untupled(f) { }; } exports.untupled = untupled; -function pipe(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs, st) { +function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) { switch (arguments.length) { case 1: return a; @@ -15996,30 +22503,14 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, return gh(fg(ef(de(cd(bc(ab(a))))))); case 9: return hi(gh(fg(ef(de(cd(bc(ab(a)))))))); - case 10: - return ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))); - case 11: - return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))); - case 12: - return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))); - case 13: - return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))); - case 14: - return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))); - case 15: - return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))); - case 16: - return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))); - case 17: - return pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))); - case 18: - return qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))); - case 19: - return rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))))); - case 20: - return st(rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))))); + default: { + var ret = arguments[0]; + for (var i = 1; i < arguments.length; i++) { + ret = arguments[i](ret); + } + return ret; + } } - return; } exports.pipe = pipe; /** @@ -16029,225 +22520,895 @@ exports.pipe = pipe; */ exports.hole = absurd; /** - * @internal + * @since 2.11.0 */ -var bind_ = function (a, name, b) { - var _a; - return Object.assign({}, a, (_a = {}, _a[name] = b, _a)); -}; -exports.bind_ = bind_; +var SK = function (_, b) { return b; }; +exports.SK = SK; /** - * @internal + * Use `Predicate` module instead. + * + * @category zone of death + * @since 2.0.0 + * @deprecated */ -var bindTo_ = function (name) { return function (b) { - var _a; - return (_a = {}, _a[name] = b, _a); -}; }; -exports.bindTo_ = bindTo_; +function not(predicate) { + return function (a) { return !predicate(a); }; +} +exports.not = not; +/** + * Use `Endomorphism` module instead. + * + * @category zone of death + * @since 2.10.0 + * @deprecated + */ +var getEndomorphismMonoid = function () { return ({ + concat: function (first, second) { return flow(first, second); }, + empty: identity +}); }; +exports.getEndomorphismMonoid = getEndomorphismMonoid; +/** @internal */ +var dual = function (arity, body) { + var isDataFirst = typeof arity === 'number' ? function (args) { return args.length >= arity; } : arity; + return function () { + var args = Array.from(arguments); + if (isDataFirst(arguments)) { + return body.apply(this, args); + } + return function (self) { return body.apply(void 0, __spreadArray([self], args, false)); }; + }; +}; +exports.dual = dual; /***/ }), -/***/ 6837: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 1840: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.pipeable = exports.pipe = void 0; +exports.flatMapReader = exports.flatMapTask = exports.flatMapIO = exports.flatMapEither = exports.flatMapOption = exports.flatMapNullable = exports.liftOption = exports.liftNullable = exports.fromReadonlyNonEmptyArray = exports.has = exports.emptyRecord = exports.emptyReadonlyArray = exports.tail = exports.head = exports.isNonEmpty = exports.singleton = exports.right = exports.left = exports.isRight = exports.isLeft = exports.some = exports.none = exports.isSome = exports.isNone = void 0; var function_1 = __nccwpck_require__(6985); -// TODO: remove module in v3 -/** - * Use [`pipe`](https://gcanti.github.io/fp-ts/modules/function.ts.html#flow) from `function` module instead. - * - * @since 2.0.0 - */ -exports.pipe = function_1.pipe; -var isFunctor = function (I) { return typeof I.map === 'function'; }; -var isContravariant = function (I) { return typeof I.contramap === 'function'; }; -var isFunctorWithIndex = function (I) { return typeof I.mapWithIndex === 'function'; }; -var isApply = function (I) { return typeof I.ap === 'function'; }; -var isChain = function (I) { return typeof I.chain === 'function'; }; -var isBifunctor = function (I) { return typeof I.bimap === 'function'; }; -var isExtend = function (I) { return typeof I.extend === 'function'; }; -var isFoldable = function (I) { return typeof I.reduce === 'function'; }; -var isFoldableWithIndex = function (I) { return typeof I.reduceWithIndex === 'function'; }; -var isAlt = function (I) { return typeof I.alt === 'function'; }; -var isCompactable = function (I) { return typeof I.compact === 'function'; }; -var isFilterable = function (I) { return typeof I.filter === 'function'; }; -var isFilterableWithIndex = function (I) { - return typeof I.filterWithIndex === 'function'; -}; -var isProfunctor = function (I) { return typeof I.promap === 'function'; }; -var isSemigroupoid = function (I) { return typeof I.compose === 'function'; }; -var isMonadThrow = function (I) { return typeof I.throwError === 'function'; }; -function pipeable(I) { - var r = {}; - if (isFunctor(I)) { - var map = function (f) { return function (fa) { return I.map(fa, f); }; }; - r.map = map; - } - if (isContravariant(I)) { - var contramap = function (f) { return function (fa) { return I.contramap(fa, f); }; }; - r.contramap = contramap; - } - if (isFunctorWithIndex(I)) { - var mapWithIndex = function (f) { return function (fa) { return I.mapWithIndex(fa, f); }; }; - r.mapWithIndex = mapWithIndex; - } - if (isApply(I)) { - var ap = function (fa) { return function (fab) { return I.ap(fab, fa); }; }; - var apFirst = function (fb) { return function (fa) { - return I.ap(I.map(fa, function (a) { return function () { return a; }; }), fb); - }; }; - r.ap = ap; - r.apFirst = apFirst; - r.apSecond = function (fb) { return function (fa) { - return I.ap(I.map(fa, function () { return function (b) { return b; }; }), fb); - }; }; - } - if (isChain(I)) { - var chain = function (f) { return function (ma) { return I.chain(ma, f); }; }; - var chainFirst = function (f) { return function (ma) { return I.chain(ma, function (a) { return I.map(f(a), function () { return a; }); }); }; }; - var flatten = function (mma) { return I.chain(mma, function_1.identity); }; - r.chain = chain; - r.chainFirst = chainFirst; - r.flatten = flatten; - } - if (isBifunctor(I)) { - var bimap = function (f, g) { return function (fa) { return I.bimap(fa, f, g); }; }; - var mapLeft = function (f) { return function (fa) { return I.mapLeft(fa, f); }; }; - r.bimap = bimap; - r.mapLeft = mapLeft; - } - if (isExtend(I)) { - var extend = function (f) { return function (wa) { return I.extend(wa, f); }; }; - var duplicate = function (wa) { return I.extend(wa, function_1.identity); }; - r.extend = extend; - r.duplicate = duplicate; - } - if (isFoldable(I)) { - var reduce = function (b, f) { return function (fa) { return I.reduce(fa, b, f); }; }; - var foldMap = function (M) { - var foldMapM = I.foldMap(M); - return function (f) { return function (fa) { return foldMapM(fa, f); }; }; - }; - var reduceRight = function (b, f) { return function (fa) { return I.reduceRight(fa, b, f); }; }; - r.reduce = reduce; - r.foldMap = foldMap; - r.reduceRight = reduceRight; - } - if (isFoldableWithIndex(I)) { - var reduceWithIndex = function (b, f) { return function (fa) { - return I.reduceWithIndex(fa, b, f); - }; }; - var foldMapWithIndex = function (M) { - var foldMapM = I.foldMapWithIndex(M); - return function (f) { return function (fa) { return foldMapM(fa, f); }; }; +// ------------------------------------------------------------------------------------- +// Option +// ------------------------------------------------------------------------------------- +/** @internal */ +var isNone = function (fa) { return fa._tag === 'None'; }; +exports.isNone = isNone; +/** @internal */ +var isSome = function (fa) { return fa._tag === 'Some'; }; +exports.isSome = isSome; +/** @internal */ +exports.none = { _tag: 'None' }; +/** @internal */ +var some = function (a) { return ({ _tag: 'Some', value: a }); }; +exports.some = some; +// ------------------------------------------------------------------------------------- +// Either +// ------------------------------------------------------------------------------------- +/** @internal */ +var isLeft = function (ma) { return ma._tag === 'Left'; }; +exports.isLeft = isLeft; +/** @internal */ +var isRight = function (ma) { return ma._tag === 'Right'; }; +exports.isRight = isRight; +/** @internal */ +var left = function (e) { return ({ _tag: 'Left', left: e }); }; +exports.left = left; +/** @internal */ +var right = function (a) { return ({ _tag: 'Right', right: a }); }; +exports.right = right; +// ------------------------------------------------------------------------------------- +// ReadonlyNonEmptyArray +// ------------------------------------------------------------------------------------- +/** @internal */ +var singleton = function (a) { return [a]; }; +exports.singleton = singleton; +/** @internal */ +var isNonEmpty = function (as) { return as.length > 0; }; +exports.isNonEmpty = isNonEmpty; +/** @internal */ +var head = function (as) { return as[0]; }; +exports.head = head; +/** @internal */ +var tail = function (as) { return as.slice(1); }; +exports.tail = tail; +// ------------------------------------------------------------------------------------- +// empty +// ------------------------------------------------------------------------------------- +/** @internal */ +exports.emptyReadonlyArray = []; +/** @internal */ +exports.emptyRecord = {}; +// ------------------------------------------------------------------------------------- +// Record +// ------------------------------------------------------------------------------------- +/** @internal */ +exports.has = Object.prototype.hasOwnProperty; +// ------------------------------------------------------------------------------------- +// NonEmptyArray +// ------------------------------------------------------------------------------------- +/** @internal */ +var fromReadonlyNonEmptyArray = function (as) { return __spreadArray([as[0]], as.slice(1), true); }; +exports.fromReadonlyNonEmptyArray = fromReadonlyNonEmptyArray; +/** @internal */ +var liftNullable = function (F) { + return function (f, onNullable) { + return function () { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } + var o = f.apply(void 0, a); + return F.fromEither(o == null ? (0, exports.left)(onNullable.apply(void 0, a)) : (0, exports.right)(o)); }; - var reduceRightWithIndex = function (b, f) { return function (fa) { - return I.reduceRightWithIndex(fa, b, f); - }; }; - r.reduceWithIndex = reduceWithIndex; - r.foldMapWithIndex = foldMapWithIndex; - r.reduceRightWithIndex = reduceRightWithIndex; - } - if (isAlt(I)) { - var alt = function (that) { return function (fa) { return I.alt(fa, that); }; }; - r.alt = alt; - } - if (isCompactable(I)) { - r.compact = I.compact; - r.separate = I.separate; - } - if (isFilterable(I)) { - var filter = function (predicate) { return function (fa) { - return I.filter(fa, predicate); - }; }; - var filterMap = function (f) { return function (fa) { return I.filterMap(fa, f); }; }; - var partition = function (predicate) { return function (fa) { - return I.partition(fa, predicate); - }; }; - var partitionMap = function (f) { return function (fa) { return I.partitionMap(fa, f); }; }; - r.filter = filter; - r.filterMap = filterMap; - r.partition = partition; - r.partitionMap = partitionMap; - } - if (isFilterableWithIndex(I)) { - var filterWithIndex = function (predicateWithIndex) { return function (fa) { return I.filterWithIndex(fa, predicateWithIndex); }; }; - var filterMapWithIndex = function (f) { return function (fa) { - return I.filterMapWithIndex(fa, f); - }; }; - var partitionWithIndex = function (predicateWithIndex) { return function (fa) { return I.partitionWithIndex(fa, predicateWithIndex); }; }; - var partitionMapWithIndex = function (f) { return function (fa) { - return I.partitionMapWithIndex(fa, f); - }; }; - r.filterWithIndex = filterWithIndex; - r.filterMapWithIndex = filterMapWithIndex; - r.partitionWithIndex = partitionWithIndex; - r.partitionMapWithIndex = partitionMapWithIndex; - } - if (isProfunctor(I)) { - var promap = function (f, g) { return function (fa) { return I.promap(fa, f, g); }; }; - r.promap = promap; - } - if (isSemigroupoid(I)) { - var compose = function (that) { return function (fa) { return I.compose(fa, that); }; }; - r.compose = compose; - } - if (isMonadThrow(I)) { - var fromOption = function (onNone) { return function (ma) { - return ma._tag === 'None' ? I.throwError(onNone()) : I.of(ma.value); - }; }; - var fromEither = function (ma) { - return ma._tag === 'Left' ? I.throwError(ma.left) : I.of(ma.right); + }; +}; +exports.liftNullable = liftNullable; +/** @internal */ +var liftOption = function (F) { + return function (f, onNone) { + return function () { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i] = arguments[_i]; + } + var o = f.apply(void 0, a); + return F.fromEither((0, exports.isNone)(o) ? (0, exports.left)(onNone.apply(void 0, a)) : (0, exports.right)(o.value)); }; - var fromPredicate = function (predicate, onFalse) { return function (a) { return (predicate(a) ? I.of(a) : I.throwError(onFalse(a))); }; }; - var filterOrElse = function (predicate, onFalse) { return function (ma) { return I.chain(ma, function (a) { return (predicate(a) ? I.of(a) : I.throwError(onFalse(a))); }); }; }; - r.fromOption = fromOption; - r.fromEither = fromEither; - r.fromPredicate = fromPredicate; - r.filterOrElse = filterOrElse; - } - return r; -} -exports.pipeable = pipeable; + }; +}; +exports.liftOption = liftOption; +/** @internal */ +var flatMapNullable = function (F, M) { + return /*#__PURE__*/ (0, function_1.dual)(3, function (self, f, onNullable) { + return M.flatMap(self, (0, exports.liftNullable)(F)(f, onNullable)); + }); +}; +exports.flatMapNullable = flatMapNullable; +/** @internal */ +var flatMapOption = function (F, M) { + return /*#__PURE__*/ (0, function_1.dual)(3, function (self, f, onNone) { return M.flatMap(self, (0, exports.liftOption)(F)(f, onNone)); }); +}; +exports.flatMapOption = flatMapOption; +/** @internal */ +var flatMapEither = function (F, M) { + return /*#__PURE__*/ (0, function_1.dual)(2, function (self, f) { + return M.flatMap(self, function (a) { return F.fromEither(f(a)); }); + }); +}; +exports.flatMapEither = flatMapEither; +/** @internal */ +var flatMapIO = function (F, M) { + return /*#__PURE__*/ (0, function_1.dual)(2, function (self, f) { + return M.flatMap(self, function (a) { return F.fromIO(f(a)); }); + }); +}; +exports.flatMapIO = flatMapIO; +/** @internal */ +var flatMapTask = function (F, M) { + return /*#__PURE__*/ (0, function_1.dual)(2, function (self, f) { + return M.flatMap(self, function (a) { return F.fromTask(f(a)); }); + }); +}; +exports.flatMapTask = flatMapTask; +/** @internal */ +var flatMapReader = function (F, M) { + return /*#__PURE__*/ (0, function_1.dual)(2, function (self, f) { + return M.flatMap(self, function (a) { return F.fromReader(f(a)); }); + }); +}; +exports.flatMapReader = flatMapReader; /***/ }), -/***/ 51: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 52: +/***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.reporter = exports.formatValidationErrors = exports.formatValidationError = exports.TYPE_MAX_LEN = void 0; +exports.Field = exports.MonoidProduct = exports.MonoidSum = exports.SemigroupProduct = exports.SemigroupSum = exports.MagmaSub = exports.Show = exports.Bounded = exports.Ord = exports.Eq = exports.isNumber = void 0; +// ------------------------------------------------------------------------------------- +// refinements +// ------------------------------------------------------------------------------------- /** - * An [io-ts Reporter](https://gcanti.github.io/io-ts/modules/Reporter.ts.html#reporter-interface). + * @category refinements + * @since 2.11.0 + */ +var isNumber = function (u) { return typeof u === 'number'; }; +exports.isNumber = isNumber; +// ------------------------------------------------------------------------------------- +// instances +// ------------------------------------------------------------------------------------- +/** + * @category instances + * @since 2.10.0 + */ +exports.Eq = { + equals: function (first, second) { return first === second; } +}; +/** + * @category instances + * @since 2.10.0 + */ +exports.Ord = { + equals: exports.Eq.equals, + compare: function (first, second) { return (first < second ? -1 : first > second ? 1 : 0); } +}; +/** + * @category instances + * @since 2.10.0 + */ +exports.Bounded = { + equals: exports.Eq.equals, + compare: exports.Ord.compare, + top: Infinity, + bottom: -Infinity +}; +/** + * @category instances + * @since 2.10.0 + */ +exports.Show = { + show: function (n) { return JSON.stringify(n); } +}; +/** + * @category instances + * @since 2.11.0 + */ +exports.MagmaSub = { + concat: function (first, second) { return first - second; } +}; +/** + * `number` semigroup under addition. * * @example + * import { SemigroupSum } from 'fp-ts/number' * - * import * as t from 'io-ts'; - * import Reporter from 'io-ts-reporters'; + * assert.deepStrictEqual(SemigroupSum.concat(2, 3), 5) * - * const User = t.interface({ name: t.string }); + * @category instances + * @since 2.10.0 + */ +exports.SemigroupSum = { + concat: function (first, second) { return first + second; } +}; +/** + * `number` semigroup under multiplication. * - * assert.deepEqual( - * Reporter.report(User.decode({ nam: 'Jane' })), - * ['Expecting string at name but instead got: undefined'], - * ) - * assert.deepEqual( Reporter.report(User.decode({ name: 'Jane' })), []) + * @example + * import { SemigroupProduct } from 'fp-ts/number' * - * @since 1.2.0 + * assert.deepStrictEqual(SemigroupProduct.concat(2, 3), 6) + * + * @category instances + * @since 2.10.0 */ -var A = __nccwpck_require__(3834); -var E = __nccwpck_require__(7534); -var NEA = __nccwpck_require__(240); -var O = __nccwpck_require__(2569); -var R = __nccwpck_require__(2653); -var pipeable_1 = __nccwpck_require__(6837); +exports.SemigroupProduct = { + concat: function (first, second) { return first * second; } +}; +/** + * `number` monoid under addition. + * + * The `empty` value is `0`. + * + * @example + * import { MonoidSum } from 'fp-ts/number' + * + * assert.deepStrictEqual(MonoidSum.concat(2, MonoidSum.empty), 2) + * + * @category instances + * @since 2.10.0 + */ +exports.MonoidSum = { + concat: exports.SemigroupSum.concat, + empty: 0 +}; +/** + * `number` monoid under multiplication. + * + * The `empty` value is `1`. + * + * @example + * import { MonoidProduct } from 'fp-ts/number' + * + * assert.deepStrictEqual(MonoidProduct.concat(2, MonoidProduct.empty), 2) + * + * @category instances + * @since 2.10.0 + */ +exports.MonoidProduct = { + concat: exports.SemigroupProduct.concat, + empty: 1 +}; +/** + * @category instances + * @since 2.10.0 + */ +exports.Field = { + add: exports.SemigroupSum.concat, + zero: 0, + mul: exports.SemigroupProduct.concat, + one: 1, + sub: exports.MagmaSub.concat, + degree: function (_) { return 1; }, + div: function (first, second) { return first / second; }, + mod: function (first, second) { return first % second; } +}; + + +/***/ }), + +/***/ 6837: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.pipe = exports.pipeable = exports.compose = exports.promap = exports.partitionMapWithIndex = exports.partitionWithIndex = exports.filterMapWithIndex = exports.filterWithIndex = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports.alt = exports.reduceRightWithIndex = exports.foldMapWithIndex = exports.reduceWithIndex = exports.reduceRight = exports.foldMap = exports.reduce = exports.extend = exports.mapLeft = exports.bimap = exports.chain = exports.ap = exports.mapWithIndex = exports.contramap = exports.map = void 0; +var Apply_1 = __nccwpck_require__(205); +var Chain_1 = __nccwpck_require__(2372); +var function_1 = __nccwpck_require__(6985); +function map(F) { + return function (f) { return function (fa) { return F.map(fa, f); }; }; +} +exports.map = map; +function contramap(F) { + return function (f) { return function (fa) { return F.contramap(fa, f); }; }; +} +exports.contramap = contramap; +function mapWithIndex(F) { + return function (f) { return function (fa) { return F.mapWithIndex(fa, f); }; }; +} +exports.mapWithIndex = mapWithIndex; +function ap(F) { + return function (fa) { return function (fab) { return F.ap(fab, fa); }; }; +} +exports.ap = ap; +function chain(F) { + return function (f) { return function (fa) { return F.chain(fa, f); }; }; +} +exports.chain = chain; +function bimap(F) { + return function (f, g) { return function (fea) { return F.bimap(fea, f, g); }; }; +} +exports.bimap = bimap; +function mapLeft(F) { + return function (f) { return function (fea) { return F.mapLeft(fea, f); }; }; +} +exports.mapLeft = mapLeft; +function extend(F) { + return function (f) { return function (wa) { return F.extend(wa, f); }; }; +} +exports.extend = extend; +function reduce(F) { + return function (b, f) { return function (fa) { return F.reduce(fa, b, f); }; }; +} +exports.reduce = reduce; +function foldMap(F) { + return function (M) { + var foldMapM = F.foldMap(M); + return function (f) { return function (fa) { return foldMapM(fa, f); }; }; + }; +} +exports.foldMap = foldMap; +function reduceRight(F) { + return function (b, f) { return function (fa) { return F.reduceRight(fa, b, f); }; }; +} +exports.reduceRight = reduceRight; +function reduceWithIndex(F) { + return function (b, f) { return function (fa) { return F.reduceWithIndex(fa, b, f); }; }; +} +exports.reduceWithIndex = reduceWithIndex; +function foldMapWithIndex(F) { + return function (M) { + var foldMapWithIndexM = F.foldMapWithIndex(M); + return function (f) { return function (fa) { return foldMapWithIndexM(fa, f); }; }; + }; +} +exports.foldMapWithIndex = foldMapWithIndex; +function reduceRightWithIndex(F) { + return function (b, f) { return function (fa) { return F.reduceRightWithIndex(fa, b, f); }; }; +} +exports.reduceRightWithIndex = reduceRightWithIndex; +function alt(F) { + return function (that) { return function (fa) { return F.alt(fa, that); }; }; +} +exports.alt = alt; +function filter(F) { + return function (predicate) { return function (fa) { return F.filter(fa, predicate); }; }; +} +exports.filter = filter; +function filterMap(F) { + return function (f) { return function (fa) { return F.filterMap(fa, f); }; }; +} +exports.filterMap = filterMap; +function partition(F) { + return function (f) { return function (fa) { return F.partition(fa, f); }; }; +} +exports.partition = partition; +function partitionMap(F) { + return function (f) { return function (fa) { return F.partitionMap(fa, f); }; }; +} +exports.partitionMap = partitionMap; +function filterWithIndex(F) { + return function (predicate) { return function (fa) { return F.filterWithIndex(fa, predicate); }; }; +} +exports.filterWithIndex = filterWithIndex; +function filterMapWithIndex(F) { + return function (f) { return function (fa) { return F.filterMapWithIndex(fa, f); }; }; +} +exports.filterMapWithIndex = filterMapWithIndex; +function partitionWithIndex(F) { + return function (f) { return function (fa) { return F.partitionWithIndex(fa, f); }; }; +} +exports.partitionWithIndex = partitionWithIndex; +function partitionMapWithIndex(F) { + return function (f) { return function (fa) { return F.partitionMapWithIndex(fa, f); }; }; +} +exports.partitionMapWithIndex = partitionMapWithIndex; +function promap(F) { + return function (f, g) { return function (fbc) { return F.promap(fbc, f, g); }; }; +} +exports.promap = promap; +function compose(F) { + return function (ea) { return function (ab) { return F.compose(ab, ea); }; }; +} +exports.compose = compose; +var isFunctor = function (I) { return typeof I.map === 'function'; }; +var isContravariant = function (I) { return typeof I.contramap === 'function'; }; +var isFunctorWithIndex = function (I) { return typeof I.mapWithIndex === 'function'; }; +var isApply = function (I) { return typeof I.ap === 'function'; }; +var isChain = function (I) { return typeof I.chain === 'function'; }; +var isBifunctor = function (I) { return typeof I.bimap === 'function'; }; +var isExtend = function (I) { return typeof I.extend === 'function'; }; +var isFoldable = function (I) { return typeof I.reduce === 'function'; }; +var isFoldableWithIndex = function (I) { return typeof I.reduceWithIndex === 'function'; }; +var isAlt = function (I) { return typeof I.alt === 'function'; }; +var isCompactable = function (I) { return typeof I.compact === 'function'; }; +var isFilterable = function (I) { return typeof I.filter === 'function'; }; +var isFilterableWithIndex = function (I) { + return typeof I.filterWithIndex === 'function'; +}; +var isProfunctor = function (I) { return typeof I.promap === 'function'; }; +var isSemigroupoid = function (I) { return typeof I.compose === 'function'; }; +var isMonadThrow = function (I) { return typeof I.throwError === 'function'; }; +/** @deprecated */ +function pipeable(I) { + var r = {}; + if (isFunctor(I)) { + r.map = map(I); + } + if (isContravariant(I)) { + r.contramap = contramap(I); + } + if (isFunctorWithIndex(I)) { + r.mapWithIndex = mapWithIndex(I); + } + if (isApply(I)) { + r.ap = ap(I); + r.apFirst = (0, Apply_1.apFirst)(I); + r.apSecond = (0, Apply_1.apSecond)(I); + } + if (isChain(I)) { + r.chain = chain(I); + r.chainFirst = (0, Chain_1.chainFirst)(I); + r.flatten = r.chain(function_1.identity); + } + if (isBifunctor(I)) { + r.bimap = bimap(I); + r.mapLeft = mapLeft(I); + } + if (isExtend(I)) { + r.extend = extend(I); + r.duplicate = r.extend(function_1.identity); + } + if (isFoldable(I)) { + r.reduce = reduce(I); + r.foldMap = foldMap(I); + r.reduceRight = reduceRight(I); + } + if (isFoldableWithIndex(I)) { + r.reduceWithIndex = reduceWithIndex(I); + r.foldMapWithIndex = foldMapWithIndex(I); + r.reduceRightWithIndex = reduceRightWithIndex(I); + } + if (isAlt(I)) { + r.alt = alt(I); + } + if (isCompactable(I)) { + r.compact = I.compact; + r.separate = I.separate; + } + if (isFilterable(I)) { + r.filter = filter(I); + r.filterMap = filterMap(I); + r.partition = partition(I); + r.partitionMap = partitionMap(I); + } + if (isFilterableWithIndex(I)) { + r.filterWithIndex = filterWithIndex(I); + r.filterMapWithIndex = filterMapWithIndex(I); + r.partitionWithIndex = partitionWithIndex(I); + r.partitionMapWithIndex = partitionMapWithIndex(I); + } + if (isProfunctor(I)) { + r.promap = promap(I); + } + if (isSemigroupoid(I)) { + r.compose = compose(I); + } + if (isMonadThrow(I)) { + var fromOption = function (onNone) { return function (ma) { + return ma._tag === 'None' ? I.throwError(onNone()) : I.of(ma.value); + }; }; + var fromEither = function (ma) { + return ma._tag === 'Left' ? I.throwError(ma.left) : I.of(ma.right); + }; + var fromPredicate = function (predicate, onFalse) { + return function (a) { + return predicate(a) ? I.of(a) : I.throwError(onFalse(a)); + }; + }; + var filterOrElse = function (predicate, onFalse) { + return function (ma) { + return I.chain(ma, function (a) { return (predicate(a) ? I.of(a) : I.throwError(onFalse(a))); }); + }; + }; + r.fromOption = fromOption; + r.fromEither = fromEither; + r.fromPredicate = fromPredicate; + r.filterOrElse = filterOrElse; + } + return r; +} +exports.pipeable = pipeable; +/** + * Use [`pipe`](https://gcanti.github.io/fp-ts/modules/function.ts.html#pipe) from `function` module instead. + * + * @since 2.0.0 + * @deprecated + */ +exports.pipe = function_1.pipe; + + +/***/ }), + +/***/ 5189: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.endsWith = exports.startsWith = exports.includes = exports.split = exports.size = exports.isEmpty = exports.slice = exports.trimRight = exports.trimLeft = exports.trim = exports.replace = exports.toLowerCase = exports.toUpperCase = exports.isString = exports.Show = exports.Ord = exports.Monoid = exports.empty = exports.Semigroup = exports.Eq = void 0; +var ReadonlyNonEmptyArray_1 = __nccwpck_require__(8630); +// ------------------------------------------------------------------------------------- +// instances +// ------------------------------------------------------------------------------------- +/** + * @example + * import * as S from 'fp-ts/string' + * + * assert.deepStrictEqual(S.Eq.equals('a', 'a'), true) + * assert.deepStrictEqual(S.Eq.equals('a', 'b'), false) + * + * @category instances + * @since 2.10.0 + */ +exports.Eq = { + equals: function (first, second) { return first === second; } +}; +/** + * `string` semigroup under concatenation. + * + * @example + * import * as S from 'fp-ts/string' + * + * assert.deepStrictEqual(S.Semigroup.concat('a', 'b'), 'ab') + * + * @category instances + * @since 2.10.0 + */ +exports.Semigroup = { + concat: function (first, second) { return first + second; } +}; +/** + * An empty `string`. + * + * @since 2.10.0 + */ +exports.empty = ''; +/** + * `string` monoid under concatenation. + * + * The `empty` value is `''`. + * + * @example + * import * as S from 'fp-ts/string' + * + * assert.deepStrictEqual(S.Monoid.concat('a', 'b'), 'ab') + * assert.deepStrictEqual(S.Monoid.concat('a', S.Monoid.empty), 'a') + * + * @category instances + * @since 2.10.0 + */ +exports.Monoid = { + concat: exports.Semigroup.concat, + empty: exports.empty +}; +/** + * @example + * import * as S from 'fp-ts/string' + * + * assert.deepStrictEqual(S.Ord.compare('a', 'a'), 0) + * assert.deepStrictEqual(S.Ord.compare('a', 'b'), -1) + * assert.deepStrictEqual(S.Ord.compare('b', 'a'), 1) + * + * @category instances + * @since 2.10.0 + */ +exports.Ord = { + equals: exports.Eq.equals, + compare: function (first, second) { return (first < second ? -1 : first > second ? 1 : 0); } +}; +/** + * @example + * import * as S from 'fp-ts/string' + * + * assert.deepStrictEqual(S.Show.show('a'), '"a"') + * + * @category instances + * @since 2.10.0 + */ +exports.Show = { + show: function (s) { return JSON.stringify(s); } +}; +// ------------------------------------------------------------------------------------- +// refinements +// ------------------------------------------------------------------------------------- +/** + * @example + * import * as S from 'fp-ts/string' + * + * assert.deepStrictEqual(S.isString('a'), true) + * assert.deepStrictEqual(S.isString(1), false) + * + * @category refinements + * @since 2.11.0 + */ +var isString = function (u) { return typeof u === 'string'; }; +exports.isString = isString; +// ------------------------------------------------------------------------------------- +// combinators +// ------------------------------------------------------------------------------------- +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('a', S.toUpperCase), 'A') + * + * @since 2.11.0 + */ +var toUpperCase = function (s) { return s.toUpperCase(); }; +exports.toUpperCase = toUpperCase; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('A', S.toLowerCase), 'a') + * + * @since 2.11.0 + */ +var toLowerCase = function (s) { return s.toLowerCase(); }; +exports.toLowerCase = toLowerCase; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('abc', S.replace('b', 'd')), 'adc') + * + * @since 2.11.0 + */ +var replace = function (searchValue, replaceValue) { + return function (s) { + return s.replace(searchValue, replaceValue); + }; +}; +exports.replace = replace; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe(' a ', S.trim), 'a') + * + * @since 2.11.0 + */ +var trim = function (s) { return s.trim(); }; +exports.trim = trim; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe(' a ', S.trimLeft), 'a ') + * + * @since 2.11.0 + */ +var trimLeft = function (s) { return s.trimLeft(); }; +exports.trimLeft = trimLeft; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe(' a ', S.trimRight), ' a') + * + * @since 2.11.0 + */ +var trimRight = function (s) { return s.trimRight(); }; +exports.trimRight = trimRight; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('abcd', S.slice(1, 3)), 'bc') + * + * @since 2.11.0 + */ +var slice = function (start, end) { + return function (s) { + return s.slice(start, end); + }; +}; +exports.slice = slice; +// ------------------------------------------------------------------------------------- +// utils +// ------------------------------------------------------------------------------------- +/** + * Test whether a `string` is empty. + * + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('', S.isEmpty), true) + * assert.deepStrictEqual(pipe('a', S.isEmpty), false) + * + * @since 2.10.0 + */ +var isEmpty = function (s) { return s.length === 0; }; +exports.isEmpty = isEmpty; +/** + * Calculate the number of characters in a `string`. + * + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('abc', S.size), 3) + * + * @since 2.10.0 + */ +var size = function (s) { return s.length; }; +exports.size = size; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('abc', S.split('')), ['a', 'b', 'c']) + * assert.deepStrictEqual(pipe('', S.split('')), ['']) + * + * @since 2.11.0 + */ +var split = function (separator) { + return function (s) { + var out = s.split(separator); + return (0, ReadonlyNonEmptyArray_1.isNonEmpty)(out) ? out : [s]; + }; +}; +exports.split = split; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('abc', S.includes('b')), true) + * assert.deepStrictEqual(pipe('abc', S.includes('d')), false) + * + * @since 2.11.0 + */ +var includes = function (searchString, position) { + return function (s) { + return s.includes(searchString, position); + }; +}; +exports.includes = includes; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('abc', S.startsWith('a')), true) + * assert.deepStrictEqual(pipe('bc', S.startsWith('a')), false) + * + * @since 2.11.0 + */ +var startsWith = function (searchString, position) { + return function (s) { + return s.startsWith(searchString, position); + }; +}; +exports.startsWith = startsWith; +/** + * @example + * import * as S from 'fp-ts/string' + * import { pipe } from 'fp-ts/function' + * + * assert.deepStrictEqual(pipe('abc', S.endsWith('c')), true) + * assert.deepStrictEqual(pipe('ab', S.endsWith('c')), false) + * + * @since 2.11.0 + */ +var endsWith = function (searchString, position) { + return function (s) { + return s.endsWith(searchString, position); + }; +}; +exports.endsWith = endsWith; + + +/***/ }), + +/***/ 51: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.reporter = exports.formatValidationErrors = exports.formatValidationError = exports.TYPE_MAX_LEN = void 0; +/** + * An [io-ts Reporter](https://gcanti.github.io/io-ts/modules/Reporter.ts.html#reporter-interface). + * + * @example + * + * import * as t from 'io-ts'; + * import Reporter from 'io-ts-reporters'; + * + * const User = t.interface({ name: t.string }); + * + * assert.deepEqual( + * Reporter.report(User.decode({ nam: 'Jane' })), + * ['Expecting string at name but instead got: undefined'], + * ) + * assert.deepEqual( Reporter.report(User.decode({ name: 'Jane' })), []) + * + * @since 1.2.0 + */ +var A = __nccwpck_require__(3834); +var E = __nccwpck_require__(7534); +var NEA = __nccwpck_require__(240); +var O = __nccwpck_require__(2569); +var R = __nccwpck_require__(2653); +var pipeable_1 = __nccwpck_require__(6837); var t = __nccwpck_require__(5428); var utils_1 = __nccwpck_require__(6753); var isUnionType = function (_a) { @@ -16425,6 +23586,8 @@ var __extends = (this && this.__extends) || (function () { return extendStatics(d, b); }; return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); @@ -16441,16 +23604,18 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; -var __spreadArrays = (this && this.__spreadArrays) || function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.partial = exports.PartialType = exports.type = exports.InterfaceType = exports.array = exports.ArrayType = exports.recursion = exports.RecursiveType = exports.Int = exports.brand = exports.RefinementType = exports.keyof = exports.KeyofType = exports.literal = exports.LiteralType = exports["void"] = exports.undefined = exports["null"] = exports.UnknownRecord = exports.AnyDictionaryType = exports.UnknownArray = exports.AnyArrayType = exports.boolean = exports.BooleanType = exports.bigint = exports.BigIntType = exports.number = exports.NumberType = exports.string = exports.StringType = exports.unknown = exports.UnknownType = exports.voidType = exports.VoidType = exports.UndefinedType = exports.nullType = exports.NullType = exports.getIndex = exports.getTags = exports.emptyTags = exports.mergeAll = exports.getDomainKeys = exports.appendContext = exports.getContextEntry = exports.getFunctionName = exports.identity = exports.Type = exports.success = exports.failure = exports.failures = void 0; -exports.alias = exports.clean = exports.StrictType = exports.dictionary = exports.Integer = exports.refinement = exports.object = exports.ObjectType = exports.Dictionary = exports.any = exports.AnyType = exports.never = exports.NeverType = exports.getDefaultContext = exports.getValidationError = exports["interface"] = exports.Array = exports.taggedUnion = exports.TaggedUnionType = exports.Function = exports.FunctionType = exports.exact = exports.ExactType = exports.strict = exports.readonlyArray = exports.ReadonlyArrayType = exports.readonly = exports.ReadonlyType = exports.tuple = exports.TupleType = exports.intersection = exports.IntersectionType = exports.union = exports.UnionType = exports.record = exports.DictionaryType = void 0; +exports.alias = exports.clean = exports.StrictType = exports.dictionary = exports.object = exports.ObjectType = exports.Dictionary = exports.getDefaultContext = exports.getValidationError = exports["interface"] = exports.Array = exports.taggedUnion = exports.TaggedUnionType = exports.Integer = exports.refinement = exports.any = exports.AnyType = exports.never = exports.NeverType = exports.Function = exports.FunctionType = exports.exact = exports.ExactType = exports.strict = exports.readonlyArray = exports.ReadonlyArrayType = exports.readonly = exports.ReadonlyType = exports.tuple = exports.TupleType = exports.intersection = exports.IntersectionType = exports.union = exports.UnionType = exports.record = exports.DictionaryType = void 0; /** * @since 1.0.0 */ @@ -16465,7 +23630,7 @@ exports.failures = Either_1.left; * @since 1.0.0 */ var failure = function (value, context, message) { - return exports.failures([{ value: value, context: context, message: message }]); + return (0, exports.failures)([{ value: value, context: context, message: message }]); }; exports.failure = failure; /** @@ -16498,10 +23663,10 @@ var Type = /** @class */ (function () { */ Type.prototype.pipe = function (ab, name) { var _this = this; - if (name === void 0) { name = "pipe(" + this.name + ", " + ab.name + ")"; } + if (name === void 0) { name = "pipe(".concat(this.name, ", ").concat(ab.name, ")"); } return new Type(name, ab.is, function (i, c) { var e = _this.validate(i, c); - if (Either_1.isLeft(e)) { + if ((0, Either_1.isLeft)(e)) { return e; } return ab.validate(e.right, c); @@ -16541,7 +23706,7 @@ exports.identity = identity; * @since 1.0.0 */ function getFunctionName(f) { - return f.displayName || f.name || ""; + return f.displayName || f.name || ""); } exports.getFunctionName = getFunctionName; /** @@ -16573,7 +23738,7 @@ function pushAll(xs, ys) { var hasOwnProperty = Object.prototype.hasOwnProperty; function getNameFromProps(props) { return Object.keys(props) - .map(function (k) { return k + ": " + props[k].name; }) + .map(function (k) { return "".concat(k, ": ").concat(props[k].name); }) .join(', '); } function useIdentity(codecs) { @@ -16585,47 +23750,20 @@ function useIdentity(codecs) { return true; } function getInterfaceTypeName(props) { - return "{ " + getNameFromProps(props) + " }"; + return "{ ".concat(getNameFromProps(props), " }"); } function getPartialTypeName(inner) { - return "Partial<" + inner + ">"; + return "Partial<".concat(inner, ">"); } function enumerableRecord(keys, domain, codomain, name) { - if (name === void 0) { name = "{ [K in " + domain.name + "]: " + codomain.name + " }"; } + if (name === void 0) { name = "{ [K in ".concat(domain.name, "]: ").concat(codomain.name, " }"); } var len = keys.length; - return new DictionaryType(name, function (u) { return exports.UnknownRecord.is(u) && keys.every(function (k) { return codomain.is(u[k]); }); }, function (u, c) { - var e = exports.UnknownRecord.validate(u, c); - if (Either_1.isLeft(e)) { - return e; - } - var o = e.right; - var a = {}; - var errors = []; - var changed = false; - for (var i = 0; i < len; i++) { - var k = keys[i]; - var ok = o[k]; - var codomainResult = codomain.validate(ok, appendContext(c, k, codomain, ok)); - if (Either_1.isLeft(codomainResult)) { - pushAll(errors, codomainResult.left); - } - else { - var vok = codomainResult.right; - changed = changed || vok !== ok; - a[k] = vok; - } - } - return errors.length > 0 ? exports.failures(errors) : exports.success((changed || Object.keys(o).length !== len ? a : o)); - }, codomain.encode === exports.identity - ? exports.identity - : function (a) { - var s = {}; - for (var i = 0; i < len; i++) { - var k = keys[i]; - s[k] = codomain.encode(a[k]); - } - return s; - }, domain, codomain); + var props = {}; + for (var i = 0; i < len; i++) { + props[keys[i]] = codomain; + } + var exactCodec = (0, exports.strict)(props, name); + return new DictionaryType(name, function (u) { return exactCodec.is(u); }, exactCodec.validate, exactCodec.encode, domain, codomain); } /** * @internal @@ -16643,16 +23781,32 @@ function getDomainKeys(domain) { } else if (isUnionC(domain)) { var keys = domain.types.map(function (type) { return getDomainKeys(type); }); - return keys.some(undefinedType.is) ? undefined : Object.assign.apply(Object, __spreadArrays([{}], keys)); + return keys.some(undefinedType.is) ? undefined : Object.assign.apply(Object, __spreadArray([{}], keys, false)); } return undefined; } exports.getDomainKeys = getDomainKeys; +function stripNonDomainKeys(o, domain) { + var keys = Object.keys(o); + var len = keys.length; + var shouldStrip = false; + var r = {}; + for (var i = 0; i < len; i++) { + var k = keys[i]; + if (domain.is(k)) { + r[k] = o[k]; + } + else { + shouldStrip = true; + } + } + return shouldStrip ? r : o; +} function nonEnumerableRecord(domain, codomain, name) { - if (name === void 0) { name = "{ [K in " + domain.name + "]: " + codomain.name + " }"; } + if (name === void 0) { name = "{ [K in ".concat(domain.name, "]: ").concat(codomain.name, " }"); } return new DictionaryType(name, function (u) { if (exports.UnknownRecord.is(u)) { - return Object.keys(u).every(function (k) { return domain.is(k) && codomain.is(u[k]); }); + return Object.keys(u).every(function (k) { return !domain.is(k) || codomain.is(u[k]); }); } return isAnyC(codomain) && Array.isArray(u); }, function (u, c) { @@ -16666,15 +23820,15 @@ function nonEnumerableRecord(domain, codomain, name) { var k = keys[i]; var ok = u[k]; var domainResult = domain.validate(k, appendContext(c, k, domain, k)); - if (Either_1.isLeft(domainResult)) { - pushAll(errors, domainResult.left); + if ((0, Either_1.isLeft)(domainResult)) { + changed = true; } else { var vk = domainResult.right; changed = changed || vk !== k; k = vk; var codomainResult = codomain.validate(ok, appendContext(c, k, codomain, ok)); - if (Either_1.isLeft(codomainResult)) { + if ((0, Either_1.isLeft)(codomainResult)) { pushAll(errors, codomainResult.left); } else { @@ -16684,17 +23838,17 @@ function nonEnumerableRecord(domain, codomain, name) { } } } - return errors.length > 0 ? exports.failures(errors) : exports.success((changed ? a : u)); + return errors.length > 0 ? (0, exports.failures)(errors) : (0, exports.success)((changed ? a : u)); } if (isAnyC(codomain) && Array.isArray(u)) { - return exports.success(u); + return (0, exports.success)(u); } - return exports.failure(u, c); + return (0, exports.failure)(u, c); }, domain.encode === exports.identity && codomain.encode === exports.identity - ? exports.identity + ? function (a) { return stripNonDomainKeys(a, domain); } : function (a) { var s = {}; - var keys = Object.keys(a); + var keys = Object.keys(stripNonDomainKeys(a, domain)); var len = keys.length; for (var i = 0; i < len; i++) { var k = keys[i]; @@ -16709,6 +23863,7 @@ function getUnionName(codecs) { /** * @internal */ +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types function mergeAll(base, us) { var equal = true; var primitive = true; @@ -16732,7 +23887,7 @@ function mergeAll(base, us) { for (var _a = 0, us_2 = us; _a < us_2.length; _a++) { var u = us_2[_a]; for (var k in u) { - if (!r.hasOwnProperty(k) || baseIsNotADictionary || u[k] !== base[k]) { + if (!hasOwnProperty.call(r, k) || baseIsNotADictionary || u[k] !== base[k]) { r[k] = u[k]; } } @@ -16770,12 +23925,12 @@ function stripKeys(o, props) { } function getExactTypeName(codec) { if (isTypeC(codec)) { - return "{| " + getNameFromProps(codec.props) + " |}"; + return "{| ".concat(getNameFromProps(codec.props), " |}"); } else if (isPartialC(codec)) { - return getPartialTypeName("{| " + getNameFromProps(codec.props) + " |}"); + return getPartialTypeName("{| ".concat(getNameFromProps(codec.props), " |}")); } - return "Exact<" + codec.name + ">"; + return "Exact<".concat(codec.name, ">"); } function isNonEmpty(as) { return as.length > 0; @@ -16803,7 +23958,7 @@ function mergeTags(a, b) { } var r = Object.assign({}, a); for (var k in b) { - if (a.hasOwnProperty(k)) { + if (hasOwnProperty.call(a, k)) { var intersection_1 = intersect(a[k], b[k]); if (isNonEmpty(intersection_1)) { r[k] = intersection_1; @@ -16825,7 +23980,7 @@ function intersectTags(a, b) { } var r = exports.emptyTags; for (var k in a) { - if (b.hasOwnProperty(k)) { + if (hasOwnProperty.call(b, k)) { var intersection_2 = intersect(a[k], b[k]); if (intersection_2.length === 0) { if (r === exports.emptyTags) { @@ -16964,7 +24119,7 @@ exports.getIndex = getIndex; var NullType = /** @class */ (function (_super) { __extends(NullType, _super); function NullType() { - var _this = _super.call(this, 'null', function (u) { return u === null; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; + var _this = _super.call(this, 'null', function (u) { return u === null; }, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; /** * @since 1.0.0 */ @@ -16986,7 +24141,7 @@ exports["null"] = exports.nullType; var UndefinedType = /** @class */ (function (_super) { __extends(UndefinedType, _super); function UndefinedType() { - var _this = _super.call(this, 'undefined', function (u) { return u === void 0; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; + var _this = _super.call(this, 'undefined', function (u) { return u === void 0; }, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; /** * @since 1.0.0 */ @@ -17047,7 +24202,7 @@ exports.unknown = new UnknownType(); var StringType = /** @class */ (function (_super) { __extends(StringType, _super); function StringType() { - var _this = _super.call(this, 'string', function (u) { return typeof u === 'string'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; + var _this = _super.call(this, 'string', function (u) { return typeof u === 'string'; }, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; /** * @since 1.0.0 */ @@ -17068,7 +24223,7 @@ exports.string = new StringType(); var NumberType = /** @class */ (function (_super) { __extends(NumberType, _super); function NumberType() { - var _this = _super.call(this, 'number', function (u) { return typeof u === 'number'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; + var _this = _super.call(this, 'number', function (u) { return typeof u === 'number'; }, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; /** * @since 1.0.0 */ @@ -17091,7 +24246,7 @@ var BigIntType = /** @class */ (function (_super) { function BigIntType() { var _this = _super.call(this, 'bigint', // tslint:disable-next-line: valid-typeof - function (u) { return typeof u === 'bigint'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; + function (u) { return typeof u === 'bigint'; }, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; /** * @since 1.0.0 */ @@ -17112,7 +24267,7 @@ exports.bigint = new BigIntType(); var BooleanType = /** @class */ (function (_super) { __extends(BooleanType, _super); function BooleanType() { - var _this = _super.call(this, 'boolean', function (u) { return typeof u === 'boolean'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; + var _this = _super.call(this, 'boolean', function (u) { return typeof u === 'boolean'; }, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; /** * @since 1.0.0 */ @@ -17133,7 +24288,7 @@ exports.boolean = new BooleanType(); var AnyArrayType = /** @class */ (function (_super) { __extends(AnyArrayType, _super); function AnyArrayType() { - var _this = _super.call(this, 'UnknownArray', Array.isArray, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; + var _this = _super.call(this, 'UnknownArray', Array.isArray, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; /** * @since 1.0.0 */ @@ -17155,10 +24310,7 @@ exports.Array = exports.UnknownArray; var AnyDictionaryType = /** @class */ (function (_super) { __extends(AnyDictionaryType, _super); function AnyDictionaryType() { - var _this = _super.call(this, 'UnknownRecord', function (u) { - var s = Object.prototype.toString.call(u); - return s === '[object Object]' || s === '[object Window]'; - }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; + var _this = _super.call(this, 'UnknownRecord', function (u) { return u !== null && typeof u === 'object' && !Array.isArray(u); }, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; /** * @since 1.0.0 */ @@ -17197,7 +24349,7 @@ exports.LiteralType = LiteralType; function literal(value, name) { if (name === void 0) { name = JSON.stringify(value); } var is = function (u) { return u === value; }; - return new LiteralType(name, is, function (u, c) { return (is(u) ? exports.success(value) : exports.failure(u, c)); }, exports.identity, value); + return new LiteralType(name, is, function (u, c) { return (is(u) ? (0, exports.success)(value) : (0, exports.failure)(u, c)); }, exports.identity, value); } exports.literal = literal; /** @@ -17226,7 +24378,7 @@ function keyof(keys, name) { .map(function (k) { return JSON.stringify(k); }) .join(' | '); } var is = function (u) { return exports.string.is(u) && hasOwnProperty.call(keys, u); }; - return new KeyofType(name, is, function (u, c) { return (is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity, keys); + return new KeyofType(name, is, function (u, c) { return (is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity, keys); } exports.keyof = keyof; // ------------------------------------------------------------------------------------- @@ -17255,7 +24407,6 @@ exports.RefinementType = RefinementType; * @since 1.8.1 */ function brand(codec, predicate, name) { - // tslint:disable-next-line: deprecation return refinement(codec, predicate, name); } exports.brand = brand; @@ -17329,10 +24480,10 @@ exports.ArrayType = ArrayType; * @since 1.0.0 */ function array(item, name) { - if (name === void 0) { name = "Array<" + item.name + ">"; } + if (name === void 0) { name = "Array<".concat(item.name, ">"); } return new ArrayType(name, function (u) { return exports.UnknownArray.is(u) && u.every(item.is); }, function (u, c) { var e = exports.UnknownArray.validate(u, c); - if (Either_1.isLeft(e)) { + if ((0, Either_1.isLeft)(e)) { return e; } var us = e.right; @@ -17342,7 +24493,7 @@ function array(item, name) { for (var i = 0; i < len; i++) { var ui = us[i]; var result = item.validate(ui, appendContext(c, String(i), item, ui)); - if (Either_1.isLeft(result)) { + if ((0, Either_1.isLeft)(result)) { pushAll(errors, result.left); } else { @@ -17355,7 +24506,7 @@ function array(item, name) { } } } - return errors.length > 0 ? exports.failures(errors) : exports.success(as); + return errors.length > 0 ? (0, exports.failures)(errors) : (0, exports.success)(as); }, item.encode === exports.identity ? exports.identity : function (a) { return a.map(item.encode); }, item); } exports.array = array; @@ -17399,7 +24550,7 @@ function type(props, name) { return false; }, function (u, c) { var e = exports.UnknownRecord.validate(u, c); - if (Either_1.isLeft(e)) { + if ((0, Either_1.isLeft)(e)) { return e; } var o = e.right; @@ -17410,7 +24561,7 @@ function type(props, name) { var ak = a[k]; var type_1 = types[i]; var result = type_1.validate(ak, appendContext(c, k, type_1, ak)); - if (Either_1.isLeft(result)) { + if ((0, Either_1.isLeft)(result)) { pushAll(errors, result.left); } else { @@ -17424,7 +24575,7 @@ function type(props, name) { } } } - return errors.length > 0 ? exports.failures(errors) : exports.success(a); + return errors.length > 0 ? (0, exports.failures)(errors) : (0, exports.success)(a); }, useIdentity(types) ? exports.identity : function (a) { @@ -17481,7 +24632,7 @@ function partial(props, name) { return false; }, function (u, c) { var e = exports.UnknownRecord.validate(u, c); - if (Either_1.isLeft(e)) { + if ((0, Either_1.isLeft)(e)) { return e; } var o = e.right; @@ -17492,7 +24643,7 @@ function partial(props, name) { var ak = a[k]; var type_2 = props[k]; var result = type_2.validate(ak, appendContext(c, k, type_2, ak)); - if (Either_1.isLeft(result)) { + if ((0, Either_1.isLeft)(result)) { if (ak !== undefined) { pushAll(errors, result.left); } @@ -17508,7 +24659,7 @@ function partial(props, name) { } } } - return errors.length > 0 ? exports.failures(errors) : exports.success(a); + return errors.length > 0 ? (0, exports.failures)(errors) : (0, exports.success)(a); }, useIdentity(types) ? exports.identity : function (a) { @@ -17597,13 +24748,13 @@ function union(codecs, name) { return false; }, function (u, c) { var e = exports.UnknownRecord.validate(u, c); - if (Either_1.isLeft(e)) { + if ((0, Either_1.isLeft)(e)) { return e; } var r = e.right; var i = find_1(r[tag_1]); if (i === undefined) { - return exports.failure(u, c); + return (0, exports.failure)(u, c); } var codec = codecs[i]; return codec.validate(r, appendContext(c, String(i), codec, r)); @@ -17613,7 +24764,7 @@ function union(codecs, name) { var i = find_1(a[tag_1]); if (i === undefined) { // https://github.com/gcanti/io-ts/pull/305 - throw new Error("no codec found to encode value in union codec " + name); + throw new Error("no codec found to encode value in union codec ".concat(name)); } else { return codecs[i].encode(a); @@ -17626,14 +24777,14 @@ function union(codecs, name) { for (var i = 0; i < codecs.length; i++) { var codec = codecs[i]; var result = codec.validate(u, appendContext(c, String(i), codec, u)); - if (Either_1.isLeft(result)) { + if ((0, Either_1.isLeft)(result)) { pushAll(errors, result.left); } else { - return exports.success(result.right); + return (0, exports.success)(result.right); } } - return exports.failures(errors); + return (0, exports.failures)(errors); }, useIdentity(codecs) ? exports.identity : function (a) { @@ -17644,7 +24795,7 @@ function union(codecs, name) { } } // https://github.com/gcanti/io-ts/pull/305 - throw new Error("no codec found to encode value in union type " + name); + throw new Error("no codec found to encode value in union type ".concat(name)); }, codecs); } } @@ -17667,7 +24818,7 @@ var IntersectionType = /** @class */ (function (_super) { }(Type)); exports.IntersectionType = IntersectionType; function intersection(codecs, name) { - if (name === void 0) { name = "(" + codecs.map(function (type) { return type.name; }).join(' & ') + ")"; } + if (name === void 0) { name = "(".concat(codecs.map(function (type) { return type.name; }).join(' & '), ")"); } var len = codecs.length; return new IntersectionType(name, function (u) { return codecs.every(function (type) { return type.is(u); }); }, codecs.length === 0 ? exports.success @@ -17677,14 +24828,14 @@ function intersection(codecs, name) { for (var i = 0; i < len; i++) { var codec = codecs[i]; var result = codec.validate(u, appendContext(c, String(i), codec, u)); - if (Either_1.isLeft(result)) { + if ((0, Either_1.isLeft)(result)) { pushAll(errors, result.left); } else { us.push(result.right); } } - return errors.length > 0 ? exports.failures(errors) : exports.success(mergeAll(u, us)); + return errors.length > 0 ? (0, exports.failures)(errors) : (0, exports.success)(mergeAll(u, us)); }, codecs.length === 0 ? exports.identity : function (a) { @@ -17710,26866 +24861,43968 @@ var TupleType = /** @class */ (function (_super) { }(Type)); exports.TupleType = TupleType; function tuple(codecs, name) { - if (name === void 0) { name = "[" + codecs.map(function (type) { return type.name; }).join(', ') + "]"; } + if (name === void 0) { name = "[".concat(codecs.map(function (type) { return type.name; }).join(', '), "]"); } var len = codecs.length; return new TupleType(name, function (u) { return exports.UnknownArray.is(u) && u.length === len && codecs.every(function (type, i) { return type.is(u[i]); }); }, function (u, c) { var e = exports.UnknownArray.validate(u, c); - if (Either_1.isLeft(e)) { + if ((0, Either_1.isLeft)(e)) { + return e; + } + var us = e.right; + var as = us.length > len ? us.slice(0, len) : us; // strip additional components + var errors = []; + for (var i = 0; i < len; i++) { + var a = us[i]; + var type_3 = codecs[i]; + var result = type_3.validate(a, appendContext(c, String(i), type_3, a)); + if ((0, Either_1.isLeft)(result)) { + pushAll(errors, result.left); + } + else { + var va = result.right; + if (va !== a) { + /* istanbul ignore next */ + if (as === us) { + as = us.slice(); + } + as[i] = va; + } + } + } + return errors.length > 0 ? (0, exports.failures)(errors) : (0, exports.success)(as); + }, useIdentity(codecs) ? exports.identity : function (a) { return codecs.map(function (type, i) { return type.encode(a[i]); }); }, codecs); +} +exports.tuple = tuple; +/** + * @since 1.0.0 + */ +var ReadonlyType = /** @class */ (function (_super) { + __extends(ReadonlyType, _super); + function ReadonlyType(name, is, validate, encode, type) { + var _this = _super.call(this, name, is, validate, encode) || this; + _this.type = type; + /** + * @since 1.0.0 + */ + _this._tag = 'ReadonlyType'; + return _this; + } + return ReadonlyType; +}(Type)); +exports.ReadonlyType = ReadonlyType; +/** + * @category combinators + * @since 1.0.0 + */ +function readonly(codec, name) { + if (name === void 0) { name = "Readonly<".concat(codec.name, ">"); } + return new ReadonlyType(name, codec.is, codec.validate, codec.encode, codec); +} +exports.readonly = readonly; +/** + * @since 1.0.0 + */ +var ReadonlyArrayType = /** @class */ (function (_super) { + __extends(ReadonlyArrayType, _super); + function ReadonlyArrayType(name, is, validate, encode, type) { + var _this = _super.call(this, name, is, validate, encode) || this; + _this.type = type; + /** + * @since 1.0.0 + */ + _this._tag = 'ReadonlyArrayType'; + return _this; + } + return ReadonlyArrayType; +}(Type)); +exports.ReadonlyArrayType = ReadonlyArrayType; +/** + * @category combinators + * @since 1.0.0 + */ +function readonlyArray(item, name) { + if (name === void 0) { name = "ReadonlyArray<".concat(item.name, ">"); } + var codec = array(item); + return new ReadonlyArrayType(name, codec.is, codec.validate, codec.encode, item); +} +exports.readonlyArray = readonlyArray; +/** + * Strips additional properties, equivalent to `exact(type(props))`. + * + * @category combinators + * @since 1.0.0 + */ +var strict = function (props, name) { return exact(type(props), name); }; +exports.strict = strict; +/** + * @since 1.1.0 + */ +var ExactType = /** @class */ (function (_super) { + __extends(ExactType, _super); + function ExactType(name, is, validate, encode, type) { + var _this = _super.call(this, name, is, validate, encode) || this; + _this.type = type; + /** + * @since 1.0.0 + */ + _this._tag = 'ExactType'; + return _this; + } + return ExactType; +}(Type)); +exports.ExactType = ExactType; +/** + * Strips additional properties. + * + * @category combinators + * @since 1.1.0 + */ +function exact(codec, name) { + if (name === void 0) { name = getExactTypeName(codec); } + var props = getProps(codec); + return new ExactType(name, codec.is, function (u, c) { + var e = exports.UnknownRecord.validate(u, c); + if ((0, Either_1.isLeft)(e)) { + return e; + } + var ce = codec.validate(u, c); + if ((0, Either_1.isLeft)(ce)) { + return ce; + } + return (0, Either_1.right)(stripKeys(ce.right, props)); + }, function (a) { return codec.encode(stripKeys(a, props)); }, codec); +} +exports.exact = exact; +/** + * @since 1.0.0 + */ +var FunctionType = /** @class */ (function (_super) { + __extends(FunctionType, _super); + function FunctionType() { + var _this = _super.call(this, 'Function', + // tslint:disable-next-line:strict-type-predicates + function (u) { return typeof u === 'function'; }, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; + /** + * @since 1.0.0 + */ + _this._tag = 'FunctionType'; + return _this; + } + return FunctionType; +}(Type)); +exports.FunctionType = FunctionType; +/** + * @category primitives + * @since 1.0.0 + */ +exports.Function = new FunctionType(); +/** + * @since 1.0.0 + */ +var NeverType = /** @class */ (function (_super) { + __extends(NeverType, _super); + function NeverType() { + var _this = _super.call(this, 'never', function (_) { return false; }, function (u, c) { return (0, exports.failure)(u, c); }, + /* istanbul ignore next */ + function () { + throw new Error('cannot encode never'); + }) || this; + /** + * @since 1.0.0 + */ + _this._tag = 'NeverType'; + return _this; + } + return NeverType; +}(Type)); +exports.NeverType = NeverType; +/** + * @category primitives + * @since 1.0.0 + */ +exports.never = new NeverType(); +/** + * @since 1.0.0 + */ +var AnyType = /** @class */ (function (_super) { + __extends(AnyType, _super); + function AnyType() { + var _this = _super.call(this, 'any', function (_) { return true; }, exports.success, exports.identity) || this; + /** + * @since 1.0.0 + */ + _this._tag = 'AnyType'; + return _this; + } + return AnyType; +}(Type)); +exports.AnyType = AnyType; +/** + * @category primitives + * @since 1.0.0 + */ +exports.any = new AnyType(); +function refinement(codec, predicate, name) { + if (name === void 0) { name = "(".concat(codec.name, " | ").concat(getFunctionName(predicate), ")"); } + return new RefinementType(name, function (u) { return codec.is(u) && predicate(u); }, function (i, c) { + var e = codec.validate(i, c); + if ((0, Either_1.isLeft)(e)) { return e; } - var us = e.right; - var as = us.length > len ? us.slice(0, len) : us; // strip additional components - var errors = []; - for (var i = 0; i < len; i++) { - var a = us[i]; - var type_3 = codecs[i]; - var result = type_3.validate(a, appendContext(c, String(i), type_3, a)); - if (Either_1.isLeft(result)) { - pushAll(errors, result.left); - } - else { - var va = result.right; - if (va !== a) { - /* istanbul ignore next */ - if (as === us) { - as = us.slice(); - } - as[i] = va; - } - } + var a = e.right; + return predicate(a) ? (0, exports.success)(a) : (0, exports.failure)(a, c); + }, codec.encode, codec, predicate); +} +exports.refinement = refinement; +/** + * @category primitives + * @since 1.0.0 + */ +exports.Integer = refinement(exports.number, Number.isInteger, 'Integer'); +// ------------------------------------------------------------------------------------- +// deprecated +// ------------------------------------------------------------------------------------- +/** + * @since 1.3.0 + * @deprecated + */ +var TaggedUnionType = /** @class */ (function (_super) { + __extends(TaggedUnionType, _super); + function TaggedUnionType(name, + // tslint:disable-next-line: deprecation + is, + // tslint:disable-next-line: deprecation + validate, + // tslint:disable-next-line: deprecation + encode, codecs, tag) { + var _this = _super.call(this, name, is, validate, encode, codecs) /* istanbul ignore next */ // <= workaround for https://github.com/Microsoft/TypeScript/issues/13455 + || this; + _this.tag = tag; + return _this; + } + return TaggedUnionType; +}(UnionType)); +exports.TaggedUnionType = TaggedUnionType; +/** + * Use `union` instead. + * + * @category combinators + * @since 1.3.0 + * @deprecated + */ +var taggedUnion = function (tag, codecs, name +// tslint:disable-next-line: deprecation +) { + if (name === void 0) { name = getUnionName(codecs); } + var U = union(codecs, name); + // tslint:disable-next-line: deprecation + if (U instanceof TaggedUnionType) { + return U; + } + else { + console.warn("[io-ts] Cannot build a tagged union for ".concat(name, ", returning a de-optimized union")); + // tslint:disable-next-line: deprecation + return new TaggedUnionType(name, U.is, U.validate, U.encode, codecs, tag); + } +}; +exports.taggedUnion = taggedUnion; +/** + * @since 1.0.0 + * @deprecated + */ +var getValidationError /* istanbul ignore next */ = function (value, context) { return ({ + value: value, + context: context +}); }; +exports.getValidationError /* istanbul ignore next */ = getValidationError; +/** + * @since 1.0.0 + * @deprecated + */ +var getDefaultContext /* istanbul ignore next */ = function (decoder) { return [ + { key: '', type: decoder } +]; }; +exports.getDefaultContext /* istanbul ignore next */ = getDefaultContext; +/** + * Use `UnknownRecord` instead. + * + * @category primitives + * @since 1.0.0 + * @deprecated + */ +exports.Dictionary = exports.UnknownRecord; +/** + * @since 1.0.0 + * @deprecated + */ +var ObjectType = /** @class */ (function (_super) { + __extends(ObjectType, _super); + function ObjectType() { + var _this = _super.call(this, 'object', function (u) { return u !== null && typeof u === 'object'; }, function (u, c) { return (_this.is(u) ? (0, exports.success)(u) : (0, exports.failure)(u, c)); }, exports.identity) || this; + /** + * @since 1.0.0 + */ + _this._tag = 'ObjectType'; + return _this; + } + return ObjectType; +}(Type)); +exports.ObjectType = ObjectType; +/** + * Use `UnknownRecord` instead. + * + * @category primitives + * @since 1.0.0 + * @deprecated + */ +// tslint:disable-next-line: deprecation +exports.object = new ObjectType(); +/** + * Use `record` instead. + * + * @category combinators + * @since 1.0.0 + * @deprecated + */ +exports.dictionary = record; +/** + * @since 1.0.0 + * @deprecated + */ +var StrictType = /** @class */ (function (_super) { + __extends(StrictType, _super); + function StrictType(name, + // tslint:disable-next-line: deprecation + is, + // tslint:disable-next-line: deprecation + validate, + // tslint:disable-next-line: deprecation + encode, props) { + var _this = _super.call(this, name, is, validate, encode) || this; + _this.props = props; + /** + * @since 1.0.0 + */ + _this._tag = 'StrictType'; + return _this; + } + return StrictType; +}(Type)); +exports.StrictType = StrictType; +/** + * Drops the codec "kind". + * + * @category combinators + * @since 1.1.0 + * @deprecated + */ +function clean(codec) { + return codec; +} +exports.clean = clean; +function alias(codec) { + return function () { return codec; }; +} +exports.alias = alias; + + +/***/ }), + +/***/ 1917: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + + +var loader = __nccwpck_require__(1161); +var dumper = __nccwpck_require__(8866); + + +function renamed(from, to) { + return function () { + throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + + 'Use yaml.' + to + ' instead, which is now safe by default.'); + }; +} + + +module.exports.Type = __nccwpck_require__(6073); +module.exports.Schema = __nccwpck_require__(1082); +module.exports.FAILSAFE_SCHEMA = __nccwpck_require__(8562); +module.exports.JSON_SCHEMA = __nccwpck_require__(1035); +module.exports.CORE_SCHEMA = __nccwpck_require__(2011); +module.exports.DEFAULT_SCHEMA = __nccwpck_require__(8759); +module.exports.load = loader.load; +module.exports.loadAll = loader.loadAll; +module.exports.dump = dumper.dump; +module.exports.YAMLException = __nccwpck_require__(8179); + +// Re-export all types in case user wants to create custom schema +module.exports.types = { + binary: __nccwpck_require__(7900), + float: __nccwpck_require__(2705), + map: __nccwpck_require__(6150), + null: __nccwpck_require__(721), + pairs: __nccwpck_require__(6860), + set: __nccwpck_require__(9548), + timestamp: __nccwpck_require__(9212), + bool: __nccwpck_require__(4993), + int: __nccwpck_require__(1615), + merge: __nccwpck_require__(6104), + omap: __nccwpck_require__(9046), + seq: __nccwpck_require__(7283), + str: __nccwpck_require__(3619) +}; + +// Removed functions from JS-YAML 3.0.x +module.exports.safeLoad = renamed('safeLoad', 'load'); +module.exports.safeLoadAll = renamed('safeLoadAll', 'loadAll'); +module.exports.safeDump = renamed('safeDump', 'dump'); + + +/***/ }), + +/***/ 6829: +/***/ ((module) => { + +"use strict"; + + + +function isNothing(subject) { + return (typeof subject === 'undefined') || (subject === null); +} + + +function isObject(subject) { + return (typeof subject === 'object') && (subject !== null); +} + + +function toArray(sequence) { + if (Array.isArray(sequence)) return sequence; + else if (isNothing(sequence)) return []; + + return [ sequence ]; +} + + +function extend(target, source) { + var index, length, key, sourceKeys; + + if (source) { + sourceKeys = Object.keys(source); + + for (index = 0, length = sourceKeys.length; index < length; index += 1) { + key = sourceKeys[index]; + target[key] = source[key]; + } + } + + return target; +} + + +function repeat(string, count) { + var result = '', cycle; + + for (cycle = 0; cycle < count; cycle += 1) { + result += string; + } + + return result; +} + + +function isNegativeZero(number) { + return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); +} + + +module.exports.isNothing = isNothing; +module.exports.isObject = isObject; +module.exports.toArray = toArray; +module.exports.repeat = repeat; +module.exports.isNegativeZero = isNegativeZero; +module.exports.extend = extend; + + +/***/ }), + +/***/ 8866: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +/*eslint-disable no-use-before-define*/ + +var common = __nccwpck_require__(6829); +var YAMLException = __nccwpck_require__(8179); +var DEFAULT_SCHEMA = __nccwpck_require__(8759); + +var _toString = Object.prototype.toString; +var _hasOwnProperty = Object.prototype.hasOwnProperty; + +var CHAR_BOM = 0xFEFF; +var CHAR_TAB = 0x09; /* Tab */ +var CHAR_LINE_FEED = 0x0A; /* LF */ +var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ +var CHAR_SPACE = 0x20; /* Space */ +var CHAR_EXCLAMATION = 0x21; /* ! */ +var CHAR_DOUBLE_QUOTE = 0x22; /* " */ +var CHAR_SHARP = 0x23; /* # */ +var CHAR_PERCENT = 0x25; /* % */ +var CHAR_AMPERSAND = 0x26; /* & */ +var CHAR_SINGLE_QUOTE = 0x27; /* ' */ +var CHAR_ASTERISK = 0x2A; /* * */ +var CHAR_COMMA = 0x2C; /* , */ +var CHAR_MINUS = 0x2D; /* - */ +var CHAR_COLON = 0x3A; /* : */ +var CHAR_EQUALS = 0x3D; /* = */ +var CHAR_GREATER_THAN = 0x3E; /* > */ +var CHAR_QUESTION = 0x3F; /* ? */ +var CHAR_COMMERCIAL_AT = 0x40; /* @ */ +var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ +var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ +var CHAR_GRAVE_ACCENT = 0x60; /* ` */ +var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ +var CHAR_VERTICAL_LINE = 0x7C; /* | */ +var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ + +var ESCAPE_SEQUENCES = {}; + +ESCAPE_SEQUENCES[0x00] = '\\0'; +ESCAPE_SEQUENCES[0x07] = '\\a'; +ESCAPE_SEQUENCES[0x08] = '\\b'; +ESCAPE_SEQUENCES[0x09] = '\\t'; +ESCAPE_SEQUENCES[0x0A] = '\\n'; +ESCAPE_SEQUENCES[0x0B] = '\\v'; +ESCAPE_SEQUENCES[0x0C] = '\\f'; +ESCAPE_SEQUENCES[0x0D] = '\\r'; +ESCAPE_SEQUENCES[0x1B] = '\\e'; +ESCAPE_SEQUENCES[0x22] = '\\"'; +ESCAPE_SEQUENCES[0x5C] = '\\\\'; +ESCAPE_SEQUENCES[0x85] = '\\N'; +ESCAPE_SEQUENCES[0xA0] = '\\_'; +ESCAPE_SEQUENCES[0x2028] = '\\L'; +ESCAPE_SEQUENCES[0x2029] = '\\P'; + +var DEPRECATED_BOOLEANS_SYNTAX = [ + 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', + 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' +]; + +var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; + +function compileStyleMap(schema, map) { + var result, keys, index, length, tag, style, type; + + if (map === null) return {}; + + result = {}; + keys = Object.keys(map); + + for (index = 0, length = keys.length; index < length; index += 1) { + tag = keys[index]; + style = String(map[tag]); + + if (tag.slice(0, 2) === '!!') { + tag = 'tag:yaml.org,2002:' + tag.slice(2); + } + type = schema.compiledTypeMap['fallback'][tag]; + + if (type && _hasOwnProperty.call(type.styleAliases, style)) { + style = type.styleAliases[style]; + } + + result[tag] = style; + } + + return result; +} + +function encodeHex(character) { + var string, handle, length; + + string = character.toString(16).toUpperCase(); + + if (character <= 0xFF) { + handle = 'x'; + length = 2; + } else if (character <= 0xFFFF) { + handle = 'u'; + length = 4; + } else if (character <= 0xFFFFFFFF) { + handle = 'U'; + length = 8; + } else { + throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); + } + + return '\\' + handle + common.repeat('0', length - string.length) + string; +} + + +var QUOTING_TYPE_SINGLE = 1, + QUOTING_TYPE_DOUBLE = 2; + +function State(options) { + this.schema = options['schema'] || DEFAULT_SCHEMA; + this.indent = Math.max(1, (options['indent'] || 2)); + this.noArrayIndent = options['noArrayIndent'] || false; + this.skipInvalid = options['skipInvalid'] || false; + this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); + this.styleMap = compileStyleMap(this.schema, options['styles'] || null); + this.sortKeys = options['sortKeys'] || false; + this.lineWidth = options['lineWidth'] || 80; + this.noRefs = options['noRefs'] || false; + this.noCompatMode = options['noCompatMode'] || false; + this.condenseFlow = options['condenseFlow'] || false; + this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; + this.forceQuotes = options['forceQuotes'] || false; + this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; + + this.implicitTypes = this.schema.compiledImplicit; + this.explicitTypes = this.schema.compiledExplicit; + + this.tag = null; + this.result = ''; + + this.duplicates = []; + this.usedDuplicates = null; +} + +// Indents every line in a string. Empty lines (\n only) are not indented. +function indentString(string, spaces) { + var ind = common.repeat(' ', spaces), + position = 0, + next = -1, + result = '', + line, + length = string.length; + + while (position < length) { + next = string.indexOf('\n', position); + if (next === -1) { + line = string.slice(position); + position = length; + } else { + line = string.slice(position, next + 1); + position = next + 1; + } + + if (line.length && line !== '\n') result += ind; + + result += line; + } + + return result; +} + +function generateNextLine(state, level) { + return '\n' + common.repeat(' ', state.indent * level); +} + +function testImplicitResolving(state, str) { + var index, length, type; + + for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { + type = state.implicitTypes[index]; + + if (type.resolve(str)) { + return true; + } + } + + return false; +} + +// [33] s-white ::= s-space | s-tab +function isWhitespace(c) { + return c === CHAR_SPACE || c === CHAR_TAB; +} + +// Returns true if the character can be printed without escaping. +// From YAML 1.2: "any allowed characters known to be non-printable +// should also be escaped. [However,] This isn’t mandatory" +// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. +function isPrintable(c) { + return (0x00020 <= c && c <= 0x00007E) + || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) + || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) + || (0x10000 <= c && c <= 0x10FFFF); +} + +// [34] ns-char ::= nb-char - s-white +// [27] nb-char ::= c-printable - b-char - c-byte-order-mark +// [26] b-char ::= b-line-feed | b-carriage-return +// Including s-white (for some reason, examples doesn't match specs in this aspect) +// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark +function isNsCharOrWhitespace(c) { + return isPrintable(c) + && c !== CHAR_BOM + // - b-char + && c !== CHAR_CARRIAGE_RETURN + && c !== CHAR_LINE_FEED; +} + +// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out +// c = flow-in ⇒ ns-plain-safe-in +// c = block-key ⇒ ns-plain-safe-out +// c = flow-key ⇒ ns-plain-safe-in +// [128] ns-plain-safe-out ::= ns-char +// [129] ns-plain-safe-in ::= ns-char - c-flow-indicator +// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) +// | ( /* An ns-char preceding */ “#” ) +// | ( “:” /* Followed by an ns-plain-safe(c) */ ) +function isPlainSafe(c, prev, inblock) { + var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); + var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); + return ( + // ns-plain-safe + inblock ? // c = flow-in + cIsNsCharOrWhitespace + : cIsNsCharOrWhitespace + // - c-flow-indicator + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + ) + // ns-plain-char + && c !== CHAR_SHARP // false on '#' + && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' + || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' + || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' +} + +// Simplified test for values allowed as the first character in plain style. +function isPlainSafeFirst(c) { + // Uses a subset of ns-char - c-indicator + // where ns-char = nb-char - s-white. + // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part + return isPrintable(c) && c !== CHAR_BOM + && !isWhitespace(c) // - s-white + // - (c-indicator ::= + // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” + && c !== CHAR_MINUS + && c !== CHAR_QUESTION + && c !== CHAR_COLON + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” + && c !== CHAR_SHARP + && c !== CHAR_AMPERSAND + && c !== CHAR_ASTERISK + && c !== CHAR_EXCLAMATION + && c !== CHAR_VERTICAL_LINE + && c !== CHAR_EQUALS + && c !== CHAR_GREATER_THAN + && c !== CHAR_SINGLE_QUOTE + && c !== CHAR_DOUBLE_QUOTE + // | “%” | “@” | “`”) + && c !== CHAR_PERCENT + && c !== CHAR_COMMERCIAL_AT + && c !== CHAR_GRAVE_ACCENT; +} + +// Simplified test for values allowed as the last character in plain style. +function isPlainSafeLast(c) { + // just not whitespace or colon, it will be checked to be plain character later + return !isWhitespace(c) && c !== CHAR_COLON; +} + +// Same as 'string'.codePointAt(pos), but works in older browsers. +function codePointAt(string, pos) { + var first = string.charCodeAt(pos), second; + if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { + second = string.charCodeAt(pos + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; +} + +// Determines whether block indentation indicator is required. +function needIndentIndicator(string) { + var leadingSpaceRe = /^\n* /; + return leadingSpaceRe.test(string); +} + +var STYLE_PLAIN = 1, + STYLE_SINGLE = 2, + STYLE_LITERAL = 3, + STYLE_FOLDED = 4, + STYLE_DOUBLE = 5; + +// Determines which scalar styles are possible and returns the preferred style. +// lineWidth = -1 => no limit. +// Pre-conditions: str.length > 0. +// Post-conditions: +// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. +// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). +// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). +function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, + testAmbiguousType, quotingType, forceQuotes, inblock) { + + var i; + var char = 0; + var prevChar = null; + var hasLineBreak = false; + var hasFoldableLine = false; // only checked if shouldTrackWidth + var shouldTrackWidth = lineWidth !== -1; + var previousLineBreak = -1; // count the first line correctly + var plain = isPlainSafeFirst(codePointAt(string, 0)) + && isPlainSafeLast(codePointAt(string, string.length - 1)); + + if (singleLineOnly || forceQuotes) { + // Case: no block styles. + // Check for disallowed characters to rule out plain and single. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; + } + } else { + // Case: block styles permitted. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (char === CHAR_LINE_FEED) { + hasLineBreak = true; + // Check if any line can be folded. + if (shouldTrackWidth) { + hasFoldableLine = hasFoldableLine || + // Foldable line = too long, and not more-indented. + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' '); + previousLineBreak = i; + } + } else if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; + } + // in case the end is missing a \n + hasFoldableLine = hasFoldableLine || (shouldTrackWidth && + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' ')); + } + // Although every style can represent \n without escaping, prefer block styles + // for multiline, since they're more readable and they don't add empty lines. + // Also prefer folding a super-long line. + if (!hasLineBreak && !hasFoldableLine) { + // Strings interpretable as another type have to be quoted; + // e.g. the string 'true' vs. the boolean true. + if (plain && !forceQuotes && !testAmbiguousType(string)) { + return STYLE_PLAIN; + } + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; + } + // Edge case: block indentation indicator can only have one digit. + if (indentPerLevel > 9 && needIndentIndicator(string)) { + return STYLE_DOUBLE; + } + // At this point we know block styles are valid. + // Prefer literal style unless we want to fold. + if (!forceQuotes) { + return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; + } + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; +} + +// Note: line breaking/folding is implemented for only the folded style. +// NB. We drop the last trailing newline (if any) of a returned block scalar +// since the dumper adds its own newline. This always works: +// • No ending newline => unaffected; already using strip "-" chomping. +// • Ending newline => removed then restored. +// Importantly, this keeps the "+" chomp indicator from gaining an extra line. +function writeScalar(state, string, level, iskey, inblock) { + state.dump = (function () { + if (string.length === 0) { + return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; + } + if (!state.noCompatMode) { + if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { + return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); + } + } + + var indent = state.indent * Math.max(1, level); // no 0-indent scalars + // As indentation gets deeper, let the width decrease monotonically + // to the lower bound min(state.lineWidth, 40). + // Note that this implies + // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. + // state.lineWidth > 40 + state.indent: width decreases until the lower bound. + // This behaves better than a constant minimum width which disallows narrower options, + // or an indent threshold which causes the width to suddenly increase. + var lineWidth = state.lineWidth === -1 + ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); + + // Without knowing if keys are implicit/explicit, assume implicit for safety. + var singleLineOnly = iskey + // No block styles in flow mode. + || (state.flowLevel > -1 && level >= state.flowLevel); + function testAmbiguity(string) { + return testImplicitResolving(state, string); + } + + switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, + testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { + + case STYLE_PLAIN: + return string; + case STYLE_SINGLE: + return "'" + string.replace(/'/g, "''") + "'"; + case STYLE_LITERAL: + return '|' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(string, indent)); + case STYLE_FOLDED: + return '>' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); + case STYLE_DOUBLE: + return '"' + escapeString(string, lineWidth) + '"'; + default: + throw new YAMLException('impossible error: invalid scalar style'); + } + }()); +} + +// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. +function blockHeader(string, indentPerLevel) { + var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; + + // note the special case: the string '\n' counts as a "trailing" empty line. + var clip = string[string.length - 1] === '\n'; + var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); + var chomp = keep ? '+' : (clip ? '' : '-'); + + return indentIndicator + chomp + '\n'; +} + +// (See the note for writeScalar.) +function dropEndingNewline(string) { + return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; +} + +// Note: a long line without a suitable break point will exceed the width limit. +// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. +function foldString(string, width) { + // In folded style, $k$ consecutive newlines output as $k+1$ newlines— + // unless they're before or after a more-indented line, or at the very + // beginning or end, in which case $k$ maps to $k$. + // Therefore, parse each chunk as newline(s) followed by a content line. + var lineRe = /(\n+)([^\n]*)/g; + + // first line (possibly an empty line) + var result = (function () { + var nextLF = string.indexOf('\n'); + nextLF = nextLF !== -1 ? nextLF : string.length; + lineRe.lastIndex = nextLF; + return foldLine(string.slice(0, nextLF), width); + }()); + // If we haven't reached the first content line yet, don't add an extra \n. + var prevMoreIndented = string[0] === '\n' || string[0] === ' '; + var moreIndented; + + // rest of the lines + var match; + while ((match = lineRe.exec(string))) { + var prefix = match[1], line = match[2]; + moreIndented = (line[0] === ' '); + result += prefix + + (!prevMoreIndented && !moreIndented && line !== '' + ? '\n' : '') + + foldLine(line, width); + prevMoreIndented = moreIndented; + } + + return result; +} + +// Greedy line breaking. +// Picks the longest line under the limit each time, +// otherwise settles for the shortest line over the limit. +// NB. More-indented lines *cannot* be folded, as that would add an extra \n. +function foldLine(line, width) { + if (line === '' || line[0] === ' ') return line; + + // Since a more-indented line adds a \n, breaks can't be followed by a space. + var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. + var match; + // start is an inclusive index. end, curr, and next are exclusive. + var start = 0, end, curr = 0, next = 0; + var result = ''; + + // Invariants: 0 <= start <= length-1. + // 0 <= curr <= next <= max(0, length-2). curr - start <= width. + // Inside the loop: + // A match implies length >= 2, so curr and next are <= length-2. + while ((match = breakRe.exec(line))) { + next = match.index; + // maintain invariant: curr - start <= width + if (next - start > width) { + end = (curr > start) ? curr : next; // derive end <= length-2 + result += '\n' + line.slice(start, end); + // skip the space that was output as \n + start = end + 1; // derive start <= length-1 + } + curr = next; + } + + // By the invariants, start <= length-1, so there is something left over. + // It is either the whole string or a part starting from non-whitespace. + result += '\n'; + // Insert a break if the remainder is too long and there is a break available. + if (line.length - start > width && curr > start) { + result += line.slice(start, curr) + '\n' + line.slice(curr + 1); + } else { + result += line.slice(start); + } + + return result.slice(1); // drop extra \n joiner +} + +// Escapes a double-quoted string. +function escapeString(string) { + var result = ''; + var char = 0; + var escapeSeq; + + for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + escapeSeq = ESCAPE_SEQUENCES[char]; + + if (!escapeSeq && isPrintable(char)) { + result += string[i]; + if (char >= 0x10000) result += string[i + 1]; + } else { + result += escapeSeq || encodeHex(char); + } + } + + return result; +} + +function writeFlowSequence(state, level, object) { + var _result = '', + _tag = state.tag, + index, + length, + value; + + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; + + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } + + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level, value, false, false) || + (typeof value === 'undefined' && + writeNode(state, level, null, false, false))) { + + if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = '[' + _result + ']'; +} + +function writeBlockSequence(state, level, object, compact) { + var _result = '', + _tag = state.tag, + index, + length, + value; + + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; + + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } + + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level + 1, value, true, true, false, true) || + (typeof value === 'undefined' && + writeNode(state, level + 1, null, true, true, false, true))) { + + if (!compact || _result !== '') { + _result += generateNextLine(state, level); + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + _result += '-'; + } else { + _result += '- '; + } + + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = _result || '[]'; // Empty sequence if no valid values. +} + +function writeFlowMapping(state, level, object) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + pairBuffer; + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + + pairBuffer = ''; + if (_result !== '') pairBuffer += ', '; + + if (state.condenseFlow) pairBuffer += '"'; + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); + } + + if (!writeNode(state, level, objectKey, false, false)) { + continue; // Skip this pair because of invalid key; + } + + if (state.dump.length > 1024) pairBuffer += '? '; + + pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); + + if (!writeNode(state, level, objectValue, false, false)) { + continue; // Skip this pair because of invalid value. + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = '{' + _result + '}'; +} + +function writeBlockMapping(state, level, object, compact) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + explicitPair, + pairBuffer; + + // Allow sorting keys so that the output file is deterministic + if (state.sortKeys === true) { + // Default sorting + objectKeyList.sort(); + } else if (typeof state.sortKeys === 'function') { + // Custom sort function + objectKeyList.sort(state.sortKeys); + } else if (state.sortKeys) { + // Something is wrong + throw new YAMLException('sortKeys must be a boolean or a function'); + } + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + pairBuffer = ''; + + if (!compact || _result !== '') { + pairBuffer += generateNextLine(state, level); + } + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); + } + + if (!writeNode(state, level + 1, objectKey, true, true, true)) { + continue; // Skip this pair because of invalid key. + } + + explicitPair = (state.tag !== null && state.tag !== '?') || + (state.dump && state.dump.length > 1024); + + if (explicitPair) { + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += '?'; + } else { + pairBuffer += '? '; + } + } + + pairBuffer += state.dump; + + if (explicitPair) { + pairBuffer += generateNextLine(state, level); + } + + if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { + continue; // Skip this pair because of invalid value. + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += ':'; + } else { + pairBuffer += ': '; + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = _result || '{}'; // Empty mapping if no valid pairs. +} + +function detectType(state, object, explicit) { + var _result, typeList, index, length, type, style; + + typeList = explicit ? state.explicitTypes : state.implicitTypes; + + for (index = 0, length = typeList.length; index < length; index += 1) { + type = typeList[index]; + + if ((type.instanceOf || type.predicate) && + (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && + (!type.predicate || type.predicate(object))) { + + if (explicit) { + if (type.multi && type.representName) { + state.tag = type.representName(object); + } else { + state.tag = type.tag; + } + } else { + state.tag = '?'; + } + + if (type.represent) { + style = state.styleMap[type.tag] || type.defaultStyle; + + if (_toString.call(type.represent) === '[object Function]') { + _result = type.represent(object, style); + } else if (_hasOwnProperty.call(type.represent, style)) { + _result = type.represent[style](object, style); + } else { + throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + } + + state.dump = _result; + } + + return true; + } + } + + return false; +} + +// Serializes `object` and writes it to global `result`. +// Returns true on success, or false on invalid object. +// +function writeNode(state, level, object, block, compact, iskey, isblockseq) { + state.tag = null; + state.dump = object; + + if (!detectType(state, object, false)) { + detectType(state, object, true); + } + + var type = _toString.call(state.dump); + var inblock = block; + var tagStr; + + if (block) { + block = (state.flowLevel < 0 || state.flowLevel > level); + } + + var objectOrArray = type === '[object Object]' || type === '[object Array]', + duplicateIndex, + duplicate; + + if (objectOrArray) { + duplicateIndex = state.duplicates.indexOf(object); + duplicate = duplicateIndex !== -1; + } + + if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { + compact = false; + } + + if (duplicate && state.usedDuplicates[duplicateIndex]) { + state.dump = '*ref_' + duplicateIndex; + } else { + if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { + state.usedDuplicates[duplicateIndex] = true; + } + if (type === '[object Object]') { + if (block && (Object.keys(state.dump).length !== 0)) { + writeBlockMapping(state, level, state.dump, compact); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowMapping(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object Array]') { + if (block && (state.dump.length !== 0)) { + if (state.noArrayIndent && !isblockseq && level > 0) { + writeBlockSequence(state, level - 1, state.dump, compact); + } else { + writeBlockSequence(state, level, state.dump, compact); + } + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowSequence(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object String]') { + if (state.tag !== '?') { + writeScalar(state, state.dump, level, iskey, inblock); + } + } else if (type === '[object Undefined]') { + return false; + } else { + if (state.skipInvalid) return false; + throw new YAMLException('unacceptable kind of an object to dump ' + type); + } + + if (state.tag !== null && state.tag !== '?') { + // Need to encode all characters except those allowed by the spec: + // + // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ + // [36] ns-hex-digit ::= ns-dec-digit + // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ + // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ + // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” + // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” + // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” + // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” + // + // Also need to encode '!' because it has special meaning (end of tag prefix). + // + tagStr = encodeURI( + state.tag[0] === '!' ? state.tag.slice(1) : state.tag + ).replace(/!/g, '%21'); + + if (state.tag[0] === '!') { + tagStr = '!' + tagStr; + } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { + tagStr = '!!' + tagStr.slice(18); + } else { + tagStr = '!<' + tagStr + '>'; + } + + state.dump = tagStr + ' ' + state.dump; + } + } + + return true; +} + +function getDuplicateReferences(object, state) { + var objects = [], + duplicatesIndexes = [], + index, + length; + + inspectNode(object, objects, duplicatesIndexes); + + for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { + state.duplicates.push(objects[duplicatesIndexes[index]]); + } + state.usedDuplicates = new Array(length); +} + +function inspectNode(object, objects, duplicatesIndexes) { + var objectKeyList, + index, + length; + + if (object !== null && typeof object === 'object') { + index = objects.indexOf(object); + if (index !== -1) { + if (duplicatesIndexes.indexOf(index) === -1) { + duplicatesIndexes.push(index); + } + } else { + objects.push(object); + + if (Array.isArray(object)) { + for (index = 0, length = object.length; index < length; index += 1) { + inspectNode(object[index], objects, duplicatesIndexes); + } + } else { + objectKeyList = Object.keys(object); + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + } + } + } + } +} + +function dump(input, options) { + options = options || {}; + + var state = new State(options); + + if (!state.noRefs) getDuplicateReferences(input, state); + + var value = input; + + if (state.replacer) { + value = state.replacer.call({ '': value }, '', value); + } + + if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; + + return ''; +} + +module.exports.dump = dump; + + +/***/ }), + +/***/ 8179: +/***/ ((module) => { + +"use strict"; +// YAML error class. http://stackoverflow.com/questions/8458984 +// + + + +function formatError(exception, compact) { + var where = '', message = exception.reason || '(unknown reason)'; + + if (!exception.mark) return message; + + if (exception.mark.name) { + where += 'in "' + exception.mark.name + '" '; + } + + where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; + + if (!compact && exception.mark.snippet) { + where += '\n\n' + exception.mark.snippet; + } + + return message + ' ' + where; +} + + +function YAMLException(reason, mark) { + // Super constructor + Error.call(this); + + this.name = 'YAMLException'; + this.reason = reason; + this.mark = mark; + this.message = formatError(this, false); + + // Include stack trace in error object + if (Error.captureStackTrace) { + // Chrome and NodeJS + Error.captureStackTrace(this, this.constructor); + } else { + // FF, IE 10+ and Safari 6+. Fallback for others + this.stack = (new Error()).stack || ''; + } +} + + +// Inherit from Error +YAMLException.prototype = Object.create(Error.prototype); +YAMLException.prototype.constructor = YAMLException; + + +YAMLException.prototype.toString = function toString(compact) { + return this.name + ': ' + formatError(this, compact); +}; + + +module.exports = YAMLException; + + +/***/ }), + +/***/ 1161: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +/*eslint-disable max-len,no-use-before-define*/ + +var common = __nccwpck_require__(6829); +var YAMLException = __nccwpck_require__(8179); +var makeSnippet = __nccwpck_require__(6975); +var DEFAULT_SCHEMA = __nccwpck_require__(8759); + + +var _hasOwnProperty = Object.prototype.hasOwnProperty; + + +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; + + +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; + + +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; + + +function _class(obj) { return Object.prototype.toString.call(obj); } + +function is_EOL(c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); +} + +function is_WHITE_SPACE(c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */); +} + +function is_WS_OR_EOL(c) { + return (c === 0x09/* Tab */) || + (c === 0x20/* Space */) || + (c === 0x0A/* LF */) || + (c === 0x0D/* CR */); +} + +function is_FLOW_INDICATOR(c) { + return c === 0x2C/* , */ || + c === 0x5B/* [ */ || + c === 0x5D/* ] */ || + c === 0x7B/* { */ || + c === 0x7D/* } */; +} + +function fromHexCode(c) { + var lc; + + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + /*eslint-disable no-bitwise*/ + lc = c | 0x20; + + if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10; + } + + return -1; +} + +function escapedHexLen(c) { + if (c === 0x78/* x */) { return 2; } + if (c === 0x75/* u */) { return 4; } + if (c === 0x55/* U */) { return 8; } + return 0; +} + +function fromDecimalCode(c) { + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + return -1; +} + +function simpleEscapeSequence(c) { + /* eslint-disable indent */ + return (c === 0x30/* 0 */) ? '\x00' : + (c === 0x61/* a */) ? '\x07' : + (c === 0x62/* b */) ? '\x08' : + (c === 0x74/* t */) ? '\x09' : + (c === 0x09/* Tab */) ? '\x09' : + (c === 0x6E/* n */) ? '\x0A' : + (c === 0x76/* v */) ? '\x0B' : + (c === 0x66/* f */) ? '\x0C' : + (c === 0x72/* r */) ? '\x0D' : + (c === 0x65/* e */) ? '\x1B' : + (c === 0x20/* Space */) ? ' ' : + (c === 0x22/* " */) ? '\x22' : + (c === 0x2F/* / */) ? '/' : + (c === 0x5C/* \ */) ? '\x5C' : + (c === 0x4E/* N */) ? '\x85' : + (c === 0x5F/* _ */) ? '\xA0' : + (c === 0x4C/* L */) ? '\u2028' : + (c === 0x50/* P */) ? '\u2029' : ''; +} + +function charFromCodepoint(c) { + if (c <= 0xFFFF) { + return String.fromCharCode(c); + } + // Encode UTF-16 surrogate pair + // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF + return String.fromCharCode( + ((c - 0x010000) >> 10) + 0xD800, + ((c - 0x010000) & 0x03FF) + 0xDC00 + ); +} + +var simpleEscapeCheck = new Array(256); // integer, for fast access +var simpleEscapeMap = new Array(256); +for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); +} + + +function State(input, options) { + this.input = input; + + this.filename = options['filename'] || null; + this.schema = options['schema'] || DEFAULT_SCHEMA; + this.onWarning = options['onWarning'] || null; + // (Hidden) Remove? makes the loader to expect YAML 1.1 documents + // if such documents have no explicit %YAML directive + this.legacy = options['legacy'] || false; + + this.json = options['json'] || false; + this.listener = options['listener'] || null; + + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + + // position of first leading tab in the current line, + // used to make sure there are no tabs in the indentation + this.firstTabInLine = -1; + + this.documents = []; + + /* + this.version; + this.checkLineBreaks; + this.tagMap; + this.anchorMap; + this.tag; + this.anchor; + this.kind; + this.result;*/ + +} + + +function generateError(state, message) { + var mark = { + name: state.filename, + buffer: state.input.slice(0, -1), // omit trailing \0 + position: state.position, + line: state.line, + column: state.position - state.lineStart + }; + + mark.snippet = makeSnippet(mark); + + return new YAMLException(message, mark); +} + +function throwError(state, message) { + throw generateError(state, message); +} + +function throwWarning(state, message) { + if (state.onWarning) { + state.onWarning.call(null, generateError(state, message)); + } +} + + +var directiveHandlers = { + + YAML: function handleYamlDirective(state, name, args) { + + var match, major, minor; + + if (state.version !== null) { + throwError(state, 'duplication of %YAML directive'); + } + + if (args.length !== 1) { + throwError(state, 'YAML directive accepts exactly one argument'); + } + + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + + if (match === null) { + throwError(state, 'ill-formed argument of the YAML directive'); + } + + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + + if (major !== 1) { + throwError(state, 'unacceptable YAML version of the document'); + } + + state.version = args[0]; + state.checkLineBreaks = (minor < 2); + + if (minor !== 1 && minor !== 2) { + throwWarning(state, 'unsupported YAML version of the document'); + } + }, + + TAG: function handleTagDirective(state, name, args) { + + var handle, prefix; + + if (args.length !== 2) { + throwError(state, 'TAG directive accepts exactly two arguments'); + } + + handle = args[0]; + prefix = args[1]; + + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); + } + + if (_hasOwnProperty.call(state.tagMap, handle)) { + throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } + + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + } + + try { + prefix = decodeURIComponent(prefix); + } catch (err) { + throwError(state, 'tag prefix is malformed: ' + prefix); + } + + state.tagMap[handle] = prefix; + } +}; + + +function captureSegment(state, start, end, checkJson) { + var _position, _length, _character, _result; + + if (start < end) { + _result = state.input.slice(start, end); + + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 0x09 || + (0x20 <= _character && _character <= 0x10FFFF))) { + throwError(state, 'expected valid JSON character'); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state, 'the stream contains non-printable characters'); + } + + state.result += _result; + } +} + +function mergeMappings(state, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; + + if (!common.isObject(source)) { + throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); + } + + sourceKeys = Object.keys(source); + + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + + if (!_hasOwnProperty.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } +} + +function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, + startLine, startLineStart, startPos) { + + var index, quantity; + + // The output is a plain object here, so keys can only be strings. + // We need to convert keyNode to a string, but doing so can hang the process + // (deeply nested arrays that explode exponentially using aliases). + if (Array.isArray(keyNode)) { + keyNode = Array.prototype.slice.call(keyNode); + + for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { + if (Array.isArray(keyNode[index])) { + throwError(state, 'nested arrays are not supported inside keys'); + } + + if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { + keyNode[index] = '[object Object]'; + } + } + } + + // Avoid code execution in load() via toString property + // (still use its own toString for arrays, timestamps, + // and whatever user schema extensions happen to have @@toStringTag) + if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { + keyNode = '[object Object]'; + } + + + keyNode = String(keyNode); + + if (_result === null) { + _result = {}; + } + + if (keyTag === 'tag:yaml.org,2002:merge') { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state, _result, valueNode, overridableKeys); + } + } else { + if (!state.json && + !_hasOwnProperty.call(overridableKeys, keyNode) && + _hasOwnProperty.call(_result, keyNode)) { + state.line = startLine || state.line; + state.lineStart = startLineStart || state.lineStart; + state.position = startPos || state.position; + throwError(state, 'duplicated mapping key'); + } + + // used for this specific key only because Object.defineProperty is slow + if (keyNode === '__proto__') { + Object.defineProperty(_result, keyNode, { + configurable: true, + enumerable: true, + writable: true, + value: valueNode + }); + } else { + _result[keyNode] = valueNode; + } + delete overridableKeys[keyNode]; + } + + return _result; +} + +function readLineBreak(state) { + var ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x0A/* LF */) { + state.position++; + } else if (ch === 0x0D/* CR */) { + state.position++; + if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { + state.position++; + } + } else { + throwError(state, 'a line break is expected'); + } + + state.line += 1; + state.lineStart = state.position; + state.firstTabInLine = -1; +} + +function skipSeparationSpace(state, allowComments, checkIndent) { + var lineBreaks = 0, + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { + state.firstTabInLine = state.position; + } + ch = state.input.charCodeAt(++state.position); + } + + if (allowComments && ch === 0x23/* # */) { + do { + ch = state.input.charCodeAt(++state.position); + } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + } + + if (is_EOL(ch)) { + readLineBreak(state); + + ch = state.input.charCodeAt(state.position); + lineBreaks++; + state.lineIndent = 0; + + while (ch === 0x20/* Space */) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + } else { + break; + } + } + + if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { + throwWarning(state, 'deficient indentation'); + } + + return lineBreaks; +} + +function testDocumentSeparator(state) { + var _position = state.position, + ch; + + ch = state.input.charCodeAt(_position); + + // Condition state.position === state.lineStart is tested + // in parent on each call, for efficiency. No needs to test here again. + if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && + ch === state.input.charCodeAt(_position + 1) && + ch === state.input.charCodeAt(_position + 2)) { + + _position += 3; + + ch = state.input.charCodeAt(_position); + + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + + return false; +} + +function writeFoldedLines(state, count) { + if (count === 1) { + state.result += ' '; + } else if (count > 1) { + state.result += common.repeat('\n', count - 1); + } +} + + +function readPlainScalar(state, nodeIndent, withinFlowCollection) { + var preceding, + following, + captureStart, + captureEnd, + hasPendingContent, + _line, + _lineStart, + _lineIndent, + _kind = state.kind, + _result = state.result, + ch; + + ch = state.input.charCodeAt(state.position); + + if (is_WS_OR_EOL(ch) || + is_FLOW_INDICATOR(ch) || + ch === 0x23/* # */ || + ch === 0x26/* & */ || + ch === 0x2A/* * */ || + ch === 0x21/* ! */ || + ch === 0x7C/* | */ || + ch === 0x3E/* > */ || + ch === 0x27/* ' */ || + ch === 0x22/* " */ || + ch === 0x25/* % */ || + ch === 0x40/* @ */ || + ch === 0x60/* ` */) { + return false; + } + + if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } + + state.kind = 'scalar'; + state.result = ''; + captureStart = captureEnd = state.position; + hasPendingContent = false; + + while (ch !== 0) { + if (ch === 0x3A/* : */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + + } else if (ch === 0x23/* # */) { + preceding = state.input.charCodeAt(state.position - 1); + + if (is_WS_OR_EOL(preceding)) { + break; + } + + } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || + withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + + } else if (is_EOL(ch)) { + _line = state.line; + _lineStart = state.lineStart; + _lineIndent = state.lineIndent; + skipSeparationSpace(state, false, -1); + + if (state.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state.input.charCodeAt(state.position); + continue; + } else { + state.position = captureEnd; + state.line = _line; + state.lineStart = _lineStart; + state.lineIndent = _lineIndent; + break; + } + } + + if (hasPendingContent) { + captureSegment(state, captureStart, captureEnd, false); + writeFoldedLines(state, state.line - _line); + captureStart = captureEnd = state.position; + hasPendingContent = false; + } + + if (!is_WHITE_SPACE(ch)) { + captureEnd = state.position + 1; + } + + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, captureEnd, false); + + if (state.result) { + return true; + } + + state.kind = _kind; + state.result = _result; + return false; +} + +function readSingleQuotedScalar(state, nodeIndent) { + var ch, + captureStart, captureEnd; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x27/* ' */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x27/* ' */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x27/* ' */) { + captureStart = state.position; + state.position++; + captureEnd = state.position; + } else { + return true; + } + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a single quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a single quoted scalar'); +} + +function readDoubleQuotedScalar(state, nodeIndent) { + var captureStart, + captureEnd, + hexLength, + hexResult, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x22/* " */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x22/* " */) { + captureSegment(state, captureStart, state.position, true); + state.position++; + return true; + + } else if (ch === 0x5C/* \ */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (is_EOL(ch)) { + skipSeparationSpace(state, false, nodeIndent); + + // TODO: rework to inline fn with no type cast? + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state.result += simpleEscapeMap[ch]; + state.position++; + + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; + + for (; hexLength > 0; hexLength--) { + ch = state.input.charCodeAt(++state.position); + + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; + + } else { + throwError(state, 'expected hexadecimal character'); + } + } + + state.result += charFromCodepoint(hexResult); + + state.position++; + + } else { + throwError(state, 'unknown escape sequence'); + } + + captureStart = captureEnd = state.position; + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a double quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a double quoted scalar'); +} + +function readFlowCollection(state, nodeIndent) { + var readNext = true, + _line, + _lineStart, + _pos, + _tag = state.tag, + _result, + _anchor = state.anchor, + following, + terminator, + isPair, + isExplicitPair, + isMapping, + overridableKeys = Object.create(null), + keyNode, + keyTag, + valueNode, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x5B/* [ */) { + terminator = 0x5D;/* ] */ + isMapping = false; + _result = []; + } else if (ch === 0x7B/* { */) { + terminator = 0x7D;/* } */ + isMapping = true; + _result = {}; + } else { + return false; + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(++state.position); + + while (ch !== 0) { + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === terminator) { + state.position++; + state.tag = _tag; + state.anchor = _anchor; + state.kind = isMapping ? 'mapping' : 'sequence'; + state.result = _result; + return true; + } else if (!readNext) { + throwError(state, 'missed comma between flow collection entries'); + } else if (ch === 0x2C/* , */) { + // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 + throwError(state, "expected the node content, but found ','"); + } + + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; + + if (ch === 0x3F/* ? */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state.position++; + skipSeparationSpace(state, true, nodeIndent); + } + } + + _line = state.line; // Save the current line. + _lineStart = state.lineStart; + _pos = state.position; + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state.tag; + keyNode = state.result; + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { + isPair = true; + ch = state.input.charCodeAt(++state.position); + skipSeparationSpace(state, true, nodeIndent); + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state.result; + } + + if (isMapping) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); + } else if (isPair) { + _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); + } else { + _result.push(keyNode); + } + + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x2C/* , */) { + readNext = true; + ch = state.input.charCodeAt(++state.position); + } else { + readNext = false; + } + } + + throwError(state, 'unexpected end of the stream within a flow collection'); +} + +function readBlockScalar(state, nodeIndent) { + var captureStart, + folding, + chomping = CHOMPING_CLIP, + didReadContent = false, + detectedIndent = false, + textIndent = nodeIndent, + emptyLines = 0, + atMoreIndented = false, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x7C/* | */) { + folding = false; + } else if (ch === 0x3E/* > */) { + folding = true; + } else { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + + while (ch !== 0) { + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { + if (CHOMPING_CLIP === chomping) { + chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state, 'repeat of a chomping mode identifier'); + } + + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state, 'repeat of an indentation width identifier'); + } + + } else { + break; + } + } + + if (is_WHITE_SPACE(ch)) { + do { ch = state.input.charCodeAt(++state.position); } + while (is_WHITE_SPACE(ch)); + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (!is_EOL(ch) && (ch !== 0)); + } + } + + while (ch !== 0) { + readLineBreak(state); + state.lineIndent = 0; + + ch = state.input.charCodeAt(state.position); + + while ((!detectedIndent || state.lineIndent < textIndent) && + (ch === 0x20/* Space */)) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + + if (!detectedIndent && state.lineIndent > textIndent) { + textIndent = state.lineIndent; + } + + if (is_EOL(ch)) { + emptyLines++; + continue; + } + + // End of the scalar. + if (state.lineIndent < textIndent) { + + // Perform the chomping. + if (chomping === CHOMPING_KEEP) { + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { // i.e. only if the scalar is not empty. + state.result += '\n'; + } + } + + // Break this `while` cycle and go to the funciton's epilogue. + break; + } + + // Folded style: use fancy rules to handle line breaks. + if (folding) { + + // Lines starting with white space characters (more-indented lines) are not folded. + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + // except for the first content line (cf. Example 8.1) + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + + // End of more-indented block. + } else if (atMoreIndented) { + atMoreIndented = false; + state.result += common.repeat('\n', emptyLines + 1); + + // Just one line break - perceive as the same line. + } else if (emptyLines === 0) { + if (didReadContent) { // i.e. only if we have already read some scalar content. + state.result += ' '; + } + + // Several line breaks - perceive as different lines. + } else { + state.result += common.repeat('\n', emptyLines); + } + + // Literal style: just add exact number of line breaks between content lines. + } else { + // Keep all line breaks except the header line break. + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } + + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state.position; + + while (!is_EOL(ch) && (ch !== 0)) { + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, state.position, false); + } + + return true; +} + +function readBlockSequence(state, nodeIndent) { + var _line, + _tag = state.tag, + _anchor = state.anchor, + _result = [], + following, + detected = false, + ch; + + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + if (state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError(state, 'tab characters must not be used in indentation'); + } + + if (ch !== 0x2D/* - */) { + break; + } + + following = state.input.charCodeAt(state.position + 1); + + if (!is_WS_OR_EOL(following)) { + break; + } + + detected = true; + state.position++; + + if (skipSeparationSpace(state, true, -1)) { + if (state.lineIndent <= nodeIndent) { + _result.push(null); + ch = state.input.charCodeAt(state.position); + continue; + } + } + + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state.result); + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a sequence entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'sequence'; + state.result = _result; + return true; + } + return false; +} + +function readBlockMapping(state, nodeIndent, flowIndent) { + var following, + allowCompact, + _line, + _keyLine, + _keyLineStart, + _keyPos, + _tag = state.tag, + _anchor = state.anchor, + _result = {}, + overridableKeys = Object.create(null), + keyTag = null, + keyNode = null, + valueNode = null, + atExplicitKey = false, + detected = false, + ch; + + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + if (!atExplicitKey && state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError(state, 'tab characters must not be used in indentation'); + } + + following = state.input.charCodeAt(state.position + 1); + _line = state.line; // Save the current line. + + // + // Explicit notation case. There are two separate blocks: + // first for the key (denoted by "?") and second for the value (denoted by ":") + // + if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { + + if (ch === 0x3F/* ? */) { + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = true; + allowCompact = true; + + } else if (atExplicitKey) { + // i.e. 0x3A/* : */ === character after the explicit key. + atExplicitKey = false; + allowCompact = true; + + } else { + throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + } + + state.position += 1; + ch = following; + + // + // Implicit notation case. Flow-style node as the key first, then ":", and the value. + // + } else { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; + + if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + // Neither implicit nor explicit notation. + // Reading is done. Go to the epilogue. + break; + } + + if (state.line === _line) { + ch = state.input.charCodeAt(state.position); + + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x3A/* : */) { + ch = state.input.charCodeAt(++state.position); + + if (!is_WS_OR_EOL(ch)) { + throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); + } + + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state.tag; + keyNode = state.result; + + } else if (detected) { + throwError(state, 'can not read an implicit mapping pair; a colon is missed'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + + } else if (detected) { + throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + } + + // + // Common reading code for both explicit and implicit notations. + // + if (state.line === _line || state.lineIndent > nodeIndent) { + if (atExplicitKey) { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; + } + + if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state.result; + } else { + valueNode = state.result; + } + } + + if (!atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + skipSeparationSpace(state, true, -1); + ch = state.input.charCodeAt(state.position); + } + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a mapping entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + // + // Epilogue. + // + + // Special case: last mapping's node contains only the key in explicit notation. + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + } + + // Expose the resulting mapping. + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'mapping'; + state.result = _result; + } + + return detected; +} + +function readTagProperty(state) { + var _position, + isVerbatim = false, + isNamed = false, + tagHandle, + tagName, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x21/* ! */) return false; + + if (state.tag !== null) { + throwError(state, 'duplication of a tag property'); + } + + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x3C/* < */) { + isVerbatim = true; + ch = state.input.charCodeAt(++state.position); + + } else if (ch === 0x21/* ! */) { + isNamed = true; + tagHandle = '!!'; + ch = state.input.charCodeAt(++state.position); + + } else { + tagHandle = '!'; + } + + _position = state.position; + + if (isVerbatim) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && ch !== 0x3E/* > */); + + if (state.position < state.length) { + tagName = state.input.slice(_position, state.position); + ch = state.input.charCodeAt(++state.position); + } else { + throwError(state, 'unexpected end of the stream within a verbatim tag'); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + + if (ch === 0x21/* ! */) { + if (!isNamed) { + tagHandle = state.input.slice(_position - 1, state.position + 1); + + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state, 'named tag handle cannot contain such characters'); + } + + isNamed = true; + _position = state.position + 1; + } else { + throwError(state, 'tag suffix cannot contain exclamation marks'); + } + } + + ch = state.input.charCodeAt(++state.position); + } + + tagName = state.input.slice(_position, state.position); + + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state, 'tag suffix cannot contain flow indicator characters'); + } + } + + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state, 'tag name cannot contain such characters: ' + tagName); + } + + try { + tagName = decodeURIComponent(tagName); + } catch (err) { + throwError(state, 'tag name is malformed: ' + tagName); + } + + if (isVerbatim) { + state.tag = tagName; + + } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { + state.tag = state.tagMap[tagHandle] + tagName; + + } else if (tagHandle === '!') { + state.tag = '!' + tagName; + + } else if (tagHandle === '!!') { + state.tag = 'tag:yaml.org,2002:' + tagName; + + } else { + throwError(state, 'undeclared tag handle "' + tagHandle + '"'); + } + + return true; +} + +function readAnchorProperty(state) { + var _position, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x26/* & */) return false; + + if (state.anchor !== null) { + throwError(state, 'duplication of an anchor property'); + } + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an anchor node must contain at least one character'); + } + + state.anchor = state.input.slice(_position, state.position); + return true; +} + +function readAlias(state) { + var _position, alias, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x2A/* * */) return false; + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an alias node must contain at least one character'); + } + + alias = state.input.slice(_position, state.position); + + if (!_hasOwnProperty.call(state.anchorMap, alias)) { + throwError(state, 'unidentified alias "' + alias + '"'); + } + + state.result = state.anchorMap[alias]; + skipSeparationSpace(state, true, -1); + return true; +} + +function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, + allowBlockScalars, + allowBlockCollections, + indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } + } + + if (indentStatus === 1) { + while (readTagProperty(state) || readAnchorProperty(state)) { + if (skipSeparationSpace(state, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + + if (state.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } else { + allowBlockCollections = false; + } + } + } + + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } + + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } + + blockIndent = state.position - state.lineStart; + + if (indentStatus === 1) { + if (allowBlockCollections && + (readBlockSequence(state, blockIndent) || + readBlockMapping(state, blockIndent, flowIndent)) || + readFlowCollection(state, flowIndent)) { + hasContent = true; + } else { + if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || + readSingleQuotedScalar(state, flowIndent) || + readDoubleQuotedScalar(state, flowIndent)) { + hasContent = true; + + } else if (readAlias(state)) { + hasContent = true; + + if (state.tag !== null || state.anchor !== null) { + throwError(state, 'alias node should not have any properties'); + } + + } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + + if (state.tag === null) { + state.tag = '?'; + } + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } else if (indentStatus === 0) { + // Special case: block sequences are allowed to have same indentation level as the parent. + // http://www.yaml.org/spec/1.2/spec.html#id2799784 + hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); + } + } + + if (state.tag === null) { + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + + } else if (state.tag === '?') { + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only automatically assigned to plain scalars. + // + // We only need to check kind conformity in case user explicitly assigns '?' + // tag, for example like this: "! [0]" + // + if (state.result !== null && state.kind !== 'scalar') { + throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + } + + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type = state.implicitTypes[typeIndex]; + + if (type.resolve(state.result)) { // `state.result` updated in resolver if matched + state.result = type.construct(state.result); + state.tag = type.tag; + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + break; + } + } + } else if (state.tag !== '!') { + if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { + type = state.typeMap[state.kind || 'fallback'][state.tag]; + } else { + // looking for multi type + type = null; + typeList = state.typeMap.multi[state.kind || 'fallback']; + + for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { + if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { + type = typeList[typeIndex]; + break; + } + } + } + + if (!type) { + throwError(state, 'unknown tag !<' + state.tag + '>'); + } + + if (state.result !== null && type.kind !== state.kind) { + throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + } + + if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched + throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); + } else { + state.result = type.construct(state.result, state.tag); + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } + + if (state.listener !== null) { + state.listener('close', state); + } + return state.tag !== null || state.anchor !== null || hasContent; +} + +function readDocument(state) { + var documentStart = state.position, + _position, + directiveName, + directiveArgs, + hasDirectives = false, + ch; + + state.version = null; + state.checkLineBreaks = state.legacy; + state.tagMap = Object.create(null); + state.anchorMap = Object.create(null); + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if (state.lineIndent > 0 || ch !== 0x25/* % */) { + break; + } + + hasDirectives = true; + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveName = state.input.slice(_position, state.position); + directiveArgs = []; + + if (directiveName.length < 1) { + throwError(state, 'directive name must not be less than one character in length'); + } + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && !is_EOL(ch)); + break; + } + + if (is_EOL(ch)) break; + + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveArgs.push(state.input.slice(_position, state.position)); + } + + if (ch !== 0) readLineBreak(state); + + if (_hasOwnProperty.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state, directiveName, directiveArgs); + } else { + throwWarning(state, 'unknown document directive "' + directiveName + '"'); + } + } + + skipSeparationSpace(state, true, -1); + + if (state.lineIndent === 0 && + state.input.charCodeAt(state.position) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + + } else if (hasDirectives) { + throwError(state, 'directives end mark is expected'); + } + + composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state, true, -1); + + if (state.checkLineBreaks && + PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { + throwWarning(state, 'non-ASCII line breaks are interpreted as content'); + } + + state.documents.push(state.result); + + if (state.position === state.lineStart && testDocumentSeparator(state)) { + + if (state.input.charCodeAt(state.position) === 0x2E/* . */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + } + return; + } + + if (state.position < (state.length - 1)) { + throwError(state, 'end of the stream or a document separator is expected'); + } else { + return; + } +} + + +function loadDocuments(input, options) { + input = String(input); + options = options || {}; + + if (input.length !== 0) { + + // Add tailing `\n` if not exists + if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && + input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { + input += '\n'; + } + + // Strip BOM + if (input.charCodeAt(0) === 0xFEFF) { + input = input.slice(1); + } + } + + var state = new State(input, options); + + var nullpos = input.indexOf('\0'); + + if (nullpos !== -1) { + state.position = nullpos; + throwError(state, 'null byte is not allowed in input'); + } + + // Use 0 as string terminator. That significantly simplifies bounds check. + state.input += '\0'; + + while (state.input.charCodeAt(state.position) === 0x20/* Space */) { + state.lineIndent += 1; + state.position += 1; + } + + while (state.position < (state.length - 1)) { + readDocument(state); + } + + return state.documents; +} + + +function loadAll(input, iterator, options) { + if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { + options = iterator; + iterator = null; + } + + var documents = loadDocuments(input, options); + + if (typeof iterator !== 'function') { + return documents; + } + + for (var index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} + + +function load(input, options) { + var documents = loadDocuments(input, options); + + if (documents.length === 0) { + /*eslint-disable no-undefined*/ + return undefined; + } else if (documents.length === 1) { + return documents[0]; + } + throw new YAMLException('expected a single document in the stream, but found more'); +} + + +module.exports.loadAll = loadAll; +module.exports.load = load; + + +/***/ }), + +/***/ 1082: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +/*eslint-disable max-len*/ + +var YAMLException = __nccwpck_require__(8179); +var Type = __nccwpck_require__(6073); + + +function compileList(schema, name) { + var result = []; + + schema[name].forEach(function (currentType) { + var newIndex = result.length; + + result.forEach(function (previousType, previousIndex) { + if (previousType.tag === currentType.tag && + previousType.kind === currentType.kind && + previousType.multi === currentType.multi) { + + newIndex = previousIndex; + } + }); + + result[newIndex] = currentType; + }); + + return result; +} + + +function compileMap(/* lists... */) { + var result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {}, + multi: { + scalar: [], + sequence: [], + mapping: [], + fallback: [] + } + }, index, length; + + function collectType(type) { + if (type.multi) { + result.multi[type.kind].push(type); + result.multi['fallback'].push(type); + } else { + result[type.kind][type.tag] = result['fallback'][type.tag] = type; + } + } + + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); + } + return result; +} + + +function Schema(definition) { + return this.extend(definition); +} + + +Schema.prototype.extend = function extend(definition) { + var implicit = []; + var explicit = []; + + if (definition instanceof Type) { + // Schema.extend(type) + explicit.push(definition); + + } else if (Array.isArray(definition)) { + // Schema.extend([ type1, type2, ... ]) + explicit = explicit.concat(definition); + + } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { + // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) + if (definition.implicit) implicit = implicit.concat(definition.implicit); + if (definition.explicit) explicit = explicit.concat(definition.explicit); + + } else { + throw new YAMLException('Schema.extend argument should be a Type, [ Type ], ' + + 'or a schema definition ({ implicit: [...], explicit: [...] })'); + } + + implicit.forEach(function (type) { + if (!(type instanceof Type)) { + throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } + + if (type.loadKind && type.loadKind !== 'scalar') { + throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); + } + + if (type.multi) { + throw new YAMLException('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); + } + }); + + explicit.forEach(function (type) { + if (!(type instanceof Type)) { + throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } + }); + + var result = Object.create(Schema.prototype); + + result.implicit = (this.implicit || []).concat(implicit); + result.explicit = (this.explicit || []).concat(explicit); + + result.compiledImplicit = compileList(result, 'implicit'); + result.compiledExplicit = compileList(result, 'explicit'); + result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); + + return result; +}; + + +module.exports = Schema; + + +/***/ }), + +/***/ 2011: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; +// Standard YAML's Core schema. +// http://www.yaml.org/spec/1.2/spec.html#id2804923 +// +// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. +// So, Core schema has no distinctions from JSON schema is JS-YAML. + + + + + +module.exports = __nccwpck_require__(1035); + + +/***/ }), + +/***/ 8759: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; +// JS-YAML's default schema for `safeLoad` function. +// It is not described in the YAML specification. +// +// This schema is based on standard YAML's Core schema and includes most of +// extra types described at YAML tag repository. (http://yaml.org/type/) + + + + + +module.exports = (__nccwpck_require__(2011).extend)({ + implicit: [ + __nccwpck_require__(9212), + __nccwpck_require__(6104) + ], + explicit: [ + __nccwpck_require__(7900), + __nccwpck_require__(9046), + __nccwpck_require__(6860), + __nccwpck_require__(9548) + ] +}); + + +/***/ }), + +/***/ 8562: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; +// Standard YAML's Failsafe schema. +// http://www.yaml.org/spec/1.2/spec.html#id2802346 + + + + + +var Schema = __nccwpck_require__(1082); + + +module.exports = new Schema({ + explicit: [ + __nccwpck_require__(3619), + __nccwpck_require__(7283), + __nccwpck_require__(6150) + ] +}); + + +/***/ }), + +/***/ 1035: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; +// Standard YAML's JSON schema. +// http://www.yaml.org/spec/1.2/spec.html#id2803231 +// +// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. +// So, this schema is not such strict as defined in the YAML specification. +// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. + + + + + +module.exports = (__nccwpck_require__(8562).extend)({ + implicit: [ + __nccwpck_require__(721), + __nccwpck_require__(4993), + __nccwpck_require__(1615), + __nccwpck_require__(2705) + ] +}); + + +/***/ }), + +/***/ 6975: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + + +var common = __nccwpck_require__(6829); + + +// get snippet for a single line, respecting maxLength +function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { + var head = ''; + var tail = ''; + var maxHalfLength = Math.floor(maxLineLength / 2) - 1; + + if (position - lineStart > maxHalfLength) { + head = ' ... '; + lineStart = position - maxHalfLength + head.length; + } + + if (lineEnd - position > maxHalfLength) { + tail = ' ...'; + lineEnd = position + maxHalfLength - tail.length; + } + + return { + str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, + pos: position - lineStart + head.length // relative position + }; +} + + +function padStart(string, max) { + return common.repeat(' ', max - string.length) + string; +} + + +function makeSnippet(mark, options) { + options = Object.create(options || null); + + if (!mark.buffer) return null; + + if (!options.maxLength) options.maxLength = 79; + if (typeof options.indent !== 'number') options.indent = 1; + if (typeof options.linesBefore !== 'number') options.linesBefore = 3; + if (typeof options.linesAfter !== 'number') options.linesAfter = 2; + + var re = /\r?\n|\r|\0/g; + var lineStarts = [ 0 ]; + var lineEnds = []; + var match; + var foundLineNo = -1; + + while ((match = re.exec(mark.buffer))) { + lineEnds.push(match.index); + lineStarts.push(match.index + match[0].length); + + if (mark.position <= match.index && foundLineNo < 0) { + foundLineNo = lineStarts.length - 2; + } + } + + if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; + + var result = '', i, line; + var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; + var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); + + for (i = 1; i <= options.linesBefore; i++) { + if (foundLineNo - i < 0) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo - i], + lineEnds[foundLineNo - i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), + maxLineLength + ); + result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n' + result; + } + + line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); + result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; + result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; + + for (i = 1; i <= options.linesAfter; i++) { + if (foundLineNo + i >= lineEnds.length) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo + i], + lineEnds[foundLineNo + i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), + maxLineLength + ); + result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; + } + + return result.replace(/\n$/, ''); +} + + +module.exports = makeSnippet; + + +/***/ }), + +/***/ 6073: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var YAMLException = __nccwpck_require__(8179); + +var TYPE_CONSTRUCTOR_OPTIONS = [ + 'kind', + 'multi', + 'resolve', + 'construct', + 'instanceOf', + 'predicate', + 'represent', + 'representName', + 'defaultStyle', + 'styleAliases' +]; + +var YAML_NODE_KINDS = [ + 'scalar', + 'sequence', + 'mapping' +]; + +function compileStyleAliases(map) { + var result = {}; + + if (map !== null) { + Object.keys(map).forEach(function (style) { + map[style].forEach(function (alias) { + result[String(alias)] = style; + }); + }); + } + + return result; +} + +function Type(tag, options) { + options = options || {}; + + Object.keys(options).forEach(function (name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + } + }); + + // TODO: Add tag format check. + this.options = options; // keep original options in case user wants to extend this type later + this.tag = tag; + this.kind = options['kind'] || null; + this.resolve = options['resolve'] || function () { return true; }; + this.construct = options['construct'] || function (data) { return data; }; + this.instanceOf = options['instanceOf'] || null; + this.predicate = options['predicate'] || null; + this.represent = options['represent'] || null; + this.representName = options['representName'] || null; + this.defaultStyle = options['defaultStyle'] || null; + this.multi = options['multi'] || false; + this.styleAliases = compileStyleAliases(options['styleAliases'] || null); + + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } +} + +module.exports = Type; + + +/***/ }), + +/***/ 7900: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +/*eslint-disable no-bitwise*/ + + +var Type = __nccwpck_require__(6073); + + +// [ 64, 65, 66 ] -> [ padding, CR, LF ] +var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; + + +function resolveYamlBinary(data) { + if (data === null) return false; + + var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; + + // Convert one by one. + for (idx = 0; idx < max; idx++) { + code = map.indexOf(data.charAt(idx)); + + // Skip CR/LF + if (code > 64) continue; + + // Fail on illegal characters + if (code < 0) return false; + + bitlen += 6; + } + + // If there are any bits left, source was corrupted + return (bitlen % 8) === 0; +} + +function constructYamlBinary(data) { + var idx, tailbits, + input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan + max = input.length, + map = BASE64_MAP, + bits = 0, + result = []; + + // Collect by 6*4 bits (3 bytes) + + for (idx = 0; idx < max; idx++) { + if ((idx % 4 === 0) && idx) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } + + bits = (bits << 6) | map.indexOf(input.charAt(idx)); + } + + // Dump tail + + tailbits = (max % 4) * 6; + + if (tailbits === 0) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } else if (tailbits === 18) { + result.push((bits >> 10) & 0xFF); + result.push((bits >> 2) & 0xFF); + } else if (tailbits === 12) { + result.push((bits >> 4) & 0xFF); + } + + return new Uint8Array(result); +} + +function representYamlBinary(object /*, style*/) { + var result = '', bits = 0, idx, tail, + max = object.length, + map = BASE64_MAP; + + // Convert every three bytes to 4 ASCII characters. + + for (idx = 0; idx < max; idx++) { + if ((idx % 3 === 0) && idx) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } + + bits = (bits << 8) + object[idx]; + } + + // Dump tail + + tail = max % 3; + + if (tail === 0) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } else if (tail === 2) { + result += map[(bits >> 10) & 0x3F]; + result += map[(bits >> 4) & 0x3F]; + result += map[(bits << 2) & 0x3F]; + result += map[64]; + } else if (tail === 1) { + result += map[(bits >> 2) & 0x3F]; + result += map[(bits << 4) & 0x3F]; + result += map[64]; + result += map[64]; + } + + return result; +} + +function isBinary(obj) { + return Object.prototype.toString.call(obj) === '[object Uint8Array]'; +} + +module.exports = new Type('tag:yaml.org,2002:binary', { + kind: 'scalar', + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary +}); + + +/***/ }), + +/***/ 4993: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +function resolveYamlBoolean(data) { + if (data === null) return false; + + var max = data.length; + + return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || + (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); +} + +function constructYamlBoolean(data) { + return data === 'true' || + data === 'True' || + data === 'TRUE'; +} + +function isBoolean(object) { + return Object.prototype.toString.call(object) === '[object Boolean]'; +} + +module.exports = new Type('tag:yaml.org,2002:bool', { + kind: 'scalar', + resolve: resolveYamlBoolean, + construct: constructYamlBoolean, + predicate: isBoolean, + represent: { + lowercase: function (object) { return object ? 'true' : 'false'; }, + uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, + camelcase: function (object) { return object ? 'True' : 'False'; } + }, + defaultStyle: 'lowercase' +}); + + +/***/ }), + +/***/ 2705: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var common = __nccwpck_require__(6829); +var Type = __nccwpck_require__(6073); + +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + + // .2e4, .2 + // special case, seems not from spec + '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + + // .inf + '|[-+]?\\.(?:inf|Inf|INF)' + + // .nan + '|\\.(?:nan|NaN|NAN))$'); + +function resolveYamlFloat(data) { + if (data === null) return false; + + if (!YAML_FLOAT_PATTERN.test(data) || + // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === '_') { + return false; + } + + return true; +} + +function constructYamlFloat(data) { + var value, sign; + + value = data.replace(/_/g, '').toLowerCase(); + sign = value[0] === '-' ? -1 : 1; + + if ('+-'.indexOf(value[0]) >= 0) { + value = value.slice(1); + } + + if (value === '.inf') { + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + + } else if (value === '.nan') { + return NaN; + } + return sign * parseFloat(value, 10); +} + + +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; + +function representYamlFloat(object, style) { + var res; + + if (isNaN(object)) { + switch (style) { + case 'lowercase': return '.nan'; + case 'uppercase': return '.NAN'; + case 'camelcase': return '.NaN'; + } + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '.inf'; + case 'uppercase': return '.INF'; + case 'camelcase': return '.Inf'; + } + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '-.inf'; + case 'uppercase': return '-.INF'; + case 'camelcase': return '-.Inf'; + } + } else if (common.isNegativeZero(object)) { + return '-0.0'; + } + + res = object.toString(10); + + // JS stringifier can build scientific format without dots: 5e-100, + // while YAML requres dot: 5.e-100. Fix it with simple hack + + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; +} + +function isFloat(object) { + return (Object.prototype.toString.call(object) === '[object Number]') && + (object % 1 !== 0 || common.isNegativeZero(object)); +} + +module.exports = new Type('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: 'lowercase' +}); + + +/***/ }), + +/***/ 1615: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var common = __nccwpck_require__(6829); +var Type = __nccwpck_require__(6073); + +function isHexCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || + ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || + ((0x61/* a */ <= c) && (c <= 0x66/* f */)); +} + +function isOctCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); +} + +function isDecCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); +} + +function resolveYamlInteger(data) { + if (data === null) return false; + + var max = data.length, + index = 0, + hasDigits = false, + ch; + + if (!max) return false; + + ch = data[index]; + + // sign + if (ch === '-' || ch === '+') { + ch = data[++index]; + } + + if (ch === '0') { + // 0 + if (index + 1 === max) return true; + ch = data[++index]; + + // base 2, base 8, base 16 + + if (ch === 'b') { + // base 2 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (ch !== '0' && ch !== '1') return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + + if (ch === 'x') { + // base 16 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isHexCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + + if (ch === 'o') { + // base 8 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isOctCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + } + + // base 10 (except 0) + + // value should not start with `_`; + if (ch === '_') return false; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isDecCode(data.charCodeAt(index))) { + return false; + } + hasDigits = true; + } + + // Should have digits and should not end with `_` + if (!hasDigits || ch === '_') return false; + + return true; +} + +function constructYamlInteger(data) { + var value = data, sign = 1, ch; + + if (value.indexOf('_') !== -1) { + value = value.replace(/_/g, ''); + } + + ch = value[0]; + + if (ch === '-' || ch === '+') { + if (ch === '-') sign = -1; + value = value.slice(1); + ch = value[0]; + } + + if (value === '0') return 0; + + if (ch === '0') { + if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); + if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); + if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); + } + + return sign * parseInt(value, 10); +} + +function isInteger(object) { + return (Object.prototype.toString.call(object)) === '[object Number]' && + (object % 1 === 0 && !common.isNegativeZero(object)); +} + +module.exports = new Type('tag:yaml.org,2002:int', { + kind: 'scalar', + resolve: resolveYamlInteger, + construct: constructYamlInteger, + predicate: isInteger, + represent: { + binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, + octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, + decimal: function (obj) { return obj.toString(10); }, + /* eslint-disable max-len */ + hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } + }, + defaultStyle: 'decimal', + styleAliases: { + binary: [ 2, 'bin' ], + octal: [ 8, 'oct' ], + decimal: [ 10, 'dec' ], + hexadecimal: [ 16, 'hex' ] + } +}); + + +/***/ }), + +/***/ 6150: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +module.exports = new Type('tag:yaml.org,2002:map', { + kind: 'mapping', + construct: function (data) { return data !== null ? data : {}; } +}); + + +/***/ }), + +/***/ 6104: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +function resolveYamlMerge(data) { + return data === '<<' || data === null; +} + +module.exports = new Type('tag:yaml.org,2002:merge', { + kind: 'scalar', + resolve: resolveYamlMerge +}); + + +/***/ }), + +/***/ 721: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +function resolveYamlNull(data) { + if (data === null) return true; + + var max = data.length; + + return (max === 1 && data === '~') || + (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); +} + +function constructYamlNull() { + return null; +} + +function isNull(object) { + return object === null; +} + +module.exports = new Type('tag:yaml.org,2002:null', { + kind: 'scalar', + resolve: resolveYamlNull, + construct: constructYamlNull, + predicate: isNull, + represent: { + canonical: function () { return '~'; }, + lowercase: function () { return 'null'; }, + uppercase: function () { return 'NULL'; }, + camelcase: function () { return 'Null'; }, + empty: function () { return ''; } + }, + defaultStyle: 'lowercase' +}); + + +/***/ }), + +/***/ 9046: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +var _hasOwnProperty = Object.prototype.hasOwnProperty; +var _toString = Object.prototype.toString; + +function resolveYamlOmap(data) { + if (data === null) return true; + + var objectKeys = [], index, length, pair, pairKey, pairHasKey, + object = data; + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; + + if (_toString.call(pair) !== '[object Object]') return false; + + for (pairKey in pair) { + if (_hasOwnProperty.call(pair, pairKey)) { + if (!pairHasKey) pairHasKey = true; + else return false; + } + } + + if (!pairHasKey) return false; + + if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); + else return false; + } + + return true; +} + +function constructYamlOmap(data) { + return data !== null ? data : []; +} + +module.exports = new Type('tag:yaml.org,2002:omap', { + kind: 'sequence', + resolve: resolveYamlOmap, + construct: constructYamlOmap +}); + + +/***/ }), + +/***/ 6860: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +var _toString = Object.prototype.toString; + +function resolveYamlPairs(data) { + if (data === null) return true; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + if (_toString.call(pair) !== '[object Object]') return false; + + keys = Object.keys(pair); + + if (keys.length !== 1) return false; + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return true; +} + +function constructYamlPairs(data) { + if (data === null) return []; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + keys = Object.keys(pair); + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return result; +} + +module.exports = new Type('tag:yaml.org,2002:pairs', { + kind: 'sequence', + resolve: resolveYamlPairs, + construct: constructYamlPairs +}); + + +/***/ }), + +/***/ 7283: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +module.exports = new Type('tag:yaml.org,2002:seq', { + kind: 'sequence', + construct: function (data) { return data !== null ? data : []; } +}); + + +/***/ }), + +/***/ 9548: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +var _hasOwnProperty = Object.prototype.hasOwnProperty; + +function resolveYamlSet(data) { + if (data === null) return true; + + var key, object = data; + + for (key in object) { + if (_hasOwnProperty.call(object, key)) { + if (object[key] !== null) return false; + } + } + + return true; +} + +function constructYamlSet(data) { + return data !== null ? data : {}; +} + +module.exports = new Type('tag:yaml.org,2002:set', { + kind: 'mapping', + resolve: resolveYamlSet, + construct: constructYamlSet +}); + + +/***/ }), + +/***/ 3619: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +module.exports = new Type('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function (data) { return data !== null ? data : ''; } +}); + + +/***/ }), + +/***/ 9212: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +"use strict"; + + +var Type = __nccwpck_require__(6073); + +var YAML_DATE_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9])' + // [2] month + '-([0-9][0-9])$'); // [3] day + +var YAML_TIMESTAMP_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9]?)' + // [2] month + '-([0-9][0-9]?)' + // [3] day + '(?:[Tt]|[ \\t]+)' + // ... + '([0-9][0-9]?)' + // [4] hour + ':([0-9][0-9])' + // [5] minute + ':([0-9][0-9])' + // [6] second + '(?:\\.([0-9]*))?' + // [7] fraction + '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour + '(?::([0-9][0-9]))?))?$'); // [11] tz_minute + +function resolveYamlTimestamp(data) { + if (data === null) return false; + if (YAML_DATE_REGEXP.exec(data) !== null) return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; + return false; +} + +function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, + delta = null, tz_hour, tz_minute, date; + + match = YAML_DATE_REGEXP.exec(data); + if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); + + if (match === null) throw new Error('Date resolve error'); + + // match: [1] year [2] month [3] day + + year = +(match[1]); + month = +(match[2]) - 1; // JS month starts with 0 + day = +(match[3]); + + if (!match[4]) { // no hour + return new Date(Date.UTC(year, month, day)); + } + + // match: [4] hour [5] minute [6] second [7] fraction + + hour = +(match[4]); + minute = +(match[5]); + second = +(match[6]); + + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { // milli-seconds + fraction += '0'; + } + fraction = +fraction; + } + + // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute + + if (match[9]) { + tz_hour = +(match[10]); + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds + if (match[9] === '-') delta = -delta; + } + + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + + if (delta) date.setTime(date.getTime() - delta); + + return date; +} + +function representYamlTimestamp(object /*, style*/) { + return object.toISOString(); +} + +module.exports = new Type('tag:yaml.org,2002:timestamp', { + kind: 'scalar', + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); + + +/***/ }), + +/***/ 250: +/***/ (function(module, exports, __nccwpck_require__) { + +/* module decorator */ module = __nccwpck_require__.nmd(module); +/** + * @license + * Lodash + * Copyright OpenJS Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ +;(function() { + + /** Used as a safe reference for `undefined` in pre-ES5 environments. */ + var undefined; + + /** Used as the semantic version number. */ + var VERSION = '4.17.21'; + + /** Used as the size to enable large array optimizations. */ + var LARGE_ARRAY_SIZE = 200; + + /** Error message constants. */ + var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', + FUNC_ERROR_TEXT = 'Expected a function', + INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; + + /** Used to stand-in for `undefined` hash values. */ + var HASH_UNDEFINED = '__lodash_hash_undefined__'; + + /** Used as the maximum memoize cache size. */ + var MAX_MEMOIZE_SIZE = 500; + + /** Used as the internal argument placeholder. */ + var PLACEHOLDER = '__lodash_placeholder__'; + + /** Used to compose bitmasks for cloning. */ + var CLONE_DEEP_FLAG = 1, + CLONE_FLAT_FLAG = 2, + CLONE_SYMBOLS_FLAG = 4; + + /** Used to compose bitmasks for value comparisons. */ + var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + + /** Used to compose bitmasks for function metadata. */ + var WRAP_BIND_FLAG = 1, + WRAP_BIND_KEY_FLAG = 2, + WRAP_CURRY_BOUND_FLAG = 4, + WRAP_CURRY_FLAG = 8, + WRAP_CURRY_RIGHT_FLAG = 16, + WRAP_PARTIAL_FLAG = 32, + WRAP_PARTIAL_RIGHT_FLAG = 64, + WRAP_ARY_FLAG = 128, + WRAP_REARG_FLAG = 256, + WRAP_FLIP_FLAG = 512; + + /** Used as default options for `_.truncate`. */ + var DEFAULT_TRUNC_LENGTH = 30, + DEFAULT_TRUNC_OMISSION = '...'; + + /** Used to detect hot functions by number of calls within a span of milliseconds. */ + var HOT_COUNT = 800, + HOT_SPAN = 16; + + /** Used to indicate the type of lazy iteratees. */ + var LAZY_FILTER_FLAG = 1, + LAZY_MAP_FLAG = 2, + LAZY_WHILE_FLAG = 3; + + /** Used as references for various `Number` constants. */ + var INFINITY = 1 / 0, + MAX_SAFE_INTEGER = 9007199254740991, + MAX_INTEGER = 1.7976931348623157e+308, + NAN = 0 / 0; + + /** Used as references for the maximum length and index of an array. */ + var MAX_ARRAY_LENGTH = 4294967295, + MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, + HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; + + /** Used to associate wrap methods with their bit flags. */ + var wrapFlags = [ + ['ary', WRAP_ARY_FLAG], + ['bind', WRAP_BIND_FLAG], + ['bindKey', WRAP_BIND_KEY_FLAG], + ['curry', WRAP_CURRY_FLAG], + ['curryRight', WRAP_CURRY_RIGHT_FLAG], + ['flip', WRAP_FLIP_FLAG], + ['partial', WRAP_PARTIAL_FLAG], + ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], + ['rearg', WRAP_REARG_FLAG] + ]; + + /** `Object#toString` result references. */ + var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + asyncTag = '[object AsyncFunction]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + domExcTag = '[object DOMException]', + errorTag = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag = '[object Map]', + numberTag = '[object Number]', + nullTag = '[object Null]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + proxyTag = '[object Proxy]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]', + undefinedTag = '[object Undefined]', + weakMapTag = '[object WeakMap]', + weakSetTag = '[object WeakSet]'; + + var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + + /** Used to match empty string literals in compiled template source. */ + var reEmptyStringLeading = /\b__p \+= '';/g, + reEmptyStringMiddle = /\b(__p \+=) '' \+/g, + reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; + + /** Used to match HTML entities and HTML characters. */ + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, + reUnescapedHtml = /[&<>"']/g, + reHasEscapedHtml = RegExp(reEscapedHtml.source), + reHasUnescapedHtml = RegExp(reUnescapedHtml.source); + + /** Used to match template delimiters. */ + var reEscape = /<%-([\s\S]+?)%>/g, + reEvaluate = /<%([\s\S]+?)%>/g, + reInterpolate = /<%=([\s\S]+?)%>/g; + + /** Used to match property names within property paths. */ + var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + + /** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ + var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, + reHasRegExpChar = RegExp(reRegExpChar.source); + + /** Used to match leading whitespace. */ + var reTrimStart = /^\s+/; + + /** Used to match a single whitespace character. */ + var reWhitespace = /\s/; + + /** Used to match wrap detail comments. */ + var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, + reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, + reSplitDetails = /,? & /; + + /** Used to match words composed of alphanumeric characters. */ + var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; + + /** + * Used to validate the `validate` option in `_.template` variable. + * + * Forbids characters which could potentially change the meaning of the function argument definition: + * - "()," (modification of function parameters) + * - "=" (default value) + * - "[]{}" (destructuring of function parameters) + * - "/" (beginning of a comment) + * - whitespace + */ + var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; + + /** Used to match backslashes in property paths. */ + var reEscapeChar = /\\(\\)?/g; + + /** + * Used to match + * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). + */ + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; + + /** Used to match `RegExp` flags from their coerced string values. */ + var reFlags = /\w*$/; + + /** Used to detect bad signed hexadecimal string values. */ + var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + + /** Used to detect binary string values. */ + var reIsBinary = /^0b[01]+$/i; + + /** Used to detect host constructors (Safari). */ + var reIsHostCtor = /^\[object .+?Constructor\]$/; + + /** Used to detect octal string values. */ + var reIsOctal = /^0o[0-7]+$/i; + + /** Used to detect unsigned integer values. */ + var reIsUint = /^(?:0|[1-9]\d*)$/; + + /** Used to match Latin Unicode letters (excluding mathematical operators). */ + var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; + + /** Used to ensure capturing order of template delimiters. */ + var reNoMatch = /($^)/; + + /** Used to match unescaped characters in compiled string literals. */ + var reUnescapedString = /['\n\r\u2028\u2029\\]/g; + + /** Used to compose unicode character classes. */ + var rsAstralRange = '\\ud800-\\udfff', + rsComboMarksRange = '\\u0300-\\u036f', + reComboHalfMarksRange = '\\ufe20-\\ufe2f', + rsComboSymbolsRange = '\\u20d0-\\u20ff', + rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, + rsDingbatRange = '\\u2700-\\u27bf', + rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', + rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', + rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', + rsPunctuationRange = '\\u2000-\\u206f', + rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', + rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', + rsVarRange = '\\ufe0e\\ufe0f', + rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; + + /** Used to compose unicode capture groups. */ + var rsApos = "['\u2019]", + rsAstral = '[' + rsAstralRange + ']', + rsBreak = '[' + rsBreakRange + ']', + rsCombo = '[' + rsComboRange + ']', + rsDigits = '\\d+', + rsDingbat = '[' + rsDingbatRange + ']', + rsLower = '[' + rsLowerRange + ']', + rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', + rsNonAstral = '[^' + rsAstralRange + ']', + rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', + rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', + rsUpper = '[' + rsUpperRange + ']', + rsZWJ = '\\u200d'; + + /** Used to compose unicode regexes. */ + var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', + rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', + rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', + rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', + reOptMod = rsModifier + '?', + rsOptVar = '[' + rsVarRange + ']?', + rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', + rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', + rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', + rsSeq = rsOptVar + reOptMod + rsOptJoin, + rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, + rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; + + /** Used to match apostrophes. */ + var reApos = RegExp(rsApos, 'g'); + + /** + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ + var reComboMark = RegExp(rsCombo, 'g'); + + /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ + var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); + + /** Used to match complex or compound words. */ + var reUnicodeWord = RegExp([ + rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', + rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', + rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, + rsUpper + '+' + rsOptContrUpper, + rsOrdUpper, + rsOrdLower, + rsDigits, + rsEmoji + ].join('|'), 'g'); + + /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ + var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + + /** Used to detect strings that need a more robust regexp to match words. */ + var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; + + /** Used to assign default `context` object properties. */ + var contextProps = [ + 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', + 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', + 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', + 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', + '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' + ]; + + /** Used to make template sourceURLs easier to identify. */ + var templateCounter = -1; + + /** Used to identify `toStringTag` values of typed arrays. */ + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = + typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = + typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = + typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = + typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = + typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = + typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = + typedArrayTags[errorTag] = typedArrayTags[funcTag] = + typedArrayTags[mapTag] = typedArrayTags[numberTag] = + typedArrayTags[objectTag] = typedArrayTags[regexpTag] = + typedArrayTags[setTag] = typedArrayTags[stringTag] = + typedArrayTags[weakMapTag] = false; + + /** Used to identify `toStringTag` values supported by `_.clone`. */ + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = + cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = + cloneableTags[boolTag] = cloneableTags[dateTag] = + cloneableTags[float32Tag] = cloneableTags[float64Tag] = + cloneableTags[int8Tag] = cloneableTags[int16Tag] = + cloneableTags[int32Tag] = cloneableTags[mapTag] = + cloneableTags[numberTag] = cloneableTags[objectTag] = + cloneableTags[regexpTag] = cloneableTags[setTag] = + cloneableTags[stringTag] = cloneableTags[symbolTag] = + cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = + cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = + cloneableTags[weakMapTag] = false; + + /** Used to map Latin Unicode letters to basic Latin letters. */ + var deburredLetters = { + // Latin-1 Supplement block. + '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', + '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', + '\xc7': 'C', '\xe7': 'c', + '\xd0': 'D', '\xf0': 'd', + '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', + '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', + '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', + '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', + '\xd1': 'N', '\xf1': 'n', + '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', + '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', + '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', + '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', + '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', + '\xc6': 'Ae', '\xe6': 'ae', + '\xde': 'Th', '\xfe': 'th', + '\xdf': 'ss', + // Latin Extended-A block. + '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', + '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', + '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', + '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', + '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', + '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', + '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', + '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', + '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', + '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', + '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', + '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', + '\u0134': 'J', '\u0135': 'j', + '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', + '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', + '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', + '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', + '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', + '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', + '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', + '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', + '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', + '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', + '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', + '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', + '\u0163': 't', '\u0165': 't', '\u0167': 't', + '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', + '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', + '\u0174': 'W', '\u0175': 'w', + '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', + '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', + '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', + '\u0132': 'IJ', '\u0133': 'ij', + '\u0152': 'Oe', '\u0153': 'oe', + '\u0149': "'n", '\u017f': 's' + }; + + /** Used to map characters to HTML entities. */ + var htmlEscapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + + /** Used to map HTML entities to characters. */ + var htmlUnescapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + ''': "'" + }; + + /** Used to escape characters for inclusion in compiled string literals. */ + var stringEscapes = { + '\\': '\\', + "'": "'", + '\n': 'n', + '\r': 'r', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + /** Built-in method references without a dependency on `root`. */ + var freeParseFloat = parseFloat, + freeParseInt = parseInt; + + /** Detect free variable `global` from Node.js. */ + var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + + /** Detect free variable `self`. */ + var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + + /** Used as a reference to the global object. */ + var root = freeGlobal || freeSelf || Function('return this')(); + + /** Detect free variable `exports`. */ + var freeExports = true && exports && !exports.nodeType && exports; + + /** Detect free variable `module`. */ + var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module; + + /** Detect the popular CommonJS extension `module.exports`. */ + var moduleExports = freeModule && freeModule.exports === freeExports; + + /** Detect free variable `process` from Node.js. */ + var freeProcess = moduleExports && freeGlobal.process; + + /** Used to access faster Node.js helpers. */ + var nodeUtil = (function() { + try { + // Use `util.types` for Node.js 10+. + var types = freeModule && freeModule.require && freeModule.require('util').types; + + if (types) { + return types; + } + + // Legacy `process.binding('util')` for Node.js < 10. + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} + }()); + + /* Node.js helper references. */ + var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, + nodeIsDate = nodeUtil && nodeUtil.isDate, + nodeIsMap = nodeUtil && nodeUtil.isMap, + nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, + nodeIsSet = nodeUtil && nodeUtil.isSet, + nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + + /*--------------------------------------------------------------------------*/ + + /** + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. + * + * @private + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} args The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ + function apply(func, thisArg, args) { + switch (args.length) { + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); + } + + /** + * A specialized version of `baseAggregator` for arrays. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. + */ + function arrayAggregator(array, setter, iteratee, accumulator) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + var value = array[index]; + setter(accumulator, value, iteratee(value), array); + } + return accumulator; + } + + /** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; + } + + /** + * A specialized version of `_.forEachRight` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEachRight(array, iteratee) { + var length = array == null ? 0 : array.length; + + while (length--) { + if (iteratee(array[length], length, array) === false) { + break; + } + } + return array; + } + + /** + * A specialized version of `_.every` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + */ + function arrayEvery(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } + } + return true; + } + + /** + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ + function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; + } + + /** + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludes(array, value) { + var length = array == null ? 0 : array.length; + return !!length && baseIndexOf(array, value, 0) > -1; + } + + /** + * This function is like `arrayIncludes` except that it accepts a comparator. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @param {Function} comparator The comparator invoked per element. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludesWith(array, value, comparator) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (comparator(value, array[index])) { + return true; + } + } + return false; + } + + /** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; + } + + /** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ + function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; + } + + /** + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array == null ? 0 : array.length; + + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; + } + + /** + * A specialized version of `_.reduceRight` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the last element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduceRight(array, iteratee, accumulator, initAccum) { + var length = array == null ? 0 : array.length; + if (initAccum && length) { + accumulator = array[--length]; + } + while (length--) { + accumulator = iteratee(accumulator, array[length], length, array); + } + return accumulator; + } + + /** + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; + } + + /** + * Gets the size of an ASCII `string`. + * + * @private + * @param {string} string The string inspect. + * @returns {number} Returns the string size. + */ + var asciiSize = baseProperty('length'); + + /** + * Converts an ASCII `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function asciiToArray(string) { + return string.split(''); + } + + /** + * Splits an ASCII `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ + function asciiWords(string) { + return string.match(reAsciiWord) || []; + } + + /** + * The base implementation of methods like `_.findKey` and `_.findLastKey`, + * without support for iteratee shorthands, which iterates over `collection` + * using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the found element or its key, else `undefined`. + */ + function baseFindKey(collection, predicate, eachFunc) { + var result; + eachFunc(collection, function(value, key, collection) { + if (predicate(value, key, collection)) { + result = key; + return false; + } + }); + return result; + } + + /** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 1 : -1); + + while ((fromRight ? index-- : ++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; + } + + /** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseIndexOf(array, value, fromIndex) { + return value === value + ? strictIndexOf(array, value, fromIndex) + : baseFindIndex(array, baseIsNaN, fromIndex); + } + + /** + * This function is like `baseIndexOf` except that it accepts a comparator. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @param {Function} comparator The comparator invoked per element. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseIndexOfWith(array, value, fromIndex, comparator) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (comparator(array[index], value)) { + return index; + } + } + return -1; + } + + /** + * The base implementation of `_.isNaN` without support for number objects. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + */ + function baseIsNaN(value) { + return value !== value; + } + + /** + * The base implementation of `_.mean` and `_.meanBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the mean. + */ + function baseMean(array, iteratee) { + var length = array == null ? 0 : array.length; + return length ? (baseSum(array, iteratee) / length) : NAN; + } + + /** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; + } + + /** + * The base implementation of `_.propertyOf` without support for deep paths. + * + * @private + * @param {Object} object The object to query. + * @returns {Function} Returns the new accessor function. + */ + function basePropertyOf(object) { + return function(key) { + return object == null ? undefined : object[key]; + }; + } + + /** + * The base implementation of `_.reduce` and `_.reduceRight`, without support + * for iteratee shorthands, which iterates over `collection` using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} accumulator The initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the accumulated value. + */ + function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initAccum + ? (initAccum = false, value) + : iteratee(accumulator, value, index, collection); + }); + return accumulator; + } + + /** + * The base implementation of `_.sortBy` which uses `comparer` to define the + * sort order of `array` and replaces criteria objects with their corresponding + * values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ + function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + + /** + * The base implementation of `_.sum` and `_.sumBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the sum. + */ + function baseSum(array, iteratee) { + var result, + index = -1, + length = array.length; + + while (++index < length) { + var current = iteratee(array[index]); + if (current !== undefined) { + result = result === undefined ? current : (result + current); + } + } + return result; + } + + /** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ + function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; + } + + /** + * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array + * of key-value pairs for `object` corresponding to the property names of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the key-value pairs. + */ + function baseToPairs(object, props) { + return arrayMap(props, function(key) { + return [key, object[key]]; + }); + } + + /** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ + function baseTrim(string) { + return string + ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; + } + + /** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ + function baseUnary(func) { + return function(value) { + return func(value); + }; + } + + /** + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. + */ + function baseValues(object, props) { + return arrayMap(props, function(key) { + return object[key]; + }); + } + + /** + * Checks if a `cache` value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function cacheHas(cache, key) { + return cache.has(key); + } + + /** + * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the first unmatched string symbol. + */ + function charsStartIndex(strSymbols, chrSymbols) { + var index = -1, + length = strSymbols.length; + + while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; + } + + /** + * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the last unmatched string symbol. + */ + function charsEndIndex(strSymbols, chrSymbols) { + var index = strSymbols.length; + + while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; + } + + /** + * Gets the number of `placeholder` occurrences in `array`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} placeholder The placeholder to search for. + * @returns {number} Returns the placeholder count. + */ + function countHolders(array, placeholder) { + var length = array.length, + result = 0; + + while (length--) { + if (array[length] === placeholder) { + ++result; + } + } + return result; + } + + /** + * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A + * letters to basic Latin letters. + * + * @private + * @param {string} letter The matched letter to deburr. + * @returns {string} Returns the deburred letter. + */ + var deburrLetter = basePropertyOf(deburredLetters); + + /** + * Used by `_.escape` to convert characters to HTML entities. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + var escapeHtmlChar = basePropertyOf(htmlEscapes); + + /** + * Used by `_.template` to escape characters for inclusion in compiled string literals. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + function escapeStringChar(chr) { + return '\\' + stringEscapes[chr]; + } + + /** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function getValue(object, key) { + return object == null ? undefined : object[key]; + } + + /** + * Checks if `string` contains Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a symbol is found, else `false`. + */ + function hasUnicode(string) { + return reHasUnicode.test(string); + } + + /** + * Checks if `string` contains a word composed of Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a word is found, else `false`. + */ + function hasUnicodeWord(string) { + return reHasUnicodeWord.test(string); + } + + /** + * Converts `iterator` to an array. + * + * @private + * @param {Object} iterator The iterator to convert. + * @returns {Array} Returns the converted array. + */ + function iteratorToArray(iterator) { + var data, + result = []; + + while (!(data = iterator.next()).done) { + result.push(data.value); + } + return result; + } + + /** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ + function mapToArray(map) { + var index = -1, + result = Array(map.size); + + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; + } + + /** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ + function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; + } + + /** + * Replaces all `placeholder` elements in `array` with an internal placeholder + * and returns an array of their indexes. + * + * @private + * @param {Array} array The array to modify. + * @param {*} placeholder The placeholder to replace. + * @returns {Array} Returns the new array of placeholder indexes. + */ + function replaceHolders(array, placeholder) { + var index = -1, + length = array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (value === placeholder || value === PLACEHOLDER) { + array[index] = PLACEHOLDER; + result[resIndex++] = index; + } + } + return result; + } + + /** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ + function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; + } + + /** + * Converts `set` to its value-value pairs. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the value-value pairs. + */ + function setToPairs(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = [value, value]; + }); + return result; + } + + /** + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; + } + + /** + * A specialized version of `_.lastIndexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function strictLastIndexOf(array, value, fromIndex) { + var index = fromIndex + 1; + while (index--) { + if (array[index] === value) { + return index; + } + } + return index; + } + + /** + * Gets the number of symbols in `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the string size. + */ + function stringSize(string) { + return hasUnicode(string) + ? unicodeSize(string) + : asciiSize(string); + } + + /** + * Converts `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function stringToArray(string) { + return hasUnicode(string) + ? unicodeToArray(string) + : asciiToArray(string); + } + + /** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ + function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; + } + + /** + * Used by `_.unescape` to convert HTML entities to characters. + * + * @private + * @param {string} chr The matched character to unescape. + * @returns {string} Returns the unescaped character. + */ + var unescapeHtmlChar = basePropertyOf(htmlUnescapes); + + /** + * Gets the size of a Unicode `string`. + * + * @private + * @param {string} string The string inspect. + * @returns {number} Returns the string size. + */ + function unicodeSize(string) { + var result = reUnicode.lastIndex = 0; + while (reUnicode.test(string)) { + ++result; + } + return result; + } + + /** + * Converts a Unicode `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function unicodeToArray(string) { + return string.match(reUnicode) || []; + } + + /** + * Splits a Unicode `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ + function unicodeWords(string) { + return string.match(reUnicodeWord) || []; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Create a new pristine `lodash` function using the `context` object. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Util + * @param {Object} [context=root] The context object. + * @returns {Function} Returns a new `lodash` function. + * @example + * + * _.mixin({ 'foo': _.constant('foo') }); + * + * var lodash = _.runInContext(); + * lodash.mixin({ 'bar': lodash.constant('bar') }); + * + * _.isFunction(_.foo); + * // => true + * _.isFunction(_.bar); + * // => false + * + * lodash.isFunction(lodash.foo); + * // => false + * lodash.isFunction(lodash.bar); + * // => true + * + * // Create a suped-up `defer` in Node.js. + * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; + */ + var runInContext = (function runInContext(context) { + context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); + + /** Built-in constructor references. */ + var Array = context.Array, + Date = context.Date, + Error = context.Error, + Function = context.Function, + Math = context.Math, + Object = context.Object, + RegExp = context.RegExp, + String = context.String, + TypeError = context.TypeError; + + /** Used for built-in method references. */ + var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype; + + /** Used to detect overreaching core-js shims. */ + var coreJsData = context['__core-js_shared__']; + + /** Used to resolve the decompiled source of functions. */ + var funcToString = funcProto.toString; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + + /** Used to generate unique IDs. */ + var idCounter = 0; + + /** Used to detect methods masquerading as native. */ + var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; + }()); + + /** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ + var nativeObjectToString = objectProto.toString; + + /** Used to infer the `Object` constructor. */ + var objectCtorString = funcToString.call(Object); + + /** Used to restore the original `_` reference in `_.noConflict`. */ + var oldDash = root._; + + /** Used to detect if a method is native. */ + var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + ); + + /** Built-in value references. */ + var Buffer = moduleExports ? context.Buffer : undefined, + Symbol = context.Symbol, + Uint8Array = context.Uint8Array, + allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, + getPrototype = overArg(Object.getPrototypeOf, Object), + objectCreate = Object.create, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + splice = arrayProto.splice, + spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, + symIterator = Symbol ? Symbol.iterator : undefined, + symToStringTag = Symbol ? Symbol.toStringTag : undefined; + + var defineProperty = (function() { + try { + var func = getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} + }()); + + /** Mocked built-ins. */ + var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, + ctxNow = Date && Date.now !== root.Date.now && Date.now, + ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; + + /* Built-in method references for those with the same name as other `lodash` methods. */ + var nativeCeil = Math.ceil, + nativeFloor = Math.floor, + nativeGetSymbols = Object.getOwnPropertySymbols, + nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, + nativeIsFinite = context.isFinite, + nativeJoin = arrayProto.join, + nativeKeys = overArg(Object.keys, Object), + nativeMax = Math.max, + nativeMin = Math.min, + nativeNow = Date.now, + nativeParseInt = context.parseInt, + nativeRandom = Math.random, + nativeReverse = arrayProto.reverse; + + /* Built-in method references that are verified to be native. */ + var DataView = getNative(context, 'DataView'), + Map = getNative(context, 'Map'), + Promise = getNative(context, 'Promise'), + Set = getNative(context, 'Set'), + WeakMap = getNative(context, 'WeakMap'), + nativeCreate = getNative(Object, 'create'); + + /** Used to store function metadata. */ + var metaMap = WeakMap && new WeakMap; + + /** Used to lookup unminified function names. */ + var realNames = {}; + + /** Used to detect maps, sets, and weakmaps. */ + var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map), + promiseCtorString = toSource(Promise), + setCtorString = toSource(Set), + weakMapCtorString = toSource(WeakMap); + + /** Used to convert symbols to primitives and strings. */ + var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a `lodash` object which wraps `value` to enable implicit method + * chain sequences. Methods that operate on and return arrays, collections, + * and functions can be chained together. Methods that retrieve a single value + * or may return a primitive value will automatically end the chain sequence + * and return the unwrapped value. Otherwise, the value must be unwrapped + * with `_#value`. + * + * Explicit chain sequences, which must be unwrapped with `_#value`, may be + * enabled using `_.chain`. + * + * The execution of chained methods is lazy, that is, it's deferred until + * `_#value` is implicitly or explicitly called. + * + * Lazy evaluation allows several methods to support shortcut fusion. + * Shortcut fusion is an optimization to merge iteratee calls; this avoids + * the creation of intermediate arrays and can greatly reduce the number of + * iteratee executions. Sections of a chain sequence qualify for shortcut + * fusion if the section is applied to an array and iteratees accept only + * one argument. The heuristic for whether a section qualifies for shortcut + * fusion is subject to change. + * + * Chaining is supported in custom builds as long as the `_#value` method is + * directly or indirectly included in the build. + * + * In addition to lodash methods, wrappers have `Array` and `String` methods. + * + * The wrapper `Array` methods are: + * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` + * + * The wrapper `String` methods are: + * `replace` and `split` + * + * The wrapper methods that support shortcut fusion are: + * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, + * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, + * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` + * + * The chainable wrapper methods are: + * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, + * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, + * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, + * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, + * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, + * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, + * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, + * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, + * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, + * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, + * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, + * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, + * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, + * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, + * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, + * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, + * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, + * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, + * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, + * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, + * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, + * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, + * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, + * `zipObject`, `zipObjectDeep`, and `zipWith` + * + * The wrapper methods that are **not** chainable by default are: + * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, + * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, + * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, + * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, + * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, + * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, + * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, + * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, + * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, + * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, + * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, + * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, + * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, + * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, + * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, + * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, + * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, + * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, + * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, + * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, + * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, + * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, + * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, + * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, + * `upperFirst`, `value`, and `words` + * + * @name _ + * @constructor + * @category Seq + * @param {*} value The value to wrap in a `lodash` instance. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var wrapped = _([1, 2, 3]); + * + * // Returns an unwrapped value. + * wrapped.reduce(_.add); + * // => 6 + * + * // Returns a wrapped value. + * var squares = wrapped.map(square); + * + * _.isArray(squares); + * // => false + * + * _.isArray(squares.value()); + * // => true + */ + function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, '__wrapped__')) { + return wrapperClone(value); } - return errors.length > 0 ? exports.failures(errors) : exports.success(as); - }, useIdentity(codecs) ? exports.identity : function (a) { return codecs.map(function (type, i) { return type.encode(a[i]); }); }, codecs); -} -exports.tuple = tuple; -/** - * @since 1.0.0 - */ -var ReadonlyType = /** @class */ (function (_super) { - __extends(ReadonlyType, _super); - function ReadonlyType(name, is, validate, encode, type) { - var _this = _super.call(this, name, is, validate, encode) || this; - _this.type = type; - /** - * @since 1.0.0 - */ - _this._tag = 'ReadonlyType'; - return _this; - } - return ReadonlyType; -}(Type)); -exports.ReadonlyType = ReadonlyType; -/** - * @category combinators - * @since 1.0.0 - */ -function readonly(codec, name) { - if (name === void 0) { name = "Readonly<" + codec.name + ">"; } - return new ReadonlyType(name, codec.is, codec.validate, codec.encode, codec); -} -exports.readonly = readonly; -/** - * @since 1.0.0 - */ -var ReadonlyArrayType = /** @class */ (function (_super) { - __extends(ReadonlyArrayType, _super); - function ReadonlyArrayType(name, is, validate, encode, type) { - var _this = _super.call(this, name, is, validate, encode) || this; - _this.type = type; - /** - * @since 1.0.0 - */ - _this._tag = 'ReadonlyArrayType'; - return _this; - } - return ReadonlyArrayType; -}(Type)); -exports.ReadonlyArrayType = ReadonlyArrayType; -/** - * @category combinators - * @since 1.0.0 - */ -function readonlyArray(item, name) { - if (name === void 0) { name = "ReadonlyArray<" + item.name + ">"; } - var codec = array(item); - return new ReadonlyArrayType(name, codec.is, codec.validate, codec.encode, item); -} -exports.readonlyArray = readonlyArray; -/** - * Strips additional properties, equivalent to `exact(type(props))`. - * - * @category combinators - * @since 1.0.0 - */ -var strict = function (props, name) { return exact(type(props), name); }; -exports.strict = strict; -/** - * @since 1.1.0 - */ -var ExactType = /** @class */ (function (_super) { - __extends(ExactType, _super); - function ExactType(name, is, validate, encode, type) { - var _this = _super.call(this, name, is, validate, encode) || this; - _this.type = type; - /** - * @since 1.0.0 - */ - _this._tag = 'ExactType'; - return _this; + } + return new LodashWrapper(value); } - return ExactType; -}(Type)); -exports.ExactType = ExactType; -/** - * Strips additional properties. - * - * @category combinators - * @since 1.1.0 - */ -function exact(codec, name) { - if (name === void 0) { name = getExactTypeName(codec); } - var props = getProps(codec); - return new ExactType(name, codec.is, function (u, c) { - var e = exports.UnknownRecord.validate(u, c); - if (Either_1.isLeft(e)) { - return e; + + /** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} proto The object to inherit from. + * @returns {Object} Returns the new object. + */ + var baseCreate = (function() { + function object() {} + return function(proto) { + if (!isObject(proto)) { + return {}; } - var ce = codec.validate(u, c); - if (Either_1.isLeft(ce)) { - return ce; + if (objectCreate) { + return objectCreate(proto); } - return Either_1.right(stripKeys(ce.right, props)); - }, function (a) { return codec.encode(stripKeys(a, props)); }, codec); -} -exports.exact = exact; -// ------------------------------------------------------------------------------------- -// deprecated -// ------------------------------------------------------------------------------------- -/** - * @since 1.0.0 - * @deprecated - */ -var FunctionType = /** @class */ (function (_super) { - __extends(FunctionType, _super); - function FunctionType() { - var _this = _super.call(this, 'Function', - // tslint:disable-next-line:strict-type-predicates - function (u) { return typeof u === 'function'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; + object.prototype = proto; + var result = new object; + object.prototype = undefined; + return result; + }; + }()); + + /** + * The function whose prototype chain sequence wrappers inherit from. + * + * @private + */ + function baseLodash() { + // No operation performed. + } + + /** + * The base constructor for creating `lodash` wrapper objects. + * + * @private + * @param {*} value The value to wrap. + * @param {boolean} [chainAll] Enable explicit method chain sequences. + */ + function LodashWrapper(value, chainAll) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__chain__ = !!chainAll; + this.__index__ = 0; + this.__values__ = undefined; + } + + /** + * By default, the template delimiters used by lodash are like those in + * embedded Ruby (ERB) as well as ES2015 template strings. Change the + * following template settings to use alternative delimiters. + * + * @static + * @memberOf _ + * @type {Object} + */ + lodash.templateSettings = { + + /** + * Used to detect `data` property values to be HTML-escaped. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'escape': reEscape, + + /** + * Used to detect code to be evaluated. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'evaluate': reEvaluate, + + /** + * Used to detect `data` property values to inject. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'interpolate': reInterpolate, + + /** + * Used to reference the data object in the template text. + * + * @memberOf _.templateSettings + * @type {string} + */ + 'variable': '', + + /** + * Used to import variables into the compiled template. + * + * @memberOf _.templateSettings + * @type {Object} + */ + 'imports': { + /** - * @since 1.0.0 + * A reference to the `lodash` function. + * + * @memberOf _.templateSettings.imports + * @type {Function} */ - _this._tag = 'FunctionType'; - return _this; - } - return FunctionType; -}(Type)); -exports.FunctionType = FunctionType; -/** - * @category primitives - * @since 1.0.0 - * @deprecated - */ -// tslint:disable-next-line: deprecation -exports.Function = new FunctionType(); -/** - * @since 1.3.0 - * @deprecated - */ -var TaggedUnionType = /** @class */ (function (_super) { - __extends(TaggedUnionType, _super); - function TaggedUnionType(name, - // tslint:disable-next-line: deprecation - is, - // tslint:disable-next-line: deprecation - validate, - // tslint:disable-next-line: deprecation - encode, codecs, tag) { - var _this = _super.call(this, name, is, validate, encode, codecs) /* istanbul ignore next */ // <= workaround for https://github.com/Microsoft/TypeScript/issues/13455 - || this; - _this.tag = tag; - return _this; + '_': lodash + } + }; + + // Ensure wrappers are instances of `baseLodash`. + lodash.prototype = baseLodash.prototype; + lodash.prototype.constructor = lodash; + + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. + * + * @private + * @constructor + * @param {*} value The value to wrap. + */ + function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = MAX_ARRAY_LENGTH; + this.__views__ = []; } - return TaggedUnionType; -}(UnionType)); -exports.TaggedUnionType = TaggedUnionType; -/** - * Use `union` instead. - * - * @category combinators - * @since 1.3.0 - * @deprecated - */ -var taggedUnion = function (tag, codecs, name -// tslint:disable-next-line: deprecation -) { - if (name === void 0) { name = getUnionName(codecs); } - var U = union(codecs, name); - // tslint:disable-next-line: deprecation - if (U instanceof TaggedUnionType) { - return U; + + /** + * Creates a clone of the lazy wrapper object. + * + * @private + * @name clone + * @memberOf LazyWrapper + * @returns {Object} Returns the cloned `LazyWrapper` object. + */ + function lazyClone() { + var result = new LazyWrapper(this.__wrapped__); + result.__actions__ = copyArray(this.__actions__); + result.__dir__ = this.__dir__; + result.__filtered__ = this.__filtered__; + result.__iteratees__ = copyArray(this.__iteratees__); + result.__takeCount__ = this.__takeCount__; + result.__views__ = copyArray(this.__views__); + return result; } - else { - console.warn("[io-ts] Cannot build a tagged union for " + name + ", returning a de-optimized union"); - // tslint:disable-next-line: deprecation - return new TaggedUnionType(name, U.is, U.validate, U.encode, codecs, tag); + + /** + * Reverses the direction of lazy iteration. + * + * @private + * @name reverse + * @memberOf LazyWrapper + * @returns {Object} Returns the new reversed `LazyWrapper` object. + */ + function lazyReverse() { + if (this.__filtered__) { + var result = new LazyWrapper(this); + result.__dir__ = -1; + result.__filtered__ = true; + } else { + result = this.clone(); + result.__dir__ *= -1; + } + return result; } -}; -exports.taggedUnion = taggedUnion; -/** - * @since 1.0.0 - * @deprecated - */ -var getValidationError /* istanbul ignore next */ = function (value, context) { return ({ - value: value, - context: context -}); }; -exports.getValidationError /* istanbul ignore next */ = getValidationError; -/** - * @since 1.0.0 - * @deprecated - */ -var getDefaultContext /* istanbul ignore next */ = function (decoder) { return [ - { key: '', type: decoder } -]; }; -exports.getDefaultContext /* istanbul ignore next */ = getDefaultContext; -/** - * @since 1.0.0 - * @deprecated - */ -var NeverType = /** @class */ (function (_super) { - __extends(NeverType, _super); - function NeverType() { - var _this = _super.call(this, 'never', function (_) { return false; }, function (u, c) { return exports.failure(u, c); }, - /* istanbul ignore next */ - function () { - throw new Error('cannot encode never'); - }) || this; - /** - * @since 1.0.0 - */ - _this._tag = 'NeverType'; - return _this; + + /** + * Extracts the unwrapped value from its lazy wrapper. + * + * @private + * @name value + * @memberOf LazyWrapper + * @returns {*} Returns the unwrapped value. + */ + function lazyValue() { + var array = this.__wrapped__.value(), + dir = this.__dir__, + isArr = isArray(array), + isRight = dir < 0, + arrLength = isArr ? array.length : 0, + view = getView(0, arrLength, this.__views__), + start = view.start, + end = view.end, + length = end - start, + index = isRight ? end : (start - 1), + iteratees = this.__iteratees__, + iterLength = iteratees.length, + resIndex = 0, + takeCount = nativeMin(length, this.__takeCount__); + + if (!isArr || (!isRight && arrLength == length && takeCount == length)) { + return baseWrapperValue(array, this.__actions__); + } + var result = []; + + outer: + while (length-- && resIndex < takeCount) { + index += dir; + + var iterIndex = -1, + value = array[index]; + + while (++iterIndex < iterLength) { + var data = iteratees[iterIndex], + iteratee = data.iteratee, + type = data.type, + computed = iteratee(value); + + if (type == LAZY_MAP_FLAG) { + value = computed; + } else if (!computed) { + if (type == LAZY_FILTER_FLAG) { + continue outer; + } else { + break outer; + } + } + } + result[resIndex++] = value; + } + return result; } - return NeverType; -}(Type)); -exports.NeverType = NeverType; -/** - * @category primitives - * @since 1.0.0 - * @deprecated - */ -// tslint:disable-next-line: deprecation -exports.never = new NeverType(); -/** - * @since 1.0.0 - * @deprecated - */ -var AnyType = /** @class */ (function (_super) { - __extends(AnyType, _super); - function AnyType() { - var _this = _super.call(this, 'any', function (_) { return true; }, exports.success, exports.identity) || this; - /** - * @since 1.0.0 - */ - _this._tag = 'AnyType'; - return _this; + + // Ensure `LazyWrapper` is an instance of `baseLodash`. + LazyWrapper.prototype = baseCreate(baseLodash.prototype); + LazyWrapper.prototype.constructor = LazyWrapper; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } } - return AnyType; -}(Type)); -exports.AnyType = AnyType; -/** - * Use `unknown` instead. - * - * @category primitives - * @since 1.0.0 - * @deprecated - */ -// tslint:disable-next-line: deprecation -exports.any = new AnyType(); -/** - * Use `UnknownRecord` instead. - * - * @category primitives - * @since 1.0.0 - * @deprecated - */ -exports.Dictionary = exports.UnknownRecord; -/** - * @since 1.0.0 - * @deprecated - */ -var ObjectType = /** @class */ (function (_super) { - __extends(ObjectType, _super); - function ObjectType() { - var _this = _super.call(this, 'object', function (u) { return u !== null && typeof u === 'object'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this; - /** - * @since 1.0.0 - */ - _this._tag = 'ObjectType'; - return _this; + + /** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ + function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; } - return ObjectType; -}(Type)); -exports.ObjectType = ObjectType; -/** - * Use `UnknownRecord` instead. - * - * @category primitives - * @since 1.0.0 - * @deprecated - */ -// tslint:disable-next-line: deprecation -exports.object = new ObjectType(); -/** - * Use `brand` instead. - * - * @category combinators - * @since 1.0.0 - * @deprecated - */ -function refinement(codec, predicate, name) { - if (name === void 0) { name = "(" + codec.name + " | " + getFunctionName(predicate) + ")"; } - return new RefinementType(name, function (u) { return codec.is(u) && predicate(u); }, function (i, c) { - var e = codec.validate(i, c); - if (Either_1.isLeft(e)) { - return e; - } - var a = e.right; - return predicate(a) ? exports.success(a) : exports.failure(a, c); - }, codec.encode, codec, predicate); -} -exports.refinement = refinement; -/** - * Use `Int` instead. - * - * @category primitives - * @since 1.0.0 - * @deprecated - */ -// tslint:disable-next-line: deprecation -exports.Integer = refinement(exports.number, Number.isInteger, 'Integer'); -/** - * Use `record` instead. - * - * @category combinators - * @since 1.0.0 - * @deprecated - */ -exports.dictionary = record; -/** - * @since 1.0.0 - * @deprecated - */ -var StrictType = /** @class */ (function (_super) { - __extends(StrictType, _super); - function StrictType(name, - // tslint:disable-next-line: deprecation - is, - // tslint:disable-next-line: deprecation - validate, - // tslint:disable-next-line: deprecation - encode, props) { - var _this = _super.call(this, name, is, validate, encode) || this; - _this.props = props; - /** - * @since 1.0.0 - */ - _this._tag = 'StrictType'; - return _this; + + /** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; } - return StrictType; -}(Type)); -exports.StrictType = StrictType; -/** - * Drops the codec "kind". - * - * @category combinators - * @since 1.1.0 - * @deprecated - */ -function clean(codec) { - return codec; -} -exports.clean = clean; -function alias(codec) { - return function () { return codec; }; -} -exports.alias = alias; + /** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty.call(data, key) ? data[key] : undefined; + } -/***/ }), + /** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); + } -/***/ 1917: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ + function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; + } -"use strict"; + // Add methods to `Hash`. + Hash.prototype.clear = hashClear; + Hash.prototype['delete'] = hashDelete; + Hash.prototype.get = hashGet; + Hash.prototype.has = hashHas; + Hash.prototype.set = hashSet; + /*------------------------------------------------------------------------*/ + /** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; -var loader = __nccwpck_require__(1161); -var dumper = __nccwpck_require__(8866); + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + /** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ + function listCacheClear() { + this.__data__ = []; + this.size = 0; + } -function renamed(from, to) { - return function () { - throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + - 'Use yaml.' + to + ' instead, which is now safe by default.'); - }; -} + /** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; + } -module.exports.Type = __nccwpck_require__(6073); -module.exports.Schema = __nccwpck_require__(1082); -module.exports.FAILSAFE_SCHEMA = __nccwpck_require__(8562); -module.exports.JSON_SCHEMA = __nccwpck_require__(1035); -module.exports.CORE_SCHEMA = __nccwpck_require__(2011); -module.exports.DEFAULT_SCHEMA = __nccwpck_require__(8759); -module.exports.load = loader.load; -module.exports.loadAll = loader.loadAll; -module.exports.dump = dumper.dump; -module.exports.YAMLException = __nccwpck_require__(8179); + /** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); -// Re-export all types in case user wants to create custom schema -module.exports.types = { - binary: __nccwpck_require__(7900), - float: __nccwpck_require__(2705), - map: __nccwpck_require__(6150), - null: __nccwpck_require__(721), - pairs: __nccwpck_require__(6860), - set: __nccwpck_require__(9548), - timestamp: __nccwpck_require__(9212), - bool: __nccwpck_require__(4993), - int: __nccwpck_require__(1615), - merge: __nccwpck_require__(6104), - omap: __nccwpck_require__(9046), - seq: __nccwpck_require__(7283), - str: __nccwpck_require__(3619) -}; + return index < 0 ? undefined : data[index][1]; + } -// Removed functions from JS-YAML 3.0.x -module.exports.safeLoad = renamed('safeLoad', 'load'); -module.exports.safeLoadAll = renamed('safeLoadAll', 'loadAll'); -module.exports.safeDump = renamed('safeDump', 'dump'); + /** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; + } + /** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ + function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); -/***/ }), + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; + } -/***/ 6829: -/***/ ((module) => { + // Add methods to `ListCache`. + ListCache.prototype.clear = listCacheClear; + ListCache.prototype['delete'] = listCacheDelete; + ListCache.prototype.get = listCacheGet; + ListCache.prototype.has = listCacheHas; + ListCache.prototype.set = listCacheSet; -"use strict"; + /*------------------------------------------------------------------------*/ + /** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } -function isNothing(subject) { - return (typeof subject === 'undefined') || (subject === null); -} + /** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ + function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; + } + /** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; + } -function isObject(subject) { - return (typeof subject === 'object') && (subject !== null); -} + /** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function mapCacheGet(key) { + return getMapData(this, key).get(key); + } + /** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function mapCacheHas(key) { + return getMapData(this, key).has(key); + } -function toArray(sequence) { - if (Array.isArray(sequence)) return sequence; - else if (isNothing(sequence)) return []; + /** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ + function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; - return [ sequence ]; -} + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; + } + // Add methods to `MapCache`. + MapCache.prototype.clear = mapCacheClear; + MapCache.prototype['delete'] = mapCacheDelete; + MapCache.prototype.get = mapCacheGet; + MapCache.prototype.has = mapCacheHas; + MapCache.prototype.set = mapCacheSet; -function extend(target, source) { - var index, length, key, sourceKeys; + /*------------------------------------------------------------------------*/ - if (source) { - sourceKeys = Object.keys(source); + /** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ + function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; - for (index = 0, length = sourceKeys.length; index < length; index += 1) { - key = sourceKeys[index]; - target[key] = source[key]; + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); + } } - } - return target; -} + /** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ + function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; + } + /** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ + function setCacheHas(value) { + return this.__data__.has(value); + } -function repeat(string, count) { - var result = '', cycle; + // Add methods to `SetCache`. + SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; + SetCache.prototype.has = setCacheHas; - for (cycle = 0; cycle < count; cycle += 1) { - result += string; - } + /*------------------------------------------------------------------------*/ - return result; -} + /** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; + } + /** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ + function stackClear() { + this.__data__ = new ListCache; + this.size = 0; + } -function isNegativeZero(number) { - return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); -} + /** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + this.size = data.size; + return result; + } -module.exports.isNothing = isNothing; -module.exports.isObject = isObject; -module.exports.toArray = toArray; -module.exports.repeat = repeat; -module.exports.isNegativeZero = isNegativeZero; -module.exports.extend = extend; + /** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function stackGet(key) { + return this.__data__.get(key); + } + /** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function stackHas(key) { + return this.__data__.has(key); + } -/***/ }), + /** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ + function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; + } -/***/ 8866: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + // Add methods to `Stack`. + Stack.prototype.clear = stackClear; + Stack.prototype['delete'] = stackDelete; + Stack.prototype.get = stackGet; + Stack.prototype.has = stackHas; + Stack.prototype.set = stackSet; -"use strict"; + /*------------------------------------------------------------------------*/ + /** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ + function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; -/*eslint-disable no-use-before-define*/ + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; + } -var common = __nccwpck_require__(6829); -var YAMLException = __nccwpck_require__(8179); -var DEFAULT_SCHEMA = __nccwpck_require__(8759); + /** + * A specialized version of `_.sample` for arrays. + * + * @private + * @param {Array} array The array to sample. + * @returns {*} Returns the random element. + */ + function arraySample(array) { + var length = array.length; + return length ? array[baseRandom(0, length - 1)] : undefined; + } -var _toString = Object.prototype.toString; -var _hasOwnProperty = Object.prototype.hasOwnProperty; + /** + * A specialized version of `_.sampleSize` for arrays. + * + * @private + * @param {Array} array The array to sample. + * @param {number} n The number of elements to sample. + * @returns {Array} Returns the random elements. + */ + function arraySampleSize(array, n) { + return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); + } -var CHAR_BOM = 0xFEFF; -var CHAR_TAB = 0x09; /* Tab */ -var CHAR_LINE_FEED = 0x0A; /* LF */ -var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ -var CHAR_SPACE = 0x20; /* Space */ -var CHAR_EXCLAMATION = 0x21; /* ! */ -var CHAR_DOUBLE_QUOTE = 0x22; /* " */ -var CHAR_SHARP = 0x23; /* # */ -var CHAR_PERCENT = 0x25; /* % */ -var CHAR_AMPERSAND = 0x26; /* & */ -var CHAR_SINGLE_QUOTE = 0x27; /* ' */ -var CHAR_ASTERISK = 0x2A; /* * */ -var CHAR_COMMA = 0x2C; /* , */ -var CHAR_MINUS = 0x2D; /* - */ -var CHAR_COLON = 0x3A; /* : */ -var CHAR_EQUALS = 0x3D; /* = */ -var CHAR_GREATER_THAN = 0x3E; /* > */ -var CHAR_QUESTION = 0x3F; /* ? */ -var CHAR_COMMERCIAL_AT = 0x40; /* @ */ -var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ -var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ -var CHAR_GRAVE_ACCENT = 0x60; /* ` */ -var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ -var CHAR_VERTICAL_LINE = 0x7C; /* | */ -var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ + /** + * A specialized version of `_.shuffle` for arrays. + * + * @private + * @param {Array} array The array to shuffle. + * @returns {Array} Returns the new shuffled array. + */ + function arrayShuffle(array) { + return shuffleSelf(copyArray(array)); + } -var ESCAPE_SEQUENCES = {}; + /** + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq(object[key], value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } + } -ESCAPE_SEQUENCES[0x00] = '\\0'; -ESCAPE_SEQUENCES[0x07] = '\\a'; -ESCAPE_SEQUENCES[0x08] = '\\b'; -ESCAPE_SEQUENCES[0x09] = '\\t'; -ESCAPE_SEQUENCES[0x0A] = '\\n'; -ESCAPE_SEQUENCES[0x0B] = '\\v'; -ESCAPE_SEQUENCES[0x0C] = '\\f'; -ESCAPE_SEQUENCES[0x0D] = '\\r'; -ESCAPE_SEQUENCES[0x1B] = '\\e'; -ESCAPE_SEQUENCES[0x22] = '\\"'; -ESCAPE_SEQUENCES[0x5C] = '\\\\'; -ESCAPE_SEQUENCES[0x85] = '\\N'; -ESCAPE_SEQUENCES[0xA0] = '\\_'; -ESCAPE_SEQUENCES[0x2028] = '\\L'; -ESCAPE_SEQUENCES[0x2029] = '\\P'; + /** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } + } -var DEPRECATED_BOOLEANS_SYNTAX = [ - 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', - 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' -]; + /** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; + } -var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; + /** + * Aggregates elements of `collection` on `accumulator` with keys transformed + * by `iteratee` and values set by `setter`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. + */ + function baseAggregator(collection, setter, iteratee, accumulator) { + baseEach(collection, function(value, key, collection) { + setter(accumulator, value, iteratee(value), collection); + }); + return accumulator; + } -function compileStyleMap(schema, map) { - var result, keys, index, length, tag, style, type; + /** + * The base implementation of `_.assign` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ + function baseAssign(object, source) { + return object && copyObject(source, keys(source), object); + } - if (map === null) return {}; + /** + * The base implementation of `_.assignIn` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ + function baseAssignIn(object, source) { + return object && copyObject(source, keysIn(source), object); + } - result = {}; - keys = Object.keys(map); + /** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function baseAssignValue(object, key, value) { + if (key == '__proto__' && defineProperty) { + defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } + } - for (index = 0, length = keys.length; index < length; index += 1) { - tag = keys[index]; - style = String(map[tag]); + /** + * The base implementation of `_.at` without support for individual paths. + * + * @private + * @param {Object} object The object to iterate over. + * @param {string[]} paths The property paths to pick. + * @returns {Array} Returns the picked elements. + */ + function baseAt(object, paths) { + var index = -1, + length = paths.length, + result = Array(length), + skip = object == null; - if (tag.slice(0, 2) === '!!') { - tag = 'tag:yaml.org,2002:' + tag.slice(2); + while (++index < length) { + result[index] = skip ? undefined : get(object, paths[index]); + } + return result; } - type = schema.compiledTypeMap['fallback'][tag]; - if (type && _hasOwnProperty.call(type.styleAliases, style)) { - style = type.styleAliases[style]; + /** + * The base implementation of `_.clamp` which doesn't coerce arguments. + * + * @private + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. + */ + function baseClamp(number, lower, upper) { + if (number === number) { + if (upper !== undefined) { + number = number <= upper ? number : upper; + } + if (lower !== undefined) { + number = number >= lower ? number : lower; + } + } + return number; } - result[tag] = style; - } + /** + * The base implementation of `_.clone` and `_.cloneDeep` which tracks + * traversed objects. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} bitmask The bitmask flags. + * 1 - Deep clone + * 2 - Flatten inherited properties + * 4 - Clone symbols + * @param {Function} [customizer] The function to customize cloning. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. + * @returns {*} Returns the cloned value. + */ + function baseClone(value, bitmask, customizer, key, object, stack) { + var result, + isDeep = bitmask & CLONE_DEEP_FLAG, + isFlat = bitmask & CLONE_FLAT_FLAG, + isFull = bitmask & CLONE_SYMBOLS_FLAG; + + if (customizer) { + result = object ? customizer(value, key, object, stack) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return copyArray(value, result); + } + } else { + var tag = getTag(value), + isFunc = tag == funcTag || tag == genTag; + + if (isBuffer(value)) { + return cloneBuffer(value, isDeep); + } + if (tag == objectTag || tag == argsTag || (isFunc && !object)) { + result = (isFlat || isFunc) ? {} : initCloneObject(value); + if (!isDeep) { + return isFlat + ? copySymbolsIn(value, baseAssignIn(result, value)) + : copySymbols(value, baseAssign(result, value)); + } + } else { + if (!cloneableTags[tag]) { + return object ? value : {}; + } + result = initCloneByTag(value, tag, isDeep); + } + } + // Check for circular references and return its corresponding clone. + stack || (stack = new Stack); + var stacked = stack.get(value); + if (stacked) { + return stacked; + } + stack.set(value, result); - return result; -} + if (isSet(value)) { + value.forEach(function(subValue) { + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); + }); + } else if (isMap(value)) { + value.forEach(function(subValue, key) { + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + } -function encodeHex(character) { - var string, handle, length; + var keysFunc = isFull + ? (isFlat ? getAllKeysIn : getAllKeys) + : (isFlat ? keysIn : keys); - string = character.toString(16).toUpperCase(); + var props = isArr ? undefined : keysFunc(value); + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } + // Recursively populate clone (susceptible to call stack limits). + assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + return result; + } - if (character <= 0xFF) { - handle = 'x'; - length = 2; - } else if (character <= 0xFFFF) { - handle = 'u'; - length = 4; - } else if (character <= 0xFFFFFFFF) { - handle = 'U'; - length = 8; - } else { - throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); - } + /** + * The base implementation of `_.conforms` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property predicates to conform to. + * @returns {Function} Returns the new spec function. + */ + function baseConforms(source) { + var props = keys(source); + return function(object) { + return baseConformsTo(object, source, props); + }; + } - return '\\' + handle + common.repeat('0', length - string.length) + string; -} + /** + * The base implementation of `_.conformsTo` which accepts `props` to check. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property predicates to conform to. + * @returns {boolean} Returns `true` if `object` conforms, else `false`. + */ + function baseConformsTo(object, source, props) { + var length = props.length; + if (object == null) { + return !length; + } + object = Object(object); + while (length--) { + var key = props[length], + predicate = source[key], + value = object[key]; + if ((value === undefined && !(key in object)) || !predicate(value)) { + return false; + } + } + return true; + } -var QUOTING_TYPE_SINGLE = 1, - QUOTING_TYPE_DOUBLE = 2; + /** + * The base implementation of `_.delay` and `_.defer` which accepts `args` + * to provide to `func`. + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {Array} args The arguments to provide to `func`. + * @returns {number|Object} Returns the timer id or timeout object. + */ + function baseDelay(func, wait, args) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return setTimeout(function() { func.apply(undefined, args); }, wait); + } -function State(options) { - this.schema = options['schema'] || DEFAULT_SCHEMA; - this.indent = Math.max(1, (options['indent'] || 2)); - this.noArrayIndent = options['noArrayIndent'] || false; - this.skipInvalid = options['skipInvalid'] || false; - this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); - this.styleMap = compileStyleMap(this.schema, options['styles'] || null); - this.sortKeys = options['sortKeys'] || false; - this.lineWidth = options['lineWidth'] || 80; - this.noRefs = options['noRefs'] || false; - this.noCompatMode = options['noCompatMode'] || false; - this.condenseFlow = options['condenseFlow'] || false; - this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; - this.forceQuotes = options['forceQuotes'] || false; - this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; + /** + * The base implementation of methods like `_.difference` without support + * for excluding multiple arrays or iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Array} values The values to exclude. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. + */ + function baseDifference(array, values, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + isCommon = true, + length = array.length, + result = [], + valuesLength = values.length; - this.implicitTypes = this.schema.compiledImplicit; - this.explicitTypes = this.schema.compiledExplicit; + if (!length) { + return result; + } + if (iteratee) { + values = arrayMap(values, baseUnary(iteratee)); + } + if (comparator) { + includes = arrayIncludesWith; + isCommon = false; + } + else if (values.length >= LARGE_ARRAY_SIZE) { + includes = cacheHas; + isCommon = false; + values = new SetCache(values); + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee == null ? value : iteratee(value); - this.tag = null; - this.result = ''; + value = (comparator || value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var valuesIndex = valuesLength; + while (valuesIndex--) { + if (values[valuesIndex] === computed) { + continue outer; + } + } + result.push(value); + } + else if (!includes(values, computed, comparator)) { + result.push(value); + } + } + return result; + } - this.duplicates = []; - this.usedDuplicates = null; -} + /** + * The base implementation of `_.forEach` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ + var baseEach = createBaseEach(baseForOwn); -// Indents every line in a string. Empty lines (\n only) are not indented. -function indentString(string, spaces) { - var ind = common.repeat(' ', spaces), - position = 0, - next = -1, - result = '', - line, - length = string.length; + /** + * The base implementation of `_.forEachRight` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ + var baseEachRight = createBaseEach(baseForOwnRight, true); - while (position < length) { - next = string.indexOf('\n', position); - if (next === -1) { - line = string.slice(position); - position = length; - } else { - line = string.slice(position, next + 1); - position = next + 1; + /** + * The base implementation of `_.every` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` + */ + function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function(value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; } - if (line.length && line !== '\n') result += ind; - - result += line; - } - - return result; -} + /** + * The base implementation of methods like `_.max` and `_.min` which accepts a + * `comparator` to determine the extremum value. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The iteratee invoked per iteration. + * @param {Function} comparator The comparator used to compare values. + * @returns {*} Returns the extremum value. + */ + function baseExtremum(array, iteratee, comparator) { + var index = -1, + length = array.length; -function generateNextLine(state, level) { - return '\n' + common.repeat(' ', state.indent * level); -} + while (++index < length) { + var value = array[index], + current = iteratee(value); -function testImplicitResolving(state, str) { - var index, length, type; + if (current != null && (computed === undefined + ? (current === current && !isSymbol(current)) + : comparator(current, computed) + )) { + var computed = current, + result = value; + } + } + return result; + } - for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { - type = state.implicitTypes[index]; + /** + * The base implementation of `_.fill` without an iteratee call guard. + * + * @private + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. + */ + function baseFill(array, value, start, end) { + var length = array.length; - if (type.resolve(str)) { - return true; + start = toInteger(start); + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = (end === undefined || end > length) ? length : toInteger(end); + if (end < 0) { + end += length; + } + end = start > end ? 0 : toLength(end); + while (start < end) { + array[start++] = value; + } + return array; } - } - - return false; -} -// [33] s-white ::= s-space | s-tab -function isWhitespace(c) { - return c === CHAR_SPACE || c === CHAR_TAB; -} + /** + * The base implementation of `_.filter` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ + function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; + } -// Returns true if the character can be printed without escaping. -// From YAML 1.2: "any allowed characters known to be non-printable -// should also be escaped. [However,] This isn’t mandatory" -// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. -function isPrintable(c) { - return (0x00020 <= c && c <= 0x00007E) - || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) - || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) - || (0x10000 <= c && c <= 0x10FFFF); -} + /** + * The base implementation of `_.flatten` with support for restricting flattening. + * + * @private + * @param {Array} array The array to flatten. + * @param {number} depth The maximum recursion depth. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. + * @param {Array} [result=[]] The initial result value. + * @returns {Array} Returns the new flattened array. + */ + function baseFlatten(array, depth, predicate, isStrict, result) { + var index = -1, + length = array.length; -// [34] ns-char ::= nb-char - s-white -// [27] nb-char ::= c-printable - b-char - c-byte-order-mark -// [26] b-char ::= b-line-feed | b-carriage-return -// Including s-white (for some reason, examples doesn't match specs in this aspect) -// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark -function isNsCharOrWhitespace(c) { - return isPrintable(c) - && c !== CHAR_BOM - // - b-char - && c !== CHAR_CARRIAGE_RETURN - && c !== CHAR_LINE_FEED; -} + predicate || (predicate = isFlattenable); + result || (result = []); -// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out -// c = flow-in ⇒ ns-plain-safe-in -// c = block-key ⇒ ns-plain-safe-out -// c = flow-key ⇒ ns-plain-safe-in -// [128] ns-plain-safe-out ::= ns-char -// [129] ns-plain-safe-in ::= ns-char - c-flow-indicator -// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) -// | ( /* An ns-char preceding */ “#” ) -// | ( “:” /* Followed by an ns-plain-safe(c) */ ) -function isPlainSafe(c, prev, inblock) { - var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); - var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); - return ( - // ns-plain-safe - inblock ? // c = flow-in - cIsNsCharOrWhitespace - : cIsNsCharOrWhitespace - // - c-flow-indicator - && c !== CHAR_COMMA - && c !== CHAR_LEFT_SQUARE_BRACKET - && c !== CHAR_RIGHT_SQUARE_BRACKET - && c !== CHAR_LEFT_CURLY_BRACKET - && c !== CHAR_RIGHT_CURLY_BRACKET - ) - // ns-plain-char - && c !== CHAR_SHARP // false on '#' - && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' - || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' - || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' -} + while (++index < length) { + var value = array[index]; + if (depth > 0 && predicate(value)) { + if (depth > 1) { + // Recursively flatten arrays (susceptible to call stack limits). + baseFlatten(value, depth - 1, predicate, isStrict, result); + } else { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; + } -// Simplified test for values allowed as the first character in plain style. -function isPlainSafeFirst(c) { - // Uses a subset of ns-char - c-indicator - // where ns-char = nb-char - s-white. - // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part - return isPrintable(c) && c !== CHAR_BOM - && !isWhitespace(c) // - s-white - // - (c-indicator ::= - // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” - && c !== CHAR_MINUS - && c !== CHAR_QUESTION - && c !== CHAR_COLON - && c !== CHAR_COMMA - && c !== CHAR_LEFT_SQUARE_BRACKET - && c !== CHAR_RIGHT_SQUARE_BRACKET - && c !== CHAR_LEFT_CURLY_BRACKET - && c !== CHAR_RIGHT_CURLY_BRACKET - // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” - && c !== CHAR_SHARP - && c !== CHAR_AMPERSAND - && c !== CHAR_ASTERISK - && c !== CHAR_EXCLAMATION - && c !== CHAR_VERTICAL_LINE - && c !== CHAR_EQUALS - && c !== CHAR_GREATER_THAN - && c !== CHAR_SINGLE_QUOTE - && c !== CHAR_DOUBLE_QUOTE - // | “%” | “@” | “`”) - && c !== CHAR_PERCENT - && c !== CHAR_COMMERCIAL_AT - && c !== CHAR_GRAVE_ACCENT; -} + /** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ + var baseFor = createBaseFor(); -// Simplified test for values allowed as the last character in plain style. -function isPlainSafeLast(c) { - // just not whitespace or colon, it will be checked to be plain character later - return !isWhitespace(c) && c !== CHAR_COLON; -} + /** + * This function is like `baseFor` except that it iterates over properties + * in the opposite order. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ + var baseForRight = createBaseFor(true); -// Same as 'string'.codePointAt(pos), but works in older browsers. -function codePointAt(string, pos) { - var first = string.charCodeAt(pos), second; - if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { - second = string.charCodeAt(pos + 1); - if (second >= 0xDC00 && second <= 0xDFFF) { - // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + /** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); } - } - return first; -} -// Determines whether block indentation indicator is required. -function needIndentIndicator(string) { - var leadingSpaceRe = /^\n* /; - return leadingSpaceRe.test(string); -} + /** + * The base implementation of `_.forOwnRight` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwnRight(object, iteratee) { + return object && baseForRight(object, iteratee, keys); + } -var STYLE_PLAIN = 1, - STYLE_SINGLE = 2, - STYLE_LITERAL = 3, - STYLE_FOLDED = 4, - STYLE_DOUBLE = 5; + /** + * The base implementation of `_.functions` which creates an array of + * `object` function property names filtered from `props`. + * + * @private + * @param {Object} object The object to inspect. + * @param {Array} props The property names to filter. + * @returns {Array} Returns the function names. + */ + function baseFunctions(object, props) { + return arrayFilter(props, function(key) { + return isFunction(object[key]); + }); + } -// Determines which scalar styles are possible and returns the preferred style. -// lineWidth = -1 => no limit. -// Pre-conditions: str.length > 0. -// Post-conditions: -// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. -// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). -// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). -function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, - testAmbiguousType, quotingType, forceQuotes, inblock) { + /** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ + function baseGet(object, path) { + path = castPath(path, object); - var i; - var char = 0; - var prevChar = null; - var hasLineBreak = false; - var hasFoldableLine = false; // only checked if shouldTrackWidth - var shouldTrackWidth = lineWidth !== -1; - var previousLineBreak = -1; // count the first line correctly - var plain = isPlainSafeFirst(codePointAt(string, 0)) - && isPlainSafeLast(codePointAt(string, string.length - 1)); + var index = 0, + length = path.length; - if (singleLineOnly || forceQuotes) { - // Case: no block styles. - // Check for disallowed characters to rule out plain and single. - for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - if (!isPrintable(char)) { - return STYLE_DOUBLE; + while (object != null && index < length) { + object = object[toKey(path[index++])]; } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; + return (index && index == length) ? object : undefined; } - } else { - // Case: block styles permitted. - for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - if (char === CHAR_LINE_FEED) { - hasLineBreak = true; - // Check if any line can be folded. - if (shouldTrackWidth) { - hasFoldableLine = hasFoldableLine || - // Foldable line = too long, and not more-indented. - (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' '); - previousLineBreak = i; - } - } else if (!isPrintable(char)) { - return STYLE_DOUBLE; + + /** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ + function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); + } + + /** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; } - plain = plain && isPlainSafe(char, prevChar, inblock); - prevChar = char; + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); } - // in case the end is missing a \n - hasFoldableLine = hasFoldableLine || (shouldTrackWidth && - (i - previousLineBreak - 1 > lineWidth && - string[previousLineBreak + 1] !== ' ')); - } - // Although every style can represent \n without escaping, prefer block styles - // for multiline, since they're more readable and they don't add empty lines. - // Also prefer folding a super-long line. - if (!hasLineBreak && !hasFoldableLine) { - // Strings interpretable as another type have to be quoted; - // e.g. the string 'true' vs. the boolean true. - if (plain && !forceQuotes && !testAmbiguousType(string)) { - return STYLE_PLAIN; + + /** + * The base implementation of `_.gt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + */ + function baseGt(value, other) { + return value > other; } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; - } - // Edge case: block indentation indicator can only have one digit. - if (indentPerLevel > 9 && needIndentIndicator(string)) { - return STYLE_DOUBLE; - } - // At this point we know block styles are valid. - // Prefer literal style unless we want to fold. - if (!forceQuotes) { - return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; - } - return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; -} -// Note: line breaking/folding is implemented for only the folded style. -// NB. We drop the last trailing newline (if any) of a returned block scalar -// since the dumper adds its own newline. This always works: -// • No ending newline => unaffected; already using strip "-" chomping. -// • Ending newline => removed then restored. -// Importantly, this keeps the "+" chomp indicator from gaining an extra line. -function writeScalar(state, string, level, iskey, inblock) { - state.dump = (function () { - if (string.length === 0) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; + /** + * The base implementation of `_.has` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ + function baseHas(object, key) { + return object != null && hasOwnProperty.call(object, key); } - if (!state.noCompatMode) { - if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { - return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); - } + + /** + * The base implementation of `_.hasIn` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ + function baseHasIn(object, key) { + return object != null && key in Object(object); } - var indent = state.indent * Math.max(1, level); // no 0-indent scalars - // As indentation gets deeper, let the width decrease monotonically - // to the lower bound min(state.lineWidth, 40). - // Note that this implies - // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. - // state.lineWidth > 40 + state.indent: width decreases until the lower bound. - // This behaves better than a constant minimum width which disallows narrower options, - // or an indent threshold which causes the width to suddenly increase. - var lineWidth = state.lineWidth === -1 - ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); + /** + * The base implementation of `_.inRange` which doesn't coerce arguments. + * + * @private + * @param {number} number The number to check. + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. + */ + function baseInRange(number, start, end) { + return number >= nativeMin(start, end) && number < nativeMax(start, end); + } - // Without knowing if keys are implicit/explicit, assume implicit for safety. - var singleLineOnly = iskey - // No block styles in flow mode. - || (state.flowLevel > -1 && level >= state.flowLevel); - function testAmbiguity(string) { - return testImplicitResolving(state, string); + /** + * The base implementation of methods like `_.intersection`, without support + * for iteratee shorthands, that accepts an array of arrays to inspect. + * + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of shared values. + */ + function baseIntersection(arrays, iteratee, comparator) { + var includes = comparator ? arrayIncludesWith : arrayIncludes, + length = arrays[0].length, + othLength = arrays.length, + othIndex = othLength, + caches = Array(othLength), + maxLength = Infinity, + result = []; + + while (othIndex--) { + var array = arrays[othIndex]; + if (othIndex && iteratee) { + array = arrayMap(array, baseUnary(iteratee)); + } + maxLength = nativeMin(array.length, maxLength); + caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) + ? new SetCache(othIndex && array) + : undefined; + } + array = arrays[0]; + + var index = -1, + seen = caches[0]; + + outer: + while (++index < length && result.length < maxLength) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + value = (comparator || value !== 0) ? value : 0; + if (!(seen + ? cacheHas(seen, computed) + : includes(result, computed, comparator) + )) { + othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if (!(cache + ? cacheHas(cache, computed) + : includes(arrays[othIndex], computed, comparator)) + ) { + continue outer; + } + } + if (seen) { + seen.push(computed); + } + result.push(value); + } + } + return result; } - switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, - testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { + /** + * The base implementation of `_.invert` and `_.invertBy` which inverts + * `object` with values transformed by `iteratee` and set by `setter`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform values. + * @param {Object} accumulator The initial inverted object. + * @returns {Function} Returns `accumulator`. + */ + function baseInverter(object, setter, iteratee, accumulator) { + baseForOwn(object, function(value, key, object) { + setter(accumulator, iteratee(value), key, object); + }); + return accumulator; + } - case STYLE_PLAIN: - return string; - case STYLE_SINGLE: - return "'" + string.replace(/'/g, "''") + "'"; - case STYLE_LITERAL: - return '|' + blockHeader(string, state.indent) - + dropEndingNewline(indentString(string, indent)); - case STYLE_FOLDED: - return '>' + blockHeader(string, state.indent) - + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); - case STYLE_DOUBLE: - return '"' + escapeString(string, lineWidth) + '"'; - default: - throw new YAMLException('impossible error: invalid scalar style'); + /** + * The base implementation of `_.invoke` without support for individual + * method arguments. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {Array} args The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + */ + function baseInvoke(object, path, args) { + path = castPath(path, object); + object = parent(object, path); + var func = object == null ? object : object[toKey(last(path))]; + return func == null ? undefined : apply(func, object, args); } - }()); -} -// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. -function blockHeader(string, indentPerLevel) { - var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; + /** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ + function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; + } - // note the special case: the string '\n' counts as a "trailing" empty line. - var clip = string[string.length - 1] === '\n'; - var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); - var chomp = keep ? '+' : (clip ? '' : '-'); + /** + * The base implementation of `_.isArrayBuffer` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. + */ + function baseIsArrayBuffer(value) { + return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; + } - return indentIndicator + chomp + '\n'; -} + /** + * The base implementation of `_.isDate` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a date object, else `false`. + */ + function baseIsDate(value) { + return isObjectLike(value) && baseGetTag(value) == dateTag; + } -// (See the note for writeScalar.) -function dropEndingNewline(string) { - return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; -} + /** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ + function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); + } -// Note: a long line without a suitable break point will exceed the width limit. -// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. -function foldString(string, width) { - // In folded style, $k$ consecutive newlines output as $k+1$ newlines— - // unless they're before or after a more-indented line, or at the very - // beginning or end, in which case $k$ maps to $k$. - // Therefore, parse each chunk as newline(s) followed by a content line. - var lineRe = /(\n+)([^\n]*)/g; + /** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); - // first line (possibly an empty line) - var result = (function () { - var nextLF = string.indexOf('\n'); - nextLF = nextLF !== -1 ? nextLF : string.length; - lineRe.lastIndex = nextLF; - return foldLine(string.slice(0, nextLF), width); - }()); - // If we haven't reached the first content line yet, don't add an extra \n. - var prevMoreIndented = string[0] === '\n' || string[0] === ' '; - var moreIndented; + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; - // rest of the lines - var match; - while ((match = lineRe.exec(string))) { - var prefix = match[1], line = match[2]; - moreIndented = (line[0] === ' '); - result += prefix - + (!prevMoreIndented && !moreIndented && line !== '' - ? '\n' : '') - + foldLine(line, width); - prevMoreIndented = moreIndented; - } + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; - return result; -} + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); -// Greedy line breaking. -// Picks the longest line under the limit each time, -// otherwise settles for the shortest line over the limit. -// NB. More-indented lines *cannot* be folded, as that would add an extra \n. -function foldLine(line, width) { - if (line === '' || line[0] === ' ') return line; + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; - // Since a more-indented line adds a \n, breaks can't be followed by a space. - var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. - var match; - // start is an inclusive index. end, curr, and next are exclusive. - var start = 0, end, curr = 0, next = 0; - var result = ''; + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); + } - // Invariants: 0 <= start <= length-1. - // 0 <= curr <= next <= max(0, length-2). curr - start <= width. - // Inside the loop: - // A match implies length >= 2, so curr and next are <= length-2. - while ((match = breakRe.exec(line))) { - next = match.index; - // maintain invariant: curr - start <= width - if (next - start > width) { - end = (curr > start) ? curr : next; // derive end <= length-2 - result += '\n' + line.slice(start, end); - // skip the space that was output as \n - start = end + 1; // derive start <= length-1 + /** + * The base implementation of `_.isMap` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + */ + function baseIsMap(value) { + return isObjectLike(value) && getTag(value) == mapTag; } - curr = next; - } - // By the invariants, start <= length-1, so there is something left over. - // It is either the whole string or a part starting from non-whitespace. - result += '\n'; - // Insert a break if the remainder is too long and there is a break available. - if (line.length - start > width && curr > start) { - result += line.slice(start, curr) + '\n' + line.slice(curr + 1); - } else { - result += line.slice(start); - } + /** + * The base implementation of `_.isMatch` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ + function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; - return result.slice(1); // drop extra \n joiner -} + if (object == null) { + return !length; + } + object = Object(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; -// Escapes a double-quoted string. -function escapeString(string) { - var result = ''; - var char = 0; - var escapeSeq; + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var stack = new Stack; + if (customizer) { + var result = customizer(objValue, srcValue, key, object, source, stack); + } + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) + : result + )) { + return false; + } + } + } + return true; + } - for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { - char = codePointAt(string, i); - escapeSeq = ESCAPE_SEQUENCES[char]; + /** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ + function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); + } - if (!escapeSeq && isPrintable(char)) { - result += string[i]; - if (char >= 0x10000) result += string[i + 1]; - } else { - result += escapeSeq || encodeHex(char); + /** + * The base implementation of `_.isRegExp` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. + */ + function baseIsRegExp(value) { + return isObjectLike(value) && baseGetTag(value) == regexpTag; } - } - return result; -} + /** + * The base implementation of `_.isSet` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + */ + function baseIsSet(value) { + return isObjectLike(value) && getTag(value) == setTag; + } -function writeFlowSequence(state, level, object) { - var _result = '', - _tag = state.tag, - index, - length, - value; + /** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ + function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; + } - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; + /** + * The base implementation of `_.iteratee`. + * + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ + function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; + } + if (value == null) { + return identity; + } + if (typeof value == 'object') { + return isArray(value) + ? baseMatchesProperty(value[0], value[1]) + : baseMatches(value); + } + return property(value); + } - if (state.replacer) { - value = state.replacer.call(object, String(index), value); + /** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; } - // Write only valid elements, put null instead of invalid elements. - if (writeNode(state, level, value, false, false) || - (typeof value === 'undefined' && - writeNode(state, level, null, false, false))) { + /** + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function baseKeysIn(object) { + if (!isObject(object)) { + return nativeKeysIn(object); + } + var isProto = isPrototype(object), + result = []; - if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); - _result += state.dump; + for (var key in object) { + if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } + } + return result; } - } - - state.tag = _tag; - state.dump = '[' + _result + ']'; -} -function writeBlockSequence(state, level, object, compact) { - var _result = '', - _tag = state.tag, - index, - length, - value; + /** + * The base implementation of `_.lt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + */ + function baseLt(value, other) { + return value < other; + } - for (index = 0, length = object.length; index < length; index += 1) { - value = object[index]; + /** + * The base implementation of `_.map` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; - if (state.replacer) { - value = state.replacer.call(object, String(index), value); + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; } - // Write only valid elements, put null instead of invalid elements. - if (writeNode(state, level + 1, value, true, true, false, true) || - (typeof value === 'undefined' && - writeNode(state, level + 1, null, true, true, false, true))) { - - if (!compact || _result !== '') { - _result += generateNextLine(state, level); + /** + * The base implementation of `_.matches` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new spec function. + */ + function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + return matchesStrictComparable(matchData[0][0], matchData[0][1]); } + return function(object) { + return object === source || baseIsMatch(object, source, matchData); + }; + } - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - _result += '-'; - } else { - _result += '- '; + /** + * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ + function baseMatchesProperty(path, srcValue) { + if (isKey(path) && isStrictComparable(srcValue)) { + return matchesStrictComparable(toKey(path), srcValue); } - - _result += state.dump; + return function(object) { + var objValue = get(object, path); + return (objValue === undefined && objValue === srcValue) + ? hasIn(object, path) + : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); + }; } - } - state.tag = _tag; - state.dump = _result || '[]'; // Empty sequence if no valid values. -} + /** + * The base implementation of `_.merge` without support for multiple sources. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. + * @param {Function} [customizer] The function to customize merged values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ + function baseMerge(object, source, srcIndex, customizer, stack) { + if (object === source) { + return; + } + baseFor(source, function(srcValue, key) { + stack || (stack = new Stack); + if (isObject(srcValue)) { + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + } + else { + var newValue = customizer + ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) + : undefined; -function writeFlowMapping(state, level, object) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - pairBuffer; + if (newValue === undefined) { + newValue = srcValue; + } + assignMergeValue(object, key, newValue); + } + }, keysIn); + } - for (index = 0, length = objectKeyList.length; index < length; index += 1) { + /** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize assigned values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ + function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { + var objValue = safeGet(object, key), + srcValue = safeGet(source, key), + stacked = stack.get(srcValue); - pairBuffer = ''; - if (_result !== '') pairBuffer += ', '; + if (stacked) { + assignMergeValue(object, key, stacked); + return; + } + var newValue = customizer + ? customizer(objValue, srcValue, (key + ''), object, source, stack) + : undefined; - if (state.condenseFlow) pairBuffer += '"'; + var isCommon = newValue === undefined; - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; + if (isCommon) { + var isArr = isArray(srcValue), + isBuff = !isArr && isBuffer(srcValue), + isTyped = !isArr && !isBuff && isTypedArray(srcValue); - if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); + newValue = srcValue; + if (isArr || isBuff || isTyped) { + if (isArray(objValue)) { + newValue = objValue; + } + else if (isArrayLikeObject(objValue)) { + newValue = copyArray(objValue); + } + else if (isBuff) { + isCommon = false; + newValue = cloneBuffer(srcValue, true); + } + else if (isTyped) { + isCommon = false; + newValue = cloneTypedArray(srcValue, true); + } + else { + newValue = []; + } + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { + newValue = objValue; + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } + else if (!isObject(objValue) || isFunction(objValue)) { + newValue = initCloneObject(srcValue); + } + } + else { + isCommon = false; + } + } + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, newValue); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); + stack['delete'](srcValue); + } + assignMergeValue(object, key, newValue); } - if (!writeNode(state, level, objectKey, false, false)) { - continue; // Skip this pair because of invalid key; + /** + * The base implementation of `_.nth` which doesn't coerce arguments. + * + * @private + * @param {Array} array The array to query. + * @param {number} n The index of the element to return. + * @returns {*} Returns the nth element of `array`. + */ + function baseNth(array, n) { + var length = array.length; + if (!length) { + return; + } + n += n < 0 ? length : 0; + return isIndex(n, length) ? array[n] : undefined; } - if (state.dump.length > 1024) pairBuffer += '? '; + /** + * The base implementation of `_.orderBy` without param guards. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {string[]} orders The sort orders of `iteratees`. + * @returns {Array} Returns the new sorted array. + */ + function baseOrderBy(collection, iteratees, orders) { + if (iteratees.length) { + iteratees = arrayMap(iteratees, function(iteratee) { + if (isArray(iteratee)) { + return function(value) { + return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); + } + } + return iteratee; + }); + } else { + iteratees = [identity]; + } - pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); + var index = -1; + iteratees = arrayMap(iteratees, baseUnary(getIteratee())); - if (!writeNode(state, level, objectValue, false, false)) { - continue; // Skip this pair because of invalid value. + var result = baseMap(collection, function(value, key, collection) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { 'criteria': criteria, 'index': ++index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); } - pairBuffer += state.dump; + /** + * The base implementation of `_.pick` without support for individual + * property identifiers. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @returns {Object} Returns the new object. + */ + function basePick(object, paths) { + return basePickBy(object, paths, function(value, path) { + return hasIn(object, path); + }); + } - // Both key and value are valid. - _result += pairBuffer; - } + /** + * The base implementation of `_.pickBy` without support for iteratee shorthands. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @param {Function} predicate The function invoked per property. + * @returns {Object} Returns the new object. + */ + function basePickBy(object, paths, predicate) { + var index = -1, + length = paths.length, + result = {}; - state.tag = _tag; - state.dump = '{' + _result + '}'; -} + while (++index < length) { + var path = paths[index], + value = baseGet(object, path); -function writeBlockMapping(state, level, object, compact) { - var _result = '', - _tag = state.tag, - objectKeyList = Object.keys(object), - index, - length, - objectKey, - objectValue, - explicitPair, - pairBuffer; + if (predicate(value, path)) { + baseSet(result, castPath(path, object), value); + } + } + return result; + } - // Allow sorting keys so that the output file is deterministic - if (state.sortKeys === true) { - // Default sorting - objectKeyList.sort(); - } else if (typeof state.sortKeys === 'function') { - // Custom sort function - objectKeyList.sort(state.sortKeys); - } else if (state.sortKeys) { - // Something is wrong - throw new YAMLException('sortKeys must be a boolean or a function'); - } + /** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + */ + function basePropertyDeep(path) { + return function(object) { + return baseGet(object, path); + }; + } - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = ''; + /** + * The base implementation of `_.pullAllBy` without support for iteratee + * shorthands. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns `array`. + */ + function basePullAll(array, values, iteratee, comparator) { + var indexOf = comparator ? baseIndexOfWith : baseIndexOf, + index = -1, + length = values.length, + seen = array; - if (!compact || _result !== '') { - pairBuffer += generateNextLine(state, level); + if (array === values) { + values = copyArray(values); + } + if (iteratee) { + seen = arrayMap(array, baseUnary(iteratee)); + } + while (++index < length) { + var fromIndex = 0, + value = values[index], + computed = iteratee ? iteratee(value) : value; + + while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { + if (seen !== array) { + splice.call(seen, fromIndex, 1); + } + splice.call(array, fromIndex, 1); + } + } + return array; } - objectKey = objectKeyList[index]; - objectValue = object[objectKey]; + /** + * The base implementation of `_.pullAt` without support for individual + * indexes or capturing the removed elements. + * + * @private + * @param {Array} array The array to modify. + * @param {number[]} indexes The indexes of elements to remove. + * @returns {Array} Returns `array`. + */ + function basePullAt(array, indexes) { + var length = array ? indexes.length : 0, + lastIndex = length - 1; - if (state.replacer) { - objectValue = state.replacer.call(object, objectKey, objectValue); + while (length--) { + var index = indexes[length]; + if (length == lastIndex || index !== previous) { + var previous = index; + if (isIndex(index)) { + splice.call(array, index, 1); + } else { + baseUnset(array, index); + } + } + } + return array; } - if (!writeNode(state, level + 1, objectKey, true, true, true)) { - continue; // Skip this pair because of invalid key. + /** + * The base implementation of `_.random` without support for returning + * floating-point numbers. + * + * @private + * @param {number} lower The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the random number. + */ + function baseRandom(lower, upper) { + return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); } - explicitPair = (state.tag !== null && state.tag !== '?') || - (state.dump && state.dump.length > 1024); + /** + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments. + * + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the range of numbers. + */ + function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); - if (explicitPair) { - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += '?'; - } else { - pairBuffer += '? '; + while (length--) { + result[fromRight ? length : ++index] = start; + start += step; } + return result; } - pairBuffer += state.dump; + /** + * The base implementation of `_.repeat` which doesn't coerce arguments. + * + * @private + * @param {string} string The string to repeat. + * @param {number} n The number of times to repeat the string. + * @returns {string} Returns the repeated string. + */ + function baseRepeat(string, n) { + var result = ''; + if (!string || n < 1 || n > MAX_SAFE_INTEGER) { + return result; + } + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; + } + n = nativeFloor(n / 2); + if (n) { + string += string; + } + } while (n); - if (explicitPair) { - pairBuffer += generateNextLine(state, level); + return result; } - if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { - continue; // Skip this pair because of invalid value. + /** + * The base implementation of `_.rest` which doesn't validate or coerce arguments. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + */ + function baseRest(func, start) { + return setToString(overRest(func, start, identity), func + ''); } - if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { - pairBuffer += ':'; - } else { - pairBuffer += ': '; + /** + * The base implementation of `_.sample`. + * + * @private + * @param {Array|Object} collection The collection to sample. + * @returns {*} Returns the random element. + */ + function baseSample(collection) { + return arraySample(values(collection)); } - pairBuffer += state.dump; - - // Both key and value are valid. - _result += pairBuffer; - } - - state.tag = _tag; - state.dump = _result || '{}'; // Empty mapping if no valid pairs. -} - -function detectType(state, object, explicit) { - var _result, typeList, index, length, type, style; + /** + * The base implementation of `_.sampleSize` without param guards. + * + * @private + * @param {Array|Object} collection The collection to sample. + * @param {number} n The number of elements to sample. + * @returns {Array} Returns the random elements. + */ + function baseSampleSize(collection, n) { + var array = values(collection); + return shuffleSelf(array, baseClamp(n, 0, array.length)); + } - typeList = explicit ? state.explicitTypes : state.implicitTypes; + /** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ + function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } + path = castPath(path, object); - for (index = 0, length = typeList.length; index < length; index += 1) { - type = typeList[index]; + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; - if ((type.instanceOf || type.predicate) && - (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && - (!type.predicate || type.predicate(object))) { + while (nested != null && ++index < length) { + var key = toKey(path[index]), + newValue = value; - if (explicit) { - if (type.multi && type.representName) { - state.tag = type.representName(object); - } else { - state.tag = type.tag; + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; } - } else { - state.tag = '?'; - } - if (type.represent) { - style = state.styleMap[type.tag] || type.defaultStyle; - - if (_toString.call(type.represent) === '[object Function]') { - _result = type.represent(object, style); - } else if (_hasOwnProperty.call(type.represent, style)) { - _result = type.represent[style](object, style); - } else { - throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); + } } - - state.dump = _result; + assignValue(nested, key, newValue); + nested = nested[key]; } - - return true; + return object; } - } - - return false; -} -// Serializes `object` and writes it to global `result`. -// Returns true on success, or false on invalid object. -// -function writeNode(state, level, object, block, compact, iskey, isblockseq) { - state.tag = null; - state.dump = object; - - if (!detectType(state, object, false)) { - detectType(state, object, true); - } - - var type = _toString.call(state.dump); - var inblock = block; - var tagStr; - - if (block) { - block = (state.flowLevel < 0 || state.flowLevel > level); - } + /** + * The base implementation of `setData` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; + }; - var objectOrArray = type === '[object Object]' || type === '[object Array]', - duplicateIndex, - duplicate; + /** + * The base implementation of `setToString` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ + var baseSetToString = !defineProperty ? identity : function(func, string) { + return defineProperty(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant(string), + 'writable': true + }); + }; - if (objectOrArray) { - duplicateIndex = state.duplicates.indexOf(object); - duplicate = duplicateIndex !== -1; - } + /** + * The base implementation of `_.shuffle`. + * + * @private + * @param {Array|Object} collection The collection to shuffle. + * @returns {Array} Returns the new shuffled array. + */ + function baseShuffle(collection) { + return shuffleSelf(values(collection)); + } - if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { - compact = false; - } + /** + * The base implementation of `_.slice` without an iteratee call guard. + * + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ + function baseSlice(array, start, end) { + var index = -1, + length = array.length; - if (duplicate && state.usedDuplicates[duplicateIndex]) { - state.dump = '*ref_' + duplicateIndex; - } else { - if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { - state.usedDuplicates[duplicateIndex] = true; - } - if (type === '[object Object]') { - if (block && (Object.keys(state.dump).length !== 0)) { - writeBlockMapping(state, level, state.dump, compact); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; - } - } else { - writeFlowMapping(state, level, state.dump); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; - } + if (start < 0) { + start = -start > length ? 0 : (length + start); } - } else if (type === '[object Array]') { - if (block && (state.dump.length !== 0)) { - if (state.noArrayIndent && !isblockseq && level > 0) { - writeBlockSequence(state, level - 1, state.dump, compact); - } else { - writeBlockSequence(state, level, state.dump, compact); - } - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + state.dump; - } - } else { - writeFlowSequence(state, level, state.dump); - if (duplicate) { - state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; - } + end = end > length ? length : end; + if (end < 0) { + end += length; } - } else if (type === '[object String]') { - if (state.tag !== '?') { - writeScalar(state, state.dump, level, iskey, inblock); + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; } - } else if (type === '[object Undefined]') { - return false; - } else { - if (state.skipInvalid) return false; - throw new YAMLException('unacceptable kind of an object to dump ' + type); + return result; } - if (state.tag !== null && state.tag !== '?') { - // Need to encode all characters except those allowed by the spec: - // - // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ - // [36] ns-hex-digit ::= ns-dec-digit - // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ - // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ - // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” - // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” - // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” - // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” - // - // Also need to encode '!' because it has special meaning (end of tag prefix). - // - tagStr = encodeURI( - state.tag[0] === '!' ? state.tag.slice(1) : state.tag - ).replace(/!/g, '%21'); - - if (state.tag[0] === '!') { - tagStr = '!' + tagStr; - } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { - tagStr = '!!' + tagStr.slice(18); - } else { - tagStr = '!<' + tagStr + '>'; - } + /** + * The base implementation of `_.some` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function baseSome(collection, predicate) { + var result; - state.dump = tagStr + ' ' + state.dump; + baseEach(collection, function(value, index, collection) { + result = predicate(value, index, collection); + return !result; + }); + return !!result; } - } - return true; -} + /** + * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which + * performs a binary search of `array` to determine the index at which `value` + * should be inserted into `array` in order to maintain its sort order. + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function baseSortedIndex(array, value, retHighest) { + var low = 0, + high = array == null ? low : array.length; -function getDuplicateReferences(object, state) { - var objects = [], - duplicatesIndexes = [], - index, - length; + if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { + while (low < high) { + var mid = (low + high) >>> 1, + computed = array[mid]; - inspectNode(object, objects, duplicatesIndexes); + if (computed !== null && !isSymbol(computed) && + (retHighest ? (computed <= value) : (computed < value))) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + return baseSortedIndexBy(array, value, identity, retHighest); + } - for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { - state.duplicates.push(objects[duplicatesIndexes[index]]); - } - state.usedDuplicates = new Array(length); -} + /** + * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` + * which invokes `iteratee` for `value` and each element of `array` to compute + * their sort ranking. The iteratee is invoked with one argument; (value). + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} iteratee The iteratee invoked per element. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function baseSortedIndexBy(array, value, iteratee, retHighest) { + var low = 0, + high = array == null ? 0 : array.length; + if (high === 0) { + return 0; + } -function inspectNode(object, objects, duplicatesIndexes) { - var objectKeyList, - index, - length; + value = iteratee(value); + var valIsNaN = value !== value, + valIsNull = value === null, + valIsSymbol = isSymbol(value), + valIsUndefined = value === undefined; - if (object !== null && typeof object === 'object') { - index = objects.indexOf(object); - if (index !== -1) { - if (duplicatesIndexes.indexOf(index) === -1) { - duplicatesIndexes.push(index); - } - } else { - objects.push(object); + while (low < high) { + var mid = nativeFloor((low + high) / 2), + computed = iteratee(array[mid]), + othIsDefined = computed !== undefined, + othIsNull = computed === null, + othIsReflexive = computed === computed, + othIsSymbol = isSymbol(computed); - if (Array.isArray(object)) { - for (index = 0, length = object.length; index < length; index += 1) { - inspectNode(object[index], objects, duplicatesIndexes); + if (valIsNaN) { + var setLow = retHighest || othIsReflexive; + } else if (valIsUndefined) { + setLow = othIsReflexive && (retHighest || othIsDefined); + } else if (valIsNull) { + setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); + } else if (valIsSymbol) { + setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); + } else if (othIsNull || othIsSymbol) { + setLow = false; + } else { + setLow = retHighest ? (computed <= value) : (computed < value); } - } else { - objectKeyList = Object.keys(object); - - for (index = 0, length = objectKeyList.length; index < length; index += 1) { - inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + if (setLow) { + low = mid + 1; + } else { + high = mid; } } + return nativeMin(high, MAX_ARRAY_INDEX); } - } -} - -function dump(input, options) { - options = options || {}; - - var state = new State(options); - - if (!state.noRefs) getDuplicateReferences(input, state); - - var value = input; - - if (state.replacer) { - value = state.replacer.call({ '': value }, '', value); - } - - if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; - - return ''; -} -module.exports.dump = dump; - - -/***/ }), - -/***/ 8179: -/***/ ((module) => { + /** + * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ + function baseSortedUniq(array, iteratee) { + var index = -1, + length = array.length, + resIndex = 0, + result = []; -"use strict"; -// YAML error class. http://stackoverflow.com/questions/8458984 -// + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + if (!index || !eq(computed, seen)) { + var seen = computed; + result[resIndex++] = value === 0 ? 0 : value; + } + } + return result; + } + /** + * The base implementation of `_.toNumber` which doesn't ensure correct + * conversions of binary, hexadecimal, or octal string values. + * + * @private + * @param {*} value The value to process. + * @returns {number} Returns the number. + */ + function baseToNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + return +value; + } -function formatError(exception, compact) { - var where = '', message = exception.reason || '(unknown reason)'; + /** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ + function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; + } - if (!exception.mark) return message; + /** + * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ + function baseUniq(array, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + length = array.length, + isCommon = true, + result = [], + seen = result; - if (exception.mark.name) { - where += 'in "' + exception.mark.name + '" '; - } + if (comparator) { + isCommon = false; + includes = arrayIncludesWith; + } + else if (length >= LARGE_ARRAY_SIZE) { + var set = iteratee ? null : createSet(array); + if (set) { + return setToArray(set); + } + isCommon = false; + includes = cacheHas; + seen = new SetCache; + } + else { + seen = iteratee ? [] : result; + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; - where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; + value = (comparator || value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } + else if (!includes(seen, computed, comparator)) { + if (seen !== result) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } - if (!compact && exception.mark.snippet) { - where += '\n\n' + exception.mark.snippet; - } + /** + * The base implementation of `_.unset`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The property path to unset. + * @returns {boolean} Returns `true` if the property is deleted, else `false`. + */ + function baseUnset(object, path) { + path = castPath(path, object); + object = parent(object, path); + return object == null || delete object[toKey(last(path))]; + } - return message + ' ' + where; -} + /** + * The base implementation of `_.update`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to update. + * @param {Function} updater The function to produce the updated value. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ + function baseUpdate(object, path, updater, customizer) { + return baseSet(object, path, updater(baseGet(object, path)), customizer); + } + /** + * The base implementation of methods like `_.dropWhile` and `_.takeWhile` + * without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to query. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [isDrop] Specify dropping elements instead of taking them. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the slice of `array`. + */ + function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, + index = fromRight ? length : -1; -function YAMLException(reason, mark) { - // Super constructor - Error.call(this); + while ((fromRight ? index-- : ++index < length) && + predicate(array[index], index, array)) {} - this.name = 'YAMLException'; - this.reason = reason; - this.mark = mark; - this.message = formatError(this, false); + return isDrop + ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) + : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); + } - // Include stack trace in error object - if (Error.captureStackTrace) { - // Chrome and NodeJS - Error.captureStackTrace(this, this.constructor); - } else { - // FF, IE 10+ and Safari 6+. Fallback for others - this.stack = (new Error()).stack || ''; - } -} + /** + * The base implementation of `wrapperValue` which returns the result of + * performing a sequence of actions on the unwrapped `value`, where each + * successive action is supplied the return value of the previous. + * + * @private + * @param {*} value The unwrapped value. + * @param {Array} actions Actions to perform to resolve the unwrapped value. + * @returns {*} Returns the resolved value. + */ + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + return arrayReduce(actions, function(result, action) { + return action.func.apply(action.thisArg, arrayPush([result], action.args)); + }, result); + } + /** + * The base implementation of methods like `_.xor`, without support for + * iteratee shorthands, that accepts an array of arrays to inspect. + * + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of values. + */ + function baseXor(arrays, iteratee, comparator) { + var length = arrays.length; + if (length < 2) { + return length ? baseUniq(arrays[0]) : []; + } + var index = -1, + result = Array(length); -// Inherit from Error -YAMLException.prototype = Object.create(Error.prototype); -YAMLException.prototype.constructor = YAMLException; + while (++index < length) { + var array = arrays[index], + othIndex = -1; + while (++othIndex < length) { + if (othIndex != index) { + result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); + } + } + } + return baseUniq(baseFlatten(result, 1), iteratee, comparator); + } -YAMLException.prototype.toString = function toString(compact) { - return this.name + ': ' + formatError(this, compact); -}; + /** + * This base implementation of `_.zipObject` which assigns values using `assignFunc`. + * + * @private + * @param {Array} props The property identifiers. + * @param {Array} values The property values. + * @param {Function} assignFunc The function to assign values. + * @returns {Object} Returns the new object. + */ + function baseZipObject(props, values, assignFunc) { + var index = -1, + length = props.length, + valsLength = values.length, + result = {}; + while (++index < length) { + var value = index < valsLength ? values[index] : undefined; + assignFunc(result, props[index], value); + } + return result; + } -module.exports = YAMLException; + /** + * Casts `value` to an empty array if it's not an array like object. + * + * @private + * @param {*} value The value to inspect. + * @returns {Array|Object} Returns the cast array-like object. + */ + function castArrayLikeObject(value) { + return isArrayLikeObject(value) ? value : []; + } + /** + * Casts `value` to `identity` if it's not a function. + * + * @private + * @param {*} value The value to inspect. + * @returns {Function} Returns cast function. + */ + function castFunction(value) { + return typeof value == 'function' ? value : identity; + } -/***/ }), + /** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ + function castPath(value, object) { + if (isArray(value)) { + return value; + } + return isKey(value, object) ? [value] : stringToPath(toString(value)); + } -/***/ 1161: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * A `baseRest` alias which can be replaced with `identity` by module + * replacement plugins. + * + * @private + * @type {Function} + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. + */ + var castRest = baseRest; -"use strict"; + /** + * Casts `array` to a slice if it's needed. + * + * @private + * @param {Array} array The array to inspect. + * @param {number} start The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the cast slice. + */ + function castSlice(array, start, end) { + var length = array.length; + end = end === undefined ? length : end; + return (!start && end >= length) ? array : baseSlice(array, start, end); + } + /** + * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). + * + * @private + * @param {number|Object} id The timer id or timeout object of the timer to clear. + */ + var clearTimeout = ctxClearTimeout || function(id) { + return root.clearTimeout(id); + }; -/*eslint-disable max-len,no-use-before-define*/ + /** + * Creates a clone of `buffer`. + * + * @private + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. + */ + function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); + } + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); -var common = __nccwpck_require__(6829); -var YAMLException = __nccwpck_require__(8179); -var makeSnippet = __nccwpck_require__(6975); -var DEFAULT_SCHEMA = __nccwpck_require__(8759); + buffer.copy(result); + return result; + } + /** + * Creates a clone of `arrayBuffer`. + * + * @private + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ + function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array(result).set(new Uint8Array(arrayBuffer)); + return result; + } -var _hasOwnProperty = Object.prototype.hasOwnProperty; + /** + * Creates a clone of `dataView`. + * + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. + */ + function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); + } + /** + * Creates a clone of `regexp`. + * + * @private + * @param {Object} regexp The regexp to clone. + * @returns {Object} Returns the cloned regexp. + */ + function cloneRegExp(regexp) { + var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); + result.lastIndex = regexp.lastIndex; + return result; + } -var CONTEXT_FLOW_IN = 1; -var CONTEXT_FLOW_OUT = 2; -var CONTEXT_BLOCK_IN = 3; -var CONTEXT_BLOCK_OUT = 4; + /** + * Creates a clone of the `symbol` object. + * + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. + */ + function cloneSymbol(symbol) { + return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; + } + /** + * Creates a clone of `typedArray`. + * + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. + */ + function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); + } -var CHOMPING_CLIP = 1; -var CHOMPING_STRIP = 2; -var CHOMPING_KEEP = 3; + /** + * Compares values to sort them in ascending order. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {number} Returns the sort order indicator for `value`. + */ + function compareAscending(value, other) { + if (value !== other) { + var valIsDefined = value !== undefined, + valIsNull = value === null, + valIsReflexive = value === value, + valIsSymbol = isSymbol(value); + var othIsDefined = other !== undefined, + othIsNull = other === null, + othIsReflexive = other === other, + othIsSymbol = isSymbol(other); -var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; -var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; -var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; -var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; -var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; + if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || + (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || + (valIsNull && othIsDefined && othIsReflexive) || + (!valIsDefined && othIsReflexive) || + !valIsReflexive) { + return 1; + } + if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || + (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || + (othIsNull && valIsDefined && valIsReflexive) || + (!othIsDefined && valIsReflexive) || + !othIsReflexive) { + return -1; + } + } + return 0; + } + /** + * Used by `_.orderBy` to compare multiple properties of a value to another + * and stable sort them. + * + * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, + * specify an order of "desc" for descending or "asc" for ascending sort order + * of corresponding values. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {boolean[]|string[]} orders The order to sort by for each property. + * @returns {number} Returns the sort order indicator for `object`. + */ + function compareMultiple(object, other, orders) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length, + ordersLength = orders.length; -function _class(obj) { return Object.prototype.toString.call(obj); } + while (++index < length) { + var result = compareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order == 'desc' ? -1 : 1); + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to provide the same value for + // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for more details. + // + // This also ensures a stable sort in V8 and other engines. + // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. + return object.index - other.index; + } -function is_EOL(c) { - return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); -} + /** + * Creates an array that is the composition of partially applied arguments, + * placeholders, and provided arguments into a single array of arguments. + * + * @private + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to prepend to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. + */ + function composeArgs(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersLength = holders.length, + leftIndex = -1, + leftLength = partials.length, + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(leftLength + rangeLength), + isUncurried = !isCurried; -function is_WHITE_SPACE(c) { - return (c === 0x09/* Tab */) || (c === 0x20/* Space */); -} + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; + } + while (++argsIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[holders[argsIndex]] = args[argsIndex]; + } + } + while (rangeLength--) { + result[leftIndex++] = args[argsIndex++]; + } + return result; + } -function is_WS_OR_EOL(c) { - return (c === 0x09/* Tab */) || - (c === 0x20/* Space */) || - (c === 0x0A/* LF */) || - (c === 0x0D/* CR */); -} + /** + * This function is like `composeArgs` except that the arguments composition + * is tailored for `_.partialRight`. + * + * @private + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to append to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. + */ + function composeArgsRight(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersIndex = -1, + holdersLength = holders.length, + rightIndex = -1, + rightLength = partials.length, + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(rangeLength + rightLength), + isUncurried = !isCurried; -function is_FLOW_INDICATOR(c) { - return c === 0x2C/* , */ || - c === 0x5B/* [ */ || - c === 0x5D/* ] */ || - c === 0x7B/* { */ || - c === 0x7D/* } */; -} + while (++argsIndex < rangeLength) { + result[argsIndex] = args[argsIndex]; + } + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; + } + while (++holdersIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + } + return result; + } -function fromHexCode(c) { - var lc; + /** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ + function copyArray(source, array) { + var index = -1, + length = source.length; - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } - /*eslint-disable no-bitwise*/ - lc = c | 0x20; + /** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ + function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); - if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { - return lc - 0x61 + 10; - } + var index = -1, + length = props.length; - return -1; -} + while (++index < length) { + var key = props[index]; -function escapedHexLen(c) { - if (c === 0x78/* x */) { return 2; } - if (c === 0x75/* u */) { return 4; } - if (c === 0x55/* U */) { return 8; } - return 0; -} + var newValue = customizer + ? customizer(object[key], source[key], key, object, source) + : undefined; -function fromDecimalCode(c) { - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + baseAssignValue(object, key, newValue); + } else { + assignValue(object, key, newValue); + } + } + return object; + } - return -1; -} + /** + * Copies own symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ + function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); + } -function simpleEscapeSequence(c) { - /* eslint-disable indent */ - return (c === 0x30/* 0 */) ? '\x00' : - (c === 0x61/* a */) ? '\x07' : - (c === 0x62/* b */) ? '\x08' : - (c === 0x74/* t */) ? '\x09' : - (c === 0x09/* Tab */) ? '\x09' : - (c === 0x6E/* n */) ? '\x0A' : - (c === 0x76/* v */) ? '\x0B' : - (c === 0x66/* f */) ? '\x0C' : - (c === 0x72/* r */) ? '\x0D' : - (c === 0x65/* e */) ? '\x1B' : - (c === 0x20/* Space */) ? ' ' : - (c === 0x22/* " */) ? '\x22' : - (c === 0x2F/* / */) ? '/' : - (c === 0x5C/* \ */) ? '\x5C' : - (c === 0x4E/* N */) ? '\x85' : - (c === 0x5F/* _ */) ? '\xA0' : - (c === 0x4C/* L */) ? '\u2028' : - (c === 0x50/* P */) ? '\u2029' : ''; -} + /** + * Copies own and inherited symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ + function copySymbolsIn(source, object) { + return copyObject(source, getSymbolsIn(source), object); + } -function charFromCodepoint(c) { - if (c <= 0xFFFF) { - return String.fromCharCode(c); - } - // Encode UTF-16 surrogate pair - // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF - return String.fromCharCode( - ((c - 0x010000) >> 10) + 0xD800, - ((c - 0x010000) & 0x03FF) + 0xDC00 - ); -} + /** + * Creates a function like `_.groupBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} [initializer] The accumulator object initializer. + * @returns {Function} Returns the new aggregator function. + */ + function createAggregator(setter, initializer) { + return function(collection, iteratee) { + var func = isArray(collection) ? arrayAggregator : baseAggregator, + accumulator = initializer ? initializer() : {}; -var simpleEscapeCheck = new Array(256); // integer, for fast access -var simpleEscapeMap = new Array(256); -for (var i = 0; i < 256; i++) { - simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; - simpleEscapeMap[i] = simpleEscapeSequence(i); -} + return func(collection, setter, getIteratee(iteratee, 2), accumulator); + }; + } + /** + * Creates a function like `_.assign`. + * + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. + */ + function createAssigner(assigner) { + return baseRest(function(object, sources) { + var index = -1, + length = sources.length, + customizer = length > 1 ? sources[length - 1] : undefined, + guard = length > 2 ? sources[2] : undefined; -function State(input, options) { - this.input = input; + customizer = (assigner.length > 3 && typeof customizer == 'function') + ? (length--, customizer) + : undefined; - this.filename = options['filename'] || null; - this.schema = options['schema'] || DEFAULT_SCHEMA; - this.onWarning = options['onWarning'] || null; - // (Hidden) Remove? makes the loader to expect YAML 1.1 documents - // if such documents have no explicit %YAML directive - this.legacy = options['legacy'] || false; + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + object = Object(object); + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, index, customizer); + } + } + return object; + }); + } - this.json = options['json'] || false; - this.listener = options['listener'] || null; + /** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ + function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + if (collection == null) { + return collection; + } + if (!isArrayLike(collection)) { + return eachFunc(collection, iteratee); + } + var length = collection.length, + index = fromRight ? length : -1, + iterable = Object(collection); - this.implicitTypes = this.schema.compiledImplicit; - this.typeMap = this.schema.compiledTypeMap; + while ((fromRight ? index-- : ++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; + } - this.length = input.length; - this.position = 0; - this.line = 0; - this.lineStart = 0; - this.lineIndent = 0; + /** + * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ + function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; - // position of first leading tab in the current line, - // used to make sure there are no tabs in the indentation - this.firstTabInLine = -1; + while (length--) { + var key = props[fromRight ? length : ++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; + } - this.documents = []; + /** + * Creates a function that wraps `func` to invoke it with the optional `this` + * binding of `thisArg`. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createBind(func, bitmask, thisArg) { + var isBind = bitmask & WRAP_BIND_FLAG, + Ctor = createCtor(func); - /* - this.version; - this.checkLineBreaks; - this.tagMap; - this.anchorMap; - this.tag; - this.anchor; - this.kind; - this.result;*/ + function wrapper() { + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return fn.apply(isBind ? thisArg : this, arguments); + } + return wrapper; + } -} + /** + * Creates a function like `_.lowerFirst`. + * + * @private + * @param {string} methodName The name of the `String` case method to use. + * @returns {Function} Returns the new case function. + */ + function createCaseFirst(methodName) { + return function(string) { + string = toString(string); + var strSymbols = hasUnicode(string) + ? stringToArray(string) + : undefined; -function generateError(state, message) { - var mark = { - name: state.filename, - buffer: state.input.slice(0, -1), // omit trailing \0 - position: state.position, - line: state.line, - column: state.position - state.lineStart - }; + var chr = strSymbols + ? strSymbols[0] + : string.charAt(0); - mark.snippet = makeSnippet(mark); + var trailing = strSymbols + ? castSlice(strSymbols, 1).join('') + : string.slice(1); - return new YAMLException(message, mark); -} + return chr[methodName]() + trailing; + }; + } -function throwError(state, message) { - throw generateError(state, message); -} + /** + * Creates a function like `_.camelCase`. + * + * @private + * @param {Function} callback The function to combine each word. + * @returns {Function} Returns the new compounder function. + */ + function createCompounder(callback) { + return function(string) { + return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); + }; + } -function throwWarning(state, message) { - if (state.onWarning) { - state.onWarning.call(null, generateError(state, message)); - } -} + /** + * Creates a function that produces an instance of `Ctor` regardless of + * whether it was invoked as part of a `new` expression or by `call` or `apply`. + * + * @private + * @param {Function} Ctor The constructor to wrap. + * @returns {Function} Returns the new wrapped function. + */ + function createCtor(Ctor) { + return function() { + // Use a `switch` statement to work with class constructors. See + // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist + // for more details. + var args = arguments; + switch (args.length) { + case 0: return new Ctor; + case 1: return new Ctor(args[0]); + case 2: return new Ctor(args[0], args[1]); + case 3: return new Ctor(args[0], args[1], args[2]); + case 4: return new Ctor(args[0], args[1], args[2], args[3]); + case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); + case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), + result = Ctor.apply(thisBinding, args); + // Mimic the constructor's `return` behavior. + // See https://es5.github.io/#x13.2.2 for more details. + return isObject(result) ? result : thisBinding; + }; + } -var directiveHandlers = { + /** + * Creates a function that wraps `func` to enable currying. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {number} arity The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createCurry(func, bitmask, arity) { + var Ctor = createCtor(func); - YAML: function handleYamlDirective(state, name, args) { + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length, + placeholder = getHolder(wrapper); - var match, major, minor; + while (index--) { + args[index] = arguments[index]; + } + var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) + ? [] + : replaceHolders(args, placeholder); - if (state.version !== null) { - throwError(state, 'duplication of %YAML directive'); + length -= holders.length; + if (length < arity) { + return createRecurry( + func, bitmask, createHybrid, wrapper.placeholder, undefined, + args, holders, undefined, undefined, arity - length); + } + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return apply(fn, this, args); + } + return wrapper; } - if (args.length !== 1) { - throwError(state, 'YAML directive accepts exactly one argument'); + /** + * Creates a `_.find` or `_.findLast` function. + * + * @private + * @param {Function} findIndexFunc The function to find the collection index. + * @returns {Function} Returns the new find function. + */ + function createFind(findIndexFunc) { + return function(collection, predicate, fromIndex) { + var iterable = Object(collection); + if (!isArrayLike(collection)) { + var iteratee = getIteratee(predicate, 3); + collection = keys(collection); + predicate = function(key) { return iteratee(iterable[key], key, iterable); }; + } + var index = findIndexFunc(collection, predicate, fromIndex); + return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; + }; } - match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + /** + * Creates a `_.flow` or `_.flowRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new flow function. + */ + function createFlow(fromRight) { + return flatRest(function(funcs) { + var length = funcs.length, + index = length, + prereq = LodashWrapper.prototype.thru; - if (match === null) { - throwError(state, 'ill-formed argument of the YAML directive'); - } + if (fromRight) { + funcs.reverse(); + } + while (index--) { + var func = funcs[index]; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (prereq && !wrapper && getFuncName(func) == 'wrapper') { + var wrapper = new LodashWrapper([], true); + } + } + index = wrapper ? index : length; + while (++index < length) { + func = funcs[index]; - major = parseInt(match[1], 10); - minor = parseInt(match[2], 10); + var funcName = getFuncName(func), + data = funcName == 'wrapper' ? getData(func) : undefined; - if (major !== 1) { - throwError(state, 'unacceptable YAML version of the document'); - } + if (data && isLaziable(data[0]) && + data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && + !data[4].length && data[9] == 1 + ) { + wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); + } else { + wrapper = (func.length == 1 && isLaziable(func)) + ? wrapper[funcName]() + : wrapper.thru(func); + } + } + return function() { + var args = arguments, + value = args[0]; - state.version = args[0]; - state.checkLineBreaks = (minor < 2); + if (wrapper && args.length == 1 && isArray(value)) { + return wrapper.plant(value).value(); + } + var index = 0, + result = length ? funcs[index].apply(this, args) : value; - if (minor !== 1 && minor !== 2) { - throwWarning(state, 'unsupported YAML version of the document'); + while (++index < length) { + result = funcs[index].call(this, result); + } + return result; + }; + }); } - }, - - TAG: function handleTagDirective(state, name, args) { - var handle, prefix; + /** + * Creates a function that wraps `func` to invoke it with optional `this` + * binding of `thisArg`, partial application, and currying. + * + * @private + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [partialsRight] The arguments to append to those provided + * to the new function. + * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & WRAP_ARY_FLAG, + isBind = bitmask & WRAP_BIND_FLAG, + isBindKey = bitmask & WRAP_BIND_KEY_FLAG, + isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), + isFlip = bitmask & WRAP_FLIP_FLAG, + Ctor = isBindKey ? undefined : createCtor(func); - if (args.length !== 2) { - throwError(state, 'TAG directive accepts exactly two arguments'); - } + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length; - handle = args[0]; - prefix = args[1]; + while (index--) { + args[index] = arguments[index]; + } + if (isCurried) { + var placeholder = getHolder(wrapper), + holdersCount = countHolders(args, placeholder); + } + if (partials) { + args = composeArgs(args, partials, holders, isCurried); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight, isCurried); + } + length -= holdersCount; + if (isCurried && length < arity) { + var newHolders = replaceHolders(args, placeholder); + return createRecurry( + func, bitmask, createHybrid, wrapper.placeholder, thisArg, + args, newHolders, argPos, ary, arity - length + ); + } + var thisBinding = isBind ? thisArg : this, + fn = isBindKey ? thisBinding[func] : func; - if (!PATTERN_TAG_HANDLE.test(handle)) { - throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); + length = args.length; + if (argPos) { + args = reorder(args, argPos); + } else if (isFlip && length > 1) { + args.reverse(); + } + if (isAry && ary < length) { + args.length = ary; + } + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtor(fn); + } + return fn.apply(thisBinding, args); + } + return wrapper; } - if (_hasOwnProperty.call(state.tagMap, handle)) { - throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + /** + * Creates a function like `_.invertBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} toIteratee The function to resolve iteratees. + * @returns {Function} Returns the new inverter function. + */ + function createInverter(setter, toIteratee) { + return function(object, iteratee) { + return baseInverter(object, setter, toIteratee(iteratee), {}); + }; } - if (!PATTERN_TAG_URI.test(prefix)) { - throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + /** + * Creates a function that performs a mathematical operation on two values. + * + * @private + * @param {Function} operator The function to perform the operation. + * @param {number} [defaultValue] The value used for `undefined` arguments. + * @returns {Function} Returns the new mathematical operation function. + */ + function createMathOperation(operator, defaultValue) { + return function(value, other) { + var result; + if (value === undefined && other === undefined) { + return defaultValue; + } + if (value !== undefined) { + result = value; + } + if (other !== undefined) { + if (result === undefined) { + return other; + } + if (typeof value == 'string' || typeof other == 'string') { + value = baseToString(value); + other = baseToString(other); + } else { + value = baseToNumber(value); + other = baseToNumber(other); + } + result = operator(value, other); + } + return result; + }; } - try { - prefix = decodeURIComponent(prefix); - } catch (err) { - throwError(state, 'tag prefix is malformed: ' + prefix); + /** + * Creates a function like `_.over`. + * + * @private + * @param {Function} arrayFunc The function to iterate over iteratees. + * @returns {Function} Returns the new over function. + */ + function createOver(arrayFunc) { + return flatRest(function(iteratees) { + iteratees = arrayMap(iteratees, baseUnary(getIteratee())); + return baseRest(function(args) { + var thisArg = this; + return arrayFunc(iteratees, function(iteratee) { + return apply(iteratee, thisArg, args); + }); + }); + }); } - state.tagMap[handle] = prefix; - } -}; + /** + * Creates the padding for `string` based on `length`. The `chars` string + * is truncated if the number of characters exceeds `length`. + * + * @private + * @param {number} length The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padding for `string`. + */ + function createPadding(length, chars) { + chars = chars === undefined ? ' ' : baseToString(chars); + var charsLength = chars.length; + if (charsLength < 2) { + return charsLength ? baseRepeat(chars, length) : chars; + } + var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); + return hasUnicode(chars) + ? castSlice(stringToArray(result), 0, length).join('') + : result.slice(0, length); + } -function captureSegment(state, start, end, checkJson) { - var _position, _length, _character, _result; + /** + * Creates a function that wraps `func` to invoke it with the `this` binding + * of `thisArg` and `partials` prepended to the arguments it receives. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} partials The arguments to prepend to those provided to + * the new function. + * @returns {Function} Returns the new wrapped function. + */ + function createPartial(func, bitmask, thisArg, partials) { + var isBind = bitmask & WRAP_BIND_FLAG, + Ctor = createCtor(func); - if (start < end) { - _result = state.input.slice(start, end); + function wrapper() { + var argsIndex = -1, + argsLength = arguments.length, + leftIndex = -1, + leftLength = partials.length, + args = Array(leftLength + argsLength), + fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; - if (checkJson) { - for (_position = 0, _length = _result.length; _position < _length; _position += 1) { - _character = _result.charCodeAt(_position); - if (!(_character === 0x09 || - (0x20 <= _character && _character <= 0x10FFFF))) { - throwError(state, 'expected valid JSON character'); + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; } + return apply(fn, isBind ? thisArg : this, args); } - } else if (PATTERN_NON_PRINTABLE.test(_result)) { - throwError(state, 'the stream contains non-printable characters'); + return wrapper; } - state.result += _result; - } -} + /** + * Creates a `_.range` or `_.rangeRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new range function. + */ + function createRange(fromRight) { + return function(start, end, step) { + if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { + end = step = undefined; + } + // Ensure the sign of `-0` is preserved. + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); + return baseRange(start, end, step, fromRight); + }; + } -function mergeMappings(state, destination, source, overridableKeys) { - var sourceKeys, key, index, quantity; + /** + * Creates a function that performs a relational operation on two values. + * + * @private + * @param {Function} operator The function to perform the operation. + * @returns {Function} Returns the new relational operation function. + */ + function createRelationalOperation(operator) { + return function(value, other) { + if (!(typeof value == 'string' && typeof other == 'string')) { + value = toNumber(value); + other = toNumber(other); + } + return operator(value, other); + }; + } - if (!common.isObject(source)) { - throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); - } + /** + * Creates a function that wraps `func` to continue currying. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {Function} wrapFunc The function to create the `func` wrapper. + * @param {*} placeholder The placeholder value. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { + var isCurry = bitmask & WRAP_CURRY_FLAG, + newHolders = isCurry ? holders : undefined, + newHoldersRight = isCurry ? undefined : holders, + newPartials = isCurry ? partials : undefined, + newPartialsRight = isCurry ? undefined : partials; - sourceKeys = Object.keys(source); + bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); + bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); - for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { - key = sourceKeys[index]; + if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { + bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); + } + var newData = [ + func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, + newHoldersRight, argPos, ary, arity + ]; - if (!_hasOwnProperty.call(destination, key)) { - destination[key] = source[key]; - overridableKeys[key] = true; + var result = wrapFunc.apply(undefined, newData); + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return setWrapToString(result, func, bitmask); } - } -} -function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, - startLine, startLineStart, startPos) { + /** + * Creates a function like `_.round`. + * + * @private + * @param {string} methodName The name of the `Math` method to use when rounding. + * @returns {Function} Returns the new round function. + */ + function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + number = toNumber(number); + precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); + if (precision && nativeIsFinite(number)) { + // Shift with exponential notation to avoid floating-point issues. + // See [MDN](https://mdn.io/round#Examples) for more details. + var pair = (toString(number) + 'e').split('e'), + value = func(pair[0] + 'e' + (+pair[1] + precision)); - var index, quantity; + pair = (toString(value) + 'e').split('e'); + return +(pair[0] + 'e' + (+pair[1] - precision)); + } + return func(number); + }; + } - // The output is a plain object here, so keys can only be strings. - // We need to convert keyNode to a string, but doing so can hang the process - // (deeply nested arrays that explode exponentially using aliases). - if (Array.isArray(keyNode)) { - keyNode = Array.prototype.slice.call(keyNode); + /** + * Creates a set object of `values`. + * + * @private + * @param {Array} values The values to add to the set. + * @returns {Object} Returns the new set. + */ + var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { + return new Set(values); + }; - for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { - if (Array.isArray(keyNode[index])) { - throwError(state, 'nested arrays are not supported inside keys'); + /** + * Creates a `_.toPairs` or `_.toPairsIn` function. + * + * @private + * @param {Function} keysFunc The function to get the keys of a given object. + * @returns {Function} Returns the new pairs function. + */ + function createToPairs(keysFunc) { + return function(object) { + var tag = getTag(object); + if (tag == mapTag) { + return mapToArray(object); + } + if (tag == setTag) { + return setToPairs(object); + } + return baseToPairs(object, keysFunc(object)); + }; + } + + /** + * Creates a function that either curries or invokes `func` with optional + * `this` binding and partially applied arguments. + * + * @private + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` or `_.curryRight` of a bound function + * 8 - `_.curry` + * 16 - `_.curryRight` + * 32 - `_.partial` + * 64 - `_.partialRight` + * 128 - `_.rearg` + * 256 - `_.ary` + * 512 - `_.flip` + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to be partially applied. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; + if (!isBindKey && typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); } - - if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { - keyNode[index] = '[object Object]'; + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); + partials = holders = undefined; } - } - } + ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); + arity = arity === undefined ? arity : toInteger(arity); + length -= holders ? holders.length : 0; - // Avoid code execution in load() via toString property - // (still use its own toString for arrays, timestamps, - // and whatever user schema extensions happen to have @@toStringTag) - if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { - keyNode = '[object Object]'; - } + if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, + holdersRight = holders; + partials = holders = undefined; + } + var data = isBindKey ? undefined : getData(func); - keyNode = String(keyNode); + var newData = [ + func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, + argPos, ary, arity + ]; - if (_result === null) { - _result = {}; - } + if (data) { + mergeData(newData, data); + } + func = newData[0]; + bitmask = newData[1]; + thisArg = newData[2]; + partials = newData[3]; + holders = newData[4]; + arity = newData[9] = newData[9] === undefined + ? (isBindKey ? 0 : func.length) + : nativeMax(newData[9] - length, 0); - if (keyTag === 'tag:yaml.org,2002:merge') { - if (Array.isArray(valueNode)) { - for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { - mergeMappings(state, _result, valueNode[index], overridableKeys); + if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { + bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); } - } else { - mergeMappings(state, _result, valueNode, overridableKeys); - } - } else { - if (!state.json && - !_hasOwnProperty.call(overridableKeys, keyNode) && - _hasOwnProperty.call(_result, keyNode)) { - state.line = startLine || state.line; - state.lineStart = startLineStart || state.lineStart; - state.position = startPos || state.position; - throwError(state, 'duplicated mapping key'); + if (!bitmask || bitmask == WRAP_BIND_FLAG) { + var result = createBind(func, bitmask, thisArg); + } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { + result = createCurry(func, bitmask, arity); + } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { + result = createPartial(func, bitmask, thisArg, partials); + } else { + result = createHybrid.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setWrapToString(setter(result, newData), func, bitmask); } - // used for this specific key only because Object.defineProperty is slow - if (keyNode === '__proto__') { - Object.defineProperty(_result, keyNode, { - configurable: true, - enumerable: true, - writable: true, - value: valueNode - }); - } else { - _result[keyNode] = valueNode; + /** + * Used by `_.defaults` to customize its `_.assignIn` use to assign properties + * of source objects to the destination object for all destination properties + * that resolve to `undefined`. + * + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to assign. + * @param {Object} object The parent object of `objValue`. + * @returns {*} Returns the value to assign. + */ + function customDefaultsAssignIn(objValue, srcValue, key, object) { + if (objValue === undefined || + (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { + return srcValue; + } + return objValue; } - delete overridableKeys[keyNode]; - } - - return _result; -} - -function readLineBreak(state) { - var ch; - ch = state.input.charCodeAt(state.position); - - if (ch === 0x0A/* LF */) { - state.position++; - } else if (ch === 0x0D/* CR */) { - state.position++; - if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { - state.position++; + /** + * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source + * objects into destination objects that are passed thru. + * + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to merge. + * @param {Object} object The parent object of `objValue`. + * @param {Object} source The parent object of `srcValue`. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + * @returns {*} Returns the value to assign. + */ + function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { + if (isObject(objValue) && isObject(srcValue)) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, objValue); + baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); + stack['delete'](srcValue); + } + return objValue; } - } else { - throwError(state, 'a line break is expected'); - } - state.line += 1; - state.lineStart = state.position; - state.firstTabInLine = -1; -} + /** + * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain + * objects. + * + * @private + * @param {*} value The value to inspect. + * @param {string} key The key of the property to inspect. + * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. + */ + function customOmitClone(value) { + return isPlainObject(value) ? undefined : value; + } -function skipSeparationSpace(state, allowComments, checkIndent) { - var lineBreaks = 0, - ch = state.input.charCodeAt(state.position); + /** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ + function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + arrLength = array.length, + othLength = other.length; - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { - state.firstTabInLine = state.position; + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; } - ch = state.input.charCodeAt(++state.position); - } - - if (allowComments && ch === 0x23/* # */) { - do { - ch = state.input.charCodeAt(++state.position); - } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); - } + // Check that cyclic values are equal. + var arrStacked = stack.get(array); + var othStacked = stack.get(other); + if (arrStacked && othStacked) { + return arrStacked == other && othStacked == array; + } + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; - if (is_EOL(ch)) { - readLineBreak(state); + stack.set(array, other); + stack.set(other, array); - ch = state.input.charCodeAt(state.position); - lineBreaks++; - state.lineIndent = 0; + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; - while (ch === 0x20/* Space */) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } } - } else { - break; + stack['delete'](array); + stack['delete'](other); + return result; } - } - - if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { - throwWarning(state, 'deficient indentation'); - } - return lineBreaks; -} + /** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; -function testDocumentSeparator(state) { - var _position = state.position, - ch; + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; - ch = state.input.charCodeAt(_position); + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); - // Condition state.position === state.lineStart is tested - // in parent on each call, for efficiency. No needs to test here again. - if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && - ch === state.input.charCodeAt(_position + 1) && - ch === state.input.charCodeAt(_position + 2)) { + case errorTag: + return object.name == other.name && object.message == other.message; - _position += 3; + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); - ch = state.input.charCodeAt(_position); + case mapTag: + var convert = mapToArray; - if (ch === 0 || is_WS_OR_EOL(ch)) { - return true; - } - } + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert || (convert = setToArray); - return false; -} + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; -function writeFoldedLines(state, count) { - if (count === 1) { - state.result += ' '; - } else if (count > 1) { - state.result += common.repeat('\n', count - 1); - } -} + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; + } -function readPlainScalar(state, nodeIndent, withinFlowCollection) { - var preceding, - following, - captureStart, - captureEnd, - hasPendingContent, - _line, - _lineStart, - _lineIndent, - _kind = state.kind, - _result = state.result, - ch; + /** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; - ch = state.input.charCodeAt(state.position); + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + // Check that cyclic values are equal. + var objStacked = stack.get(object); + var othStacked = stack.get(other); + if (objStacked && othStacked) { + return objStacked == other && othStacked == object; + } + var result = true; + stack.set(object, other); + stack.set(other, object); - if (is_WS_OR_EOL(ch) || - is_FLOW_INDICATOR(ch) || - ch === 0x23/* # */ || - ch === 0x26/* & */ || - ch === 0x2A/* * */ || - ch === 0x21/* ! */ || - ch === 0x7C/* | */ || - ch === 0x3E/* > */ || - ch === 0x27/* ' */ || - ch === 0x22/* " */ || - ch === 0x25/* % */ || - ch === 0x40/* @ */ || - ch === 0x60/* ` */) { - return false; - } + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; - if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { - following = state.input.charCodeAt(state.position + 1); + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; - if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - return false; + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } + } + stack['delete'](object); + stack['delete'](other); + return result; } - } - - state.kind = 'scalar'; - state.result = ''; - captureStart = captureEnd = state.position; - hasPendingContent = false; - - while (ch !== 0) { - if (ch === 0x3A/* : */) { - following = state.input.charCodeAt(state.position + 1); - if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - break; - } + /** + * A specialized version of `baseRest` which flattens the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. + */ + function flatRest(func) { + return setToString(overRest(func, undefined, flatten), func + ''); + } - } else if (ch === 0x23/* # */) { - preceding = state.input.charCodeAt(state.position - 1); + /** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); + } - if (is_WS_OR_EOL(preceding)) { - break; - } + /** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn, getSymbolsIn); + } - } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || - withinFlowCollection && is_FLOW_INDICATOR(ch)) { - break; + /** + * Gets metadata for `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. + */ + var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); + }; - } else if (is_EOL(ch)) { - _line = state.line; - _lineStart = state.lineStart; - _lineIndent = state.lineIndent; - skipSeparationSpace(state, false, -1); + /** + * Gets the name of `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {string} Returns the function name. + */ + function getFuncName(func) { + var result = (func.name + ''), + array = realNames[result], + length = hasOwnProperty.call(realNames, result) ? array.length : 0; - if (state.lineIndent >= nodeIndent) { - hasPendingContent = true; - ch = state.input.charCodeAt(state.position); - continue; - } else { - state.position = captureEnd; - state.line = _line; - state.lineStart = _lineStart; - state.lineIndent = _lineIndent; - break; + while (length--) { + var data = array[length], + otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; + } } + return result; } - if (hasPendingContent) { - captureSegment(state, captureStart, captureEnd, false); - writeFoldedLines(state, state.line - _line); - captureStart = captureEnd = state.position; - hasPendingContent = false; + /** + * Gets the argument placeholder value for `func`. + * + * @private + * @param {Function} func The function to inspect. + * @returns {*} Returns the placeholder value. + */ + function getHolder(func) { + var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; + return object.placeholder; } - if (!is_WHITE_SPACE(ch)) { - captureEnd = state.position + 1; + /** + * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, + * this function returns the custom method, otherwise it returns `baseIteratee`. + * If arguments are provided, the chosen function is invoked with them and + * its result is returned. + * + * @private + * @param {*} [value] The value to convert to an iteratee. + * @param {number} [arity] The arity of the created iteratee. + * @returns {Function} Returns the chosen function or its result. + */ + function getIteratee() { + var result = lodash.iteratee || iteratee; + result = result === iteratee ? baseIteratee : result; + return arguments.length ? result(arguments[0], arguments[1]) : result; } - ch = state.input.charCodeAt(++state.position); - } - - captureSegment(state, captureStart, captureEnd, false); - - if (state.result) { - return true; - } + /** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ + function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; + } - state.kind = _kind; - state.result = _result; - return false; -} + /** + * Gets the property names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ + function getMatchData(object) { + var result = keys(object), + length = result.length; -function readSingleQuotedScalar(state, nodeIndent) { - var ch, - captureStart, captureEnd; + while (length--) { + var key = result[length], + value = object[key]; - ch = state.input.charCodeAt(state.position); + result[length] = [key, value, isStrictComparable(value)]; + } + return result; + } - if (ch !== 0x27/* ' */) { - return false; - } + /** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ + function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; + } - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; + /** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ + function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x27/* ' */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} - if (ch === 0x27/* ' */) { - captureStart = state.position; - state.position++; - captureEnd = state.position; - } else { - return true; + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } } - - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a single quoted scalar'); - - } else { - state.position++; - captureEnd = state.position; + return result; } - } - throwError(state, 'unexpected end of the stream within a single quoted scalar'); -} - -function readDoubleQuotedScalar(state, nodeIndent) { - var captureStart, - captureEnd, - hexLength, - hexResult, - tmp, - ch; + /** + * Creates an array of the own enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); + }; - ch = state.input.charCodeAt(state.position); + /** + * Creates an array of the own and inherited enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; + }; - if (ch !== 0x22/* " */) { - return false; - } + /** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + var getTag = baseGetTag; - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; + // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. + if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || + (Set && getTag(new Set) != setTag) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = baseGetTag(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x22/* " */) { - captureSegment(state, captureStart, state.position, true); - state.position++; - return true; + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; + } - } else if (ch === 0x5C/* \ */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); + /** + * Gets the view, applying any `transforms` to the `start` and `end` positions. + * + * @private + * @param {number} start The start of the view. + * @param {number} end The end of the view. + * @param {Array} transforms The transformations to apply to the view. + * @returns {Object} Returns an object containing the `start` and `end` + * positions of the view. + */ + function getView(start, end, transforms) { + var index = -1, + length = transforms.length; - if (is_EOL(ch)) { - skipSeparationSpace(state, false, nodeIndent); + while (++index < length) { + var data = transforms[index], + size = data.size; - // TODO: rework to inline fn with no type cast? - } else if (ch < 256 && simpleEscapeCheck[ch]) { - state.result += simpleEscapeMap[ch]; - state.position++; + switch (data.type) { + case 'drop': start += size; break; + case 'dropRight': end -= size; break; + case 'take': end = nativeMin(end, start + size); break; + case 'takeRight': start = nativeMax(start, end - size); break; + } + } + return { 'start': start, 'end': end }; + } - } else if ((tmp = escapedHexLen(ch)) > 0) { - hexLength = tmp; - hexResult = 0; + /** + * Extracts wrapper details from the `source` body comment. + * + * @private + * @param {string} source The source to inspect. + * @returns {Array} Returns the wrapper details. + */ + function getWrapDetails(source) { + var match = source.match(reWrapDetails); + return match ? match[1].split(reSplitDetails) : []; + } - for (; hexLength > 0; hexLength--) { - ch = state.input.charCodeAt(++state.position); + /** + * Checks if `path` exists on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @param {Function} hasFunc The function to check properties. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + */ + function hasPath(object, path, hasFunc) { + path = castPath(path, object); - if ((tmp = fromHexCode(ch)) >= 0) { - hexResult = (hexResult << 4) + tmp; + var index = -1, + length = path.length, + result = false; - } else { - throwError(state, 'expected hexadecimal character'); - } + while (++index < length) { + var key = toKey(path[index]); + if (!(result = object != null && hasFunc(object, key))) { + break; } + object = object[key]; + } + if (result || ++index != length) { + return result; + } + length = object == null ? 0 : object.length; + return !!length && isLength(length) && isIndex(key, length) && + (isArray(object) || isArguments(object)); + } - state.result += charFromCodepoint(hexResult); - - state.position++; + /** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ + function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); - } else { - throwError(state, 'unknown escape sequence'); + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { + result.index = array.index; + result.input = array.input; } + return result; + } - captureStart = captureEnd = state.position; - - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; + /** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneObject(object) { + return (typeof object.constructor == 'function' && !isPrototype(object)) + ? baseCreate(getPrototype(object)) + : {}; + } - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a double quoted scalar'); + /** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return cloneArrayBuffer(object); - } else { - state.position++; - captureEnd = state.position; - } - } + case boolTag: + case dateTag: + return new Ctor(+object); - throwError(state, 'unexpected end of the stream within a double quoted scalar'); -} + case dataViewTag: + return cloneDataView(object, isDeep); -function readFlowCollection(state, nodeIndent) { - var readNext = true, - _line, - _lineStart, - _pos, - _tag = state.tag, - _result, - _anchor = state.anchor, - following, - terminator, - isPair, - isExplicitPair, - isMapping, - overridableKeys = Object.create(null), - keyNode, - keyTag, - valueNode, - ch; + case float32Tag: case float64Tag: + case int8Tag: case int16Tag: case int32Tag: + case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: + return cloneTypedArray(object, isDeep); - ch = state.input.charCodeAt(state.position); + case mapTag: + return new Ctor; - if (ch === 0x5B/* [ */) { - terminator = 0x5D;/* ] */ - isMapping = false; - _result = []; - } else if (ch === 0x7B/* { */) { - terminator = 0x7D;/* } */ - isMapping = true; - _result = {}; - } else { - return false; - } + case numberTag: + case stringTag: + return new Ctor(object); - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } + case regexpTag: + return cloneRegExp(object); - ch = state.input.charCodeAt(++state.position); + case setTag: + return new Ctor; - while (ch !== 0) { - skipSeparationSpace(state, true, nodeIndent); + case symbolTag: + return cloneSymbol(object); + } + } - ch = state.input.charCodeAt(state.position); + /** + * Inserts wrapper `details` in a comment at the top of the `source` body. + * + * @private + * @param {string} source The source to modify. + * @returns {Array} details The details to insert. + * @returns {string} Returns the modified source. + */ + function insertWrapDetails(source, details) { + var length = details.length; + if (!length) { + return source; + } + var lastIndex = length - 1; + details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; + details = details.join(length > 2 ? ', ' : ' '); + return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); + } - if (ch === terminator) { - state.position++; - state.tag = _tag; - state.anchor = _anchor; - state.kind = isMapping ? 'mapping' : 'sequence'; - state.result = _result; - return true; - } else if (!readNext) { - throwError(state, 'missed comma between flow collection entries'); - } else if (ch === 0x2C/* , */) { - // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 - throwError(state, "expected the node content, but found ','"); + /** + * Checks if `value` is a flattenable `arguments` object or array. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ + function isFlattenable(value) { + return isArray(value) || isArguments(value) || + !!(spreadableSymbol && value && value[spreadableSymbol]); } - keyTag = keyNode = valueNode = null; - isPair = isExplicitPair = false; + /** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ + function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; - if (ch === 0x3F/* ? */) { - following = state.input.charCodeAt(state.position + 1); + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); + } - if (is_WS_OR_EOL(following)) { - isPair = isExplicitPair = true; - state.position++; - skipSeparationSpace(state, true, nodeIndent); + /** + * Checks if the given arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. + */ + function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { + return eq(object[index], value); } + return false; } - _line = state.line; // Save the current line. - _lineStart = state.lineStart; - _pos = state.position; - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - keyTag = state.tag; - keyNode = state.result; - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { - isPair = true; - ch = state.input.charCodeAt(++state.position); - skipSeparationSpace(state, true, nodeIndent); - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - valueNode = state.result; + /** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ + function isKey(value, object) { + if (isArray(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); } - if (isMapping) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); - } else if (isPair) { - _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); - } else { - _result.push(keyNode); + /** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ + function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); } - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); + /** + * Checks if `func` has a lazy counterpart. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` has a lazy counterpart, + * else `false`. + */ + function isLaziable(func) { + var funcName = getFuncName(func), + other = lodash[funcName]; - if (ch === 0x2C/* , */) { - readNext = true; - ch = state.input.charCodeAt(++state.position); - } else { - readNext = false; + if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { + return false; + } + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; } - } - throwError(state, 'unexpected end of the stream within a flow collection'); -} - -function readBlockScalar(state, nodeIndent) { - var captureStart, - folding, - chomping = CHOMPING_CLIP, - didReadContent = false, - detectedIndent = false, - textIndent = nodeIndent, - emptyLines = 0, - atMoreIndented = false, - tmp, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x7C/* | */) { - folding = false; - } else if (ch === 0x3E/* > */) { - folding = true; - } else { - return false; - } + /** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ + function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); + } - state.kind = 'scalar'; - state.result = ''; + /** + * Checks if `func` is capable of being masked. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `func` is maskable, else `false`. + */ + var isMaskable = coreJsData ? isFunction : stubFalse; - while (ch !== 0) { - ch = state.input.charCodeAt(++state.position); + /** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ + function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { - if (CHOMPING_CLIP === chomping) { - chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; - } else { - throwError(state, 'repeat of a chomping mode identifier'); - } + return value === proto; + } - } else if ((tmp = fromDecimalCode(ch)) >= 0) { - if (tmp === 0) { - throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); - } else if (!detectedIndent) { - textIndent = nodeIndent + tmp - 1; - detectedIndent = true; - } else { - throwError(state, 'repeat of an indentation width identifier'); - } + /** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ + function isStrictComparable(value) { + return value === value && !isObject(value); + } - } else { - break; + /** + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. + * + * @private + * @param {string} key The key of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ + function matchesStrictComparable(key, srcValue) { + return function(object) { + if (object == null) { + return false; + } + return object[key] === srcValue && + (srcValue !== undefined || (key in Object(object))); + }; } - } - if (is_WHITE_SPACE(ch)) { - do { ch = state.input.charCodeAt(++state.position); } - while (is_WHITE_SPACE(ch)); + /** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ + function memoizeCapped(func) { + var result = memoize(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (!is_EOL(ch) && (ch !== 0)); + var cache = result.cache; + return result; } - } - while (ch !== 0) { - readLineBreak(state); - state.lineIndent = 0; - - ch = state.input.charCodeAt(state.position); + /** + * Merges the function metadata of `source` into `data`. + * + * Merging metadata reduces the number of wrappers used to invoke a function. + * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` + * may be applied regardless of execution order. Methods like `_.ary` and + * `_.rearg` modify function arguments, making the order in which they are + * executed important, preventing the merging of metadata. However, we make + * an exception for a safe combined case where curried functions have `_.ary` + * and or `_.rearg` applied. + * + * @private + * @param {Array} data The destination metadata. + * @param {Array} source The source metadata. + * @returns {Array} Returns `data`. + */ + function mergeData(data, source) { + var bitmask = data[1], + srcBitmask = source[1], + newBitmask = bitmask | srcBitmask, + isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); - while ((!detectedIndent || state.lineIndent < textIndent) && - (ch === 0x20/* Space */)) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } + var isCombo = + ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || + ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || + ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); - if (!detectedIndent && state.lineIndent > textIndent) { - textIndent = state.lineIndent; - } + // Exit early if metadata can't be merged. + if (!(isCommon || isCombo)) { + return data; + } + // Use source `thisArg` if available. + if (srcBitmask & WRAP_BIND_FLAG) { + data[2] = source[2]; + // Set when currying a bound function. + newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; + } + // Compose partial arguments. + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : value; + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; + } + // Compose partial right arguments. + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; + } + // Use source `argPos` if available. + value = source[7]; + if (value) { + data[7] = value; + } + // Use source `ary` if it's smaller. + if (srcBitmask & WRAP_ARY_FLAG) { + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + // Use source `arity` if one is not provided. + if (data[9] == null) { + data[9] = source[9]; + } + // Use source `func` and merge bitmasks. + data[0] = source[0]; + data[1] = newBitmask; - if (is_EOL(ch)) { - emptyLines++; - continue; + return data; } - // End of the scalar. - if (state.lineIndent < textIndent) { - - // Perform the chomping. - if (chomping === CHOMPING_KEEP) { - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - } else if (chomping === CHOMPING_CLIP) { - if (didReadContent) { // i.e. only if the scalar is not empty. - state.result += '\n'; + /** + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); } } - - // Break this `while` cycle and go to the funciton's epilogue. - break; + return result; } - // Folded style: use fancy rules to handle line breaks. - if (folding) { - - // Lines starting with white space characters (more-indented lines) are not folded. - if (is_WHITE_SPACE(ch)) { - atMoreIndented = true; - // except for the first content line (cf. Example 8.1) - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + /** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ + function objectToString(value) { + return nativeObjectToString.call(value); + } - // End of more-indented block. - } else if (atMoreIndented) { - atMoreIndented = false; - state.result += common.repeat('\n', emptyLines + 1); + /** + * A specialized version of `baseRest` which transforms the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @param {Function} transform The rest array transform. + * @returns {Function} Returns the new function. + */ + function overRest(func, start, transform) { + start = nativeMax(start === undefined ? (func.length - 1) : start, 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + array = Array(length); - // Just one line break - perceive as the same line. - } else if (emptyLines === 0) { - if (didReadContent) { // i.e. only if we have already read some scalar content. - state.result += ' '; + while (++index < length) { + array[index] = args[start + index]; } + index = -1; + var otherArgs = Array(start + 1); + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = transform(array); + return apply(func, this, otherArgs); + }; + } - // Several line breaks - perceive as different lines. - } else { - state.result += common.repeat('\n', emptyLines); - } - - // Literal style: just add exact number of line breaks between content lines. - } else { - // Keep all line breaks except the header line break. - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + /** + * Gets the parent value at `path` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} path The path to get the parent value of. + * @returns {*} Returns the parent value. + */ + function parent(object, path) { + return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); } - didReadContent = true; - detectedIndent = true; - emptyLines = 0; - captureStart = state.position; + /** + * Reorder `array` according to the specified indexes where the element at + * the first index is assigned as the first element, the element at + * the second index is assigned as the second element, and so on. + * + * @private + * @param {Array} array The array to reorder. + * @param {Array} indexes The arranged array indexes. + * @returns {Array} Returns `array`. + */ + function reorder(array, indexes) { + var arrLength = array.length, + length = nativeMin(indexes.length, arrLength), + oldArray = copyArray(array); - while (!is_EOL(ch) && (ch !== 0)) { - ch = state.input.charCodeAt(++state.position); + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; + } + return array; } - captureSegment(state, captureStart, state.position, false); - } + /** + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; + } - return true; -} + if (key == '__proto__') { + return; + } -function readBlockSequence(state, nodeIndent) { - var _line, - _tag = state.tag, - _anchor = state.anchor, - _result = [], - following, - detected = false, - ch; + return object[key]; + } - // there is a leading tab before this token, so it can't be a block sequence/mapping; - // it can still be flow sequence/mapping or a scalar - if (state.firstTabInLine !== -1) return false; + /** + * Sets metadata for `func`. + * + * **Note:** If this function becomes hot, i.e. is invoked a lot in a short + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses in V8. See + * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) + * for more details. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var setData = shortOut(baseSetData); - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } + /** + * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @returns {number|Object} Returns the timer id or timeout object. + */ + var setTimeout = ctxSetTimeout || function(func, wait) { + return root.setTimeout(func, wait); + }; - ch = state.input.charCodeAt(state.position); + /** + * Sets the `toString` method of `func` to return `string`. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ + var setToString = shortOut(baseSetToString); - while (ch !== 0) { - if (state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, 'tab characters must not be used in indentation'); + /** + * Sets the `toString` method of `wrapper` to mimic the source of `reference` + * with wrapper details in a comment at the top of the source body. + * + * @private + * @param {Function} wrapper The function to modify. + * @param {Function} reference The reference function. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Function} Returns `wrapper`. + */ + function setWrapToString(wrapper, reference, bitmask) { + var source = (reference + ''); + return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); } - if (ch !== 0x2D/* - */) { - break; - } + /** + * Creates a function that'll short out and invoke `identity` instead + * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` + * milliseconds. + * + * @private + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new shortable function. + */ + function shortOut(func) { + var count = 0, + lastCalled = 0; - following = state.input.charCodeAt(state.position + 1); + return function() { + var stamp = nativeNow(), + remaining = HOT_SPAN - (stamp - lastCalled); - if (!is_WS_OR_EOL(following)) { - break; + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return arguments[0]; + } + } else { + count = 0; + } + return func.apply(undefined, arguments); + }; } - detected = true; - state.position++; + /** + * A specialized version of `_.shuffle` which mutates and sets the size of `array`. + * + * @private + * @param {Array} array The array to shuffle. + * @param {number} [size=array.length] The size of `array`. + * @returns {Array} Returns `array`. + */ + function shuffleSelf(array, size) { + var index = -1, + length = array.length, + lastIndex = length - 1; - if (skipSeparationSpace(state, true, -1)) { - if (state.lineIndent <= nodeIndent) { - _result.push(null); - ch = state.input.charCodeAt(state.position); - continue; + size = size === undefined ? length : size; + while (++index < size) { + var rand = baseRandom(index, lastIndex), + value = array[rand]; + + array[rand] = array[index]; + array[index] = value; } + array.length = size; + return array; } - _line = state.line; - composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); - _result.push(state.result); - skipSeparationSpace(state, true, -1); - - ch = state.input.charCodeAt(state.position); + /** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ + var stringToPath = memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; + }); - if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError(state, 'bad indentation of a sequence entry'); - } else if (state.lineIndent < nodeIndent) { - break; + /** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ + function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } - } - - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'sequence'; - state.result = _result; - return true; - } - return false; -} - -function readBlockMapping(state, nodeIndent, flowIndent) { - var following, - allowCompact, - _line, - _keyLine, - _keyLineStart, - _keyPos, - _tag = state.tag, - _anchor = state.anchor, - _result = {}, - overridableKeys = Object.create(null), - keyTag = null, - keyNode = null, - valueNode = null, - atExplicitKey = false, - detected = false, - ch; - - // there is a leading tab before this token, so it can't be a block sequence/mapping; - // it can still be flow sequence/mapping or a scalar - if (state.firstTabInLine !== -1) return false; - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(state.position); - while (ch !== 0) { - if (!atExplicitKey && state.firstTabInLine !== -1) { - state.position = state.firstTabInLine; - throwError(state, 'tab characters must not be used in indentation'); + /** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ + function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; } - following = state.input.charCodeAt(state.position + 1); - _line = state.line; // Save the current line. - - // - // Explicit notation case. There are two separate blocks: - // first for the key (denoted by "?") and second for the value (denoted by ":") - // - if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { - - if (ch === 0x3F/* ? */) { - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; + /** + * Updates wrapper `details` based on `bitmask` flags. + * + * @private + * @returns {Array} details The details to modify. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Array} Returns `details`. + */ + function updateWrapDetails(details, bitmask) { + arrayEach(wrapFlags, function(pair) { + var value = '_.' + pair[0]; + if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { + details.push(value); } + }); + return details.sort(); + } - detected = true; - atExplicitKey = true; - allowCompact = true; + /** + * Creates a clone of `wrapper`. + * + * @private + * @param {Object} wrapper The wrapper to clone. + * @returns {Object} Returns the cloned wrapper. + */ + function wrapperClone(wrapper) { + if (wrapper instanceof LazyWrapper) { + return wrapper.clone(); + } + var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); + result.__actions__ = copyArray(wrapper.__actions__); + result.__index__ = wrapper.__index__; + result.__values__ = wrapper.__values__; + return result; + } - } else if (atExplicitKey) { - // i.e. 0x3A/* : */ === character after the explicit key. - atExplicitKey = false; - allowCompact = true; + /*------------------------------------------------------------------------*/ + /** + * Creates an array of elements split into groups the length of `size`. + * If `array` can't be split evenly, the final chunk will be the remaining + * elements. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to process. + * @param {number} [size=1] The length of each chunk + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the new array of chunks. + * @example + * + * _.chunk(['a', 'b', 'c', 'd'], 2); + * // => [['a', 'b'], ['c', 'd']] + * + * _.chunk(['a', 'b', 'c', 'd'], 3); + * // => [['a', 'b', 'c'], ['d']] + */ + function chunk(array, size, guard) { + if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { + size = 1; } else { - throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + size = nativeMax(toInteger(size), 0); } + var length = array == null ? 0 : array.length; + if (!length || size < 1) { + return []; + } + var index = 0, + resIndex = 0, + result = Array(nativeCeil(length / size)); - state.position += 1; - ch = following; - - // - // Implicit notation case. Flow-style node as the key first, then ":", and the value. - // - } else { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; - - if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { - // Neither implicit nor explicit notation. - // Reading is done. Go to the epilogue. - break; + while (index < length) { + result[resIndex++] = baseSlice(array, index, (index += size)); } + return result; + } - if (state.line === _line) { - ch = state.input.charCodeAt(state.position); + /** + * Creates an array with all falsey values removed. The values `false`, `null`, + * `0`, `""`, `undefined`, and `NaN` are falsey. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to compact. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.compact([0, 1, false, 2, '', 3]); + * // => [1, 2, 3] + */ + function compact(array) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); + while (++index < length) { + var value = array[index]; + if (value) { + result[resIndex++] = value; } + } + return result; + } - if (ch === 0x3A/* : */) { - ch = state.input.charCodeAt(++state.position); - - if (!is_WS_OR_EOL(ch)) { - throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); - } - - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; - } + /** + * Creates a new array concatenating `array` with any additional arrays + * and/or values. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to concatenate. + * @param {...*} [values] The values to concatenate. + * @returns {Array} Returns the new concatenated array. + * @example + * + * var array = [1]; + * var other = _.concat(array, 2, [3], [[4]]); + * + * console.log(other); + * // => [1, 2, 3, [4]] + * + * console.log(array); + * // => [1] + */ + function concat() { + var length = arguments.length; + if (!length) { + return []; + } + var args = Array(length - 1), + array = arguments[0], + index = length; - detected = true; - atExplicitKey = false; - allowCompact = false; - keyTag = state.tag; - keyNode = state.result; + while (index--) { + args[index - 1] = arguments[index]; + } + return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); + } - } else if (detected) { - throwError(state, 'can not read an implicit mapping pair; a colon is missed'); + /** + * Creates an array of `array` values not included in the other given arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. The order and references of result values are + * determined by the first array. + * + * **Note:** Unlike `_.pullAll`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @see _.without, _.xor + * @example + * + * _.difference([2, 1], [2, 3]); + * // => [1] + */ + var difference = baseRest(function(array, values) { + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) + : []; + }); - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. - } + /** + * This method is like `_.difference` except that it accepts `iteratee` which + * is invoked for each element of `array` and `values` to generate the criterion + * by which they're compared. The order and references of result values are + * determined by the first array. The iteratee is invoked with one argument: + * (value). + * + * **Note:** Unlike `_.pullAllBy`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [1.2] + * + * // The `_.property` iteratee shorthand. + * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] + */ + var differenceBy = baseRest(function(array, values) { + var iteratee = last(values); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) + : []; + }); - } else if (detected) { - throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); + /** + * This method is like `_.difference` except that it accepts `comparator` + * which is invoked to compare elements of `array` to `values`. The order and + * references of result values are determined by the first array. The comparator + * is invoked with two arguments: (arrVal, othVal). + * + * **Note:** Unlike `_.pullAllWith`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * + * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); + * // => [{ 'x': 2, 'y': 1 }] + */ + var differenceWith = baseRest(function(array, values) { + var comparator = last(values); + if (isArrayLikeObject(comparator)) { + comparator = undefined; + } + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) + : []; + }); - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. + /** + * Creates a slice of `array` with `n` elements dropped from the beginning. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.drop([1, 2, 3]); + * // => [2, 3] + * + * _.drop([1, 2, 3], 2); + * // => [3] + * + * _.drop([1, 2, 3], 5); + * // => [] + * + * _.drop([1, 2, 3], 0); + * // => [1, 2, 3] + */ + function drop(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; } + n = (guard || n === undefined) ? 1 : toInteger(n); + return baseSlice(array, n < 0 ? 0 : n, length); } - // - // Common reading code for both explicit and implicit notations. - // - if (state.line === _line || state.lineIndent > nodeIndent) { - if (atExplicitKey) { - _keyLine = state.line; - _keyLineStart = state.lineStart; - _keyPos = state.position; - } - - if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { - if (atExplicitKey) { - keyNode = state.result; - } else { - valueNode = state.result; - } - } - - if (!atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); - keyTag = keyNode = valueNode = null; + /** + * Creates a slice of `array` with `n` elements dropped from the end. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.dropRight([1, 2, 3]); + * // => [1, 2] + * + * _.dropRight([1, 2, 3], 2); + * // => [1] + * + * _.dropRight([1, 2, 3], 5); + * // => [] + * + * _.dropRight([1, 2, 3], 0); + * // => [1, 2, 3] + */ + function dropRight(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; } - - skipSeparationSpace(state, true, -1); - ch = state.input.charCodeAt(state.position); + n = (guard || n === undefined) ? 1 : toInteger(n); + n = length - n; + return baseSlice(array, 0, n < 0 ? 0 : n); } - if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError(state, 'bad indentation of a mapping entry'); - } else if (state.lineIndent < nodeIndent) { - break; + /** + * Creates a slice of `array` excluding elements dropped from the end. + * Elements are dropped until `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * _.dropRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney'] + * + * // The `_.matches` iteratee shorthand. + * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['barney', 'fred'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.dropRightWhile(users, ['active', false]); + * // => objects for ['barney'] + * + * // The `_.property` iteratee shorthand. + * _.dropRightWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] + */ + function dropRightWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), true, true) + : []; } - } - - // - // Epilogue. - // - - // Special case: last mapping's node contains only the key in explicit notation. - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); - } - - // Expose the resulting mapping. - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'mapping'; - state.result = _result; - } - - return detected; -} - -function readTagProperty(state) { - var _position, - isVerbatim = false, - isNamed = false, - tagHandle, - tagName, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x21/* ! */) return false; - - if (state.tag !== null) { - throwError(state, 'duplication of a tag property'); - } - - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x3C/* < */) { - isVerbatim = true; - ch = state.input.charCodeAt(++state.position); - - } else if (ch === 0x21/* ! */) { - isNamed = true; - tagHandle = '!!'; - ch = state.input.charCodeAt(++state.position); - - } else { - tagHandle = '!'; - } - - _position = state.position; - - if (isVerbatim) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && ch !== 0x3E/* > */); - if (state.position < state.length) { - tagName = state.input.slice(_position, state.position); - ch = state.input.charCodeAt(++state.position); - } else { - throwError(state, 'unexpected end of the stream within a verbatim tag'); + /** + * Creates a slice of `array` excluding elements dropped from the beginning. + * Elements are dropped until `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.dropWhile(users, function(o) { return !o.active; }); + * // => objects for ['pebbles'] + * + * // The `_.matches` iteratee shorthand. + * _.dropWhile(users, { 'user': 'barney', 'active': false }); + * // => objects for ['fred', 'pebbles'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.dropWhile(users, ['active', false]); + * // => objects for ['pebbles'] + * + * // The `_.property` iteratee shorthand. + * _.dropWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] + */ + function dropWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), true) + : []; } - } else { - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - - if (ch === 0x21/* ! */) { - if (!isNamed) { - tagHandle = state.input.slice(_position - 1, state.position + 1); - - if (!PATTERN_TAG_HANDLE.test(tagHandle)) { - throwError(state, 'named tag handle cannot contain such characters'); - } - isNamed = true; - _position = state.position + 1; - } else { - throwError(state, 'tag suffix cannot contain exclamation marks'); - } + /** + * Fills elements of `array` with `value` from `start` up to, but not + * including, `end`. + * + * **Note:** This method mutates `array`. + * + * @static + * @memberOf _ + * @since 3.2.0 + * @category Array + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3]; + * + * _.fill(array, 'a'); + * console.log(array); + * // => ['a', 'a', 'a'] + * + * _.fill(Array(3), 2); + * // => [2, 2, 2] + * + * _.fill([4, 6, 8, 10], '*', 1, 3); + * // => [4, '*', '*', 10] + */ + function fill(array, value, start, end) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; } - - ch = state.input.charCodeAt(++state.position); + if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { + start = 0; + end = length; + } + return baseFill(array, value, start, end); } - tagName = state.input.slice(_position, state.position); - - if (PATTERN_FLOW_INDICATORS.test(tagName)) { - throwError(state, 'tag suffix cannot contain flow indicator characters'); + /** + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.findIndex(users, function(o) { return o.user == 'barney'; }); + * // => 0 + * + * // The `_.matches` iteratee shorthand. + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findIndex(users, ['active', false]); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.findIndex(users, 'active'); + * // => 2 + */ + function findIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax(length + index, 0); + } + return baseFindIndex(array, getIteratee(predicate, 3), index); } - } - - if (tagName && !PATTERN_TAG_URI.test(tagName)) { - throwError(state, 'tag name cannot contain such characters: ' + tagName); - } - - try { - tagName = decodeURIComponent(tagName); - } catch (err) { - throwError(state, 'tag name is malformed: ' + tagName); - } - - if (isVerbatim) { - state.tag = tagName; - - } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { - state.tag = state.tagMap[tagHandle] + tagName; - - } else if (tagHandle === '!') { - state.tag = '!' + tagName; - - } else if (tagHandle === '!!') { - state.tag = 'tag:yaml.org,2002:' + tagName; - - } else { - throwError(state, 'undeclared tag handle "' + tagHandle + '"'); - } - - return true; -} - -function readAnchorProperty(state) { - var _position, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x26/* & */) return false; - - if (state.anchor !== null) { - throwError(state, 'duplication of an anchor property'); - } - - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (state.position === _position) { - throwError(state, 'name of an anchor node must contain at least one character'); - } - - state.anchor = state.input.slice(_position, state.position); - return true; -} - -function readAlias(state) { - var _position, alias, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x2A/* * */) return false; - - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (state.position === _position) { - throwError(state, 'name of an alias node must contain at least one character'); - } - - alias = state.input.slice(_position, state.position); - - if (!_hasOwnProperty.call(state.anchorMap, alias)) { - throwError(state, 'unidentified alias "' + alias + '"'); - } - - state.result = state.anchorMap[alias]; - skipSeparationSpace(state, true, -1); - return true; -} - -function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { - var allowBlockStyles, - allowBlockScalars, - allowBlockCollections, - indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this 2 + * + * // The `_.matches` iteratee shorthand. + * _.findLastIndex(users, { 'user': 'barney', 'active': true }); + * // => 0 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findLastIndex(users, ['active', false]); + * // => 2 + * + * // The `_.property` iteratee shorthand. + * _.findLastIndex(users, 'active'); + * // => 0 + */ + function findLastIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = length - 1; + if (fromIndex !== undefined) { + index = toInteger(fromIndex); + index = fromIndex < 0 + ? nativeMax(length + index, 0) + : nativeMin(index, length - 1); + } + return baseFindIndex(array, getIteratee(predicate, 3), index, true); + } - allowBlockStyles = allowBlockScalars = allowBlockCollections = - CONTEXT_BLOCK_OUT === nodeContext || - CONTEXT_BLOCK_IN === nodeContext; + /** + * Flattens `array` a single level deep. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flatten([1, [2, [3, [4]], 5]]); + * // => [1, 2, [3, [4]], 5] + */ + function flatten(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array, 1) : []; + } - if (allowToSeek) { - if (skipSeparationSpace(state, true, -1)) { - atNewLine = true; + /** + * Recursively flattens `array`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flattenDeep([1, [2, [3, [4]], 5]]); + * // => [1, 2, 3, 4, 5] + */ + function flattenDeep(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array, INFINITY) : []; + } - if (state.lineIndent > parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; + /** + * Recursively flatten `array` up to `depth` times. + * + * @static + * @memberOf _ + * @since 4.4.0 + * @category Array + * @param {Array} array The array to flatten. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. + * @example + * + * var array = [1, [2, [3, [4]], 5]]; + * + * _.flattenDepth(array, 1); + * // => [1, 2, [3, [4]], 5] + * + * _.flattenDepth(array, 2); + * // => [1, 2, 3, [4], 5] + */ + function flattenDepth(array, depth) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; } + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(array, depth); } - } - if (indentStatus === 1) { - while (readTagProperty(state) || readAnchorProperty(state)) { - if (skipSeparationSpace(state, true, -1)) { - atNewLine = true; - allowBlockCollections = allowBlockStyles; + /** + * The inverse of `_.toPairs`; this method returns an object composed + * from key-value `pairs`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} pairs The key-value pairs. + * @returns {Object} Returns the new object. + * @example + * + * _.fromPairs([['a', 1], ['b', 2]]); + * // => { 'a': 1, 'b': 2 } + */ + function fromPairs(pairs) { + var index = -1, + length = pairs == null ? 0 : pairs.length, + result = {}; - if (state.lineIndent > parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; - } - } else { - allowBlockCollections = false; + while (++index < length) { + var pair = pairs[index]; + result[pair[0]] = pair[1]; } + return result; } - } - - if (allowBlockCollections) { - allowBlockCollections = atNewLine || allowCompact; - } - if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { - if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { - flowIndent = parentIndent; - } else { - flowIndent = parentIndent + 1; + /** + * Gets the first element of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @alias first + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the first element of `array`. + * @example + * + * _.head([1, 2, 3]); + * // => 1 + * + * _.head([]); + * // => undefined + */ + function head(array) { + return (array && array.length) ? array[0] : undefined; } - blockIndent = state.position - state.lineStart; - - if (indentStatus === 1) { - if (allowBlockCollections && - (readBlockSequence(state, blockIndent) || - readBlockMapping(state, blockIndent, flowIndent)) || - readFlowCollection(state, flowIndent)) { - hasContent = true; - } else { - if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || - readSingleQuotedScalar(state, flowIndent) || - readDoubleQuotedScalar(state, flowIndent)) { - hasContent = true; - - } else if (readAlias(state)) { - hasContent = true; - - if (state.tag !== null || state.anchor !== null) { - throwError(state, 'alias node should not have any properties'); - } - - } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { - hasContent = true; - - if (state.tag === null) { - state.tag = '?'; - } - } - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } + /** + * Gets the index at which the first occurrence of `value` is found in `array` + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it's used as the + * offset from the end of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.indexOf([1, 2, 1, 2], 2); + * // => 1 + * + * // Search from the `fromIndex`. + * _.indexOf([1, 2, 1, 2], 2, 2); + * // => 3 + */ + function indexOf(array, value, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; } - } else if (indentStatus === 0) { - // Special case: block sequences are allowed to have same indentation level as the parent. - // http://www.yaml.org/spec/1.2/spec.html#id2799784 - hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax(length + index, 0); + } + return baseIndexOf(array, value, index); } - } - if (state.tag === null) { - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; + /** + * Gets all but the last element of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.initial([1, 2, 3]); + * // => [1, 2] + */ + function initial(array) { + var length = array == null ? 0 : array.length; + return length ? baseSlice(array, 0, -1) : []; } - } else if (state.tag === '?') { - // Implicit resolving is not allowed for non-scalar types, and '?' - // non-specific tag is only automatically assigned to plain scalars. - // - // We only need to check kind conformity in case user explicitly assigns '?' - // tag, for example like this: "! [0]" - // - if (state.result !== null && state.kind !== 'scalar') { - throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); - } + /** + * Creates an array of unique values that are included in all given arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. The order and references of result values are + * determined by the first array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of intersecting values. + * @example + * + * _.intersection([2, 1], [2, 3]); + * // => [2] + */ + var intersection = baseRest(function(arrays) { + var mapped = arrayMap(arrays, castArrayLikeObject); + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped) + : []; + }); - for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { - type = state.implicitTypes[typeIndex]; + /** + * This method is like `_.intersection` except that it accepts `iteratee` + * which is invoked for each element of each `arrays` to generate the criterion + * by which they're compared. The order and references of result values are + * determined by the first array. The iteratee is invoked with one argument: + * (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of intersecting values. + * @example + * + * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [2.1] + * + * // The `_.property` iteratee shorthand. + * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }] + */ + var intersectionBy = baseRest(function(arrays) { + var iteratee = last(arrays), + mapped = arrayMap(arrays, castArrayLikeObject); - if (type.resolve(state.result)) { // `state.result` updated in resolver if matched - state.result = type.construct(state.result); - state.tag = type.tag; - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - break; + if (iteratee === last(mapped)) { + iteratee = undefined; + } else { + mapped.pop(); } - } - } else if (state.tag !== '!') { - if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { - type = state.typeMap[state.kind || 'fallback'][state.tag]; - } else { - // looking for multi type - type = null; - typeList = state.typeMap.multi[state.kind || 'fallback']; + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped, getIteratee(iteratee, 2)) + : []; + }); - for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { - if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { - type = typeList[typeIndex]; - break; - } + /** + * This method is like `_.intersection` except that it accepts `comparator` + * which is invoked to compare elements of `arrays`. The order and references + * of result values are determined by the first array. The comparator is + * invoked with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of intersecting values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.intersectionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }] + */ + var intersectionWith = baseRest(function(arrays) { + var comparator = last(arrays), + mapped = arrayMap(arrays, castArrayLikeObject); + + comparator = typeof comparator == 'function' ? comparator : undefined; + if (comparator) { + mapped.pop(); } - } + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped, undefined, comparator) + : []; + }); - if (!type) { - throwError(state, 'unknown tag !<' + state.tag + '>'); + /** + * Converts all elements in `array` into a string separated by `separator`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to convert. + * @param {string} [separator=','] The element separator. + * @returns {string} Returns the joined string. + * @example + * + * _.join(['a', 'b', 'c'], '~'); + * // => 'a~b~c' + */ + function join(array, separator) { + return array == null ? '' : nativeJoin.call(array, separator); } - if (state.result !== null && type.kind !== state.kind) { - throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + /** + * Gets the last element of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + */ + function last(array) { + var length = array == null ? 0 : array.length; + return length ? array[length - 1] : undefined; } - if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched - throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); - } else { - state.result = type.construct(state.result, state.tag); - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; + /** + * This method is like `_.indexOf` except that it iterates over elements of + * `array` from right to left. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=array.length-1] The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.lastIndexOf([1, 2, 1, 2], 2); + * // => 3 + * + * // Search from the `fromIndex`. + * _.lastIndexOf([1, 2, 1, 2], 2, 2); + * // => 1 + */ + function lastIndexOf(array, value, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = length; + if (fromIndex !== undefined) { + index = toInteger(fromIndex); + index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); } + return value === value + ? strictLastIndexOf(array, value, index) + : baseFindIndex(array, baseIsNaN, index, true); } - } - - if (state.listener !== null) { - state.listener('close', state); - } - return state.tag !== null || state.anchor !== null || hasContent; -} - -function readDocument(state) { - var documentStart = state.position, - _position, - directiveName, - directiveArgs, - hasDirectives = false, - ch; - state.version = null; - state.checkLineBreaks = state.legacy; - state.tagMap = Object.create(null); - state.anchorMap = Object.create(null); + /** + * Gets the element at index `n` of `array`. If `n` is negative, the nth + * element from the end is returned. + * + * @static + * @memberOf _ + * @since 4.11.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=0] The index of the element to return. + * @returns {*} Returns the nth element of `array`. + * @example + * + * var array = ['a', 'b', 'c', 'd']; + * + * _.nth(array, 1); + * // => 'b' + * + * _.nth(array, -2); + * // => 'c'; + */ + function nth(array, n) { + return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; + } - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - skipSeparationSpace(state, true, -1); + /** + * Removes all given values from `array` using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` + * to remove elements from an array by predicate. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {...*} [values] The values to remove. + * @returns {Array} Returns `array`. + * @example + * + * var array = ['a', 'b', 'c', 'a', 'b', 'c']; + * + * _.pull(array, 'a', 'c'); + * console.log(array); + * // => ['b', 'b'] + */ + var pull = baseRest(pullAll); - ch = state.input.charCodeAt(state.position); + /** + * This method is like `_.pull` except that it accepts an array of values to remove. + * + * **Note:** Unlike `_.difference`, this method mutates `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @returns {Array} Returns `array`. + * @example + * + * var array = ['a', 'b', 'c', 'a', 'b', 'c']; + * + * _.pullAll(array, ['a', 'c']); + * console.log(array); + * // => ['b', 'b'] + */ + function pullAll(array, values) { + return (array && array.length && values && values.length) + ? basePullAll(array, values) + : array; + } - if (state.lineIndent > 0 || ch !== 0x25/* % */) { - break; + /** + * This method is like `_.pullAll` except that it accepts `iteratee` which is + * invoked for each element of `array` and `values` to generate the criterion + * by which they're compared. The iteratee is invoked with one argument: (value). + * + * **Note:** Unlike `_.differenceBy`, this method mutates `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns `array`. + * @example + * + * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; + * + * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); + * console.log(array); + * // => [{ 'x': 2 }] + */ + function pullAllBy(array, values, iteratee) { + return (array && array.length && values && values.length) + ? basePullAll(array, values, getIteratee(iteratee, 2)) + : array; } - hasDirectives = true; - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); + /** + * This method is like `_.pullAll` except that it accepts `comparator` which + * is invoked to compare elements of `array` to `values`. The comparator is + * invoked with two arguments: (arrVal, othVal). + * + * **Note:** Unlike `_.differenceWith`, this method mutates `array`. + * + * @static + * @memberOf _ + * @since 4.6.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns `array`. + * @example + * + * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; + * + * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); + * console.log(array); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] + */ + function pullAllWith(array, values, comparator) { + return (array && array.length && values && values.length) + ? basePullAll(array, values, undefined, comparator) + : array; } - directiveName = state.input.slice(_position, state.position); - directiveArgs = []; + /** + * Removes elements from `array` corresponding to `indexes` and returns an + * array of removed elements. + * + * **Note:** Unlike `_.at`, this method mutates `array`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {...(number|number[])} [indexes] The indexes of elements to remove. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = ['a', 'b', 'c', 'd']; + * var pulled = _.pullAt(array, [1, 3]); + * + * console.log(array); + * // => ['a', 'c'] + * + * console.log(pulled); + * // => ['b', 'd'] + */ + var pullAt = flatRest(function(array, indexes) { + var length = array == null ? 0 : array.length, + result = baseAt(array, indexes); - if (directiveName.length < 1) { - throwError(state, 'directive name must not be less than one character in length'); - } + basePullAt(array, arrayMap(indexes, function(index) { + return isIndex(index, length) ? +index : index; + }).sort(compareAscending)); - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); - } + return result; + }); - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && !is_EOL(ch)); - break; + /** + * Removes all elements from `array` that `predicate` returns truthy for + * and returns an array of the removed elements. The predicate is invoked + * with three arguments: (value, index, array). + * + * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` + * to pull elements from an array by value. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = [1, 2, 3, 4]; + * var evens = _.remove(array, function(n) { + * return n % 2 == 0; + * }); + * + * console.log(array); + * // => [1, 3] + * + * console.log(evens); + * // => [2, 4] + */ + function remove(array, predicate) { + var result = []; + if (!(array && array.length)) { + return result; } + var index = -1, + indexes = [], + length = array.length; - if (is_EOL(ch)) break; - - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); + predicate = getIteratee(predicate, 3); + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result.push(value); + indexes.push(index); + } } - - directiveArgs.push(state.input.slice(_position, state.position)); + basePullAt(array, indexes); + return result; } - if (ch !== 0) readLineBreak(state); - - if (_hasOwnProperty.call(directiveHandlers, directiveName)) { - directiveHandlers[directiveName](state, directiveName, directiveArgs); - } else { - throwWarning(state, 'unknown document directive "' + directiveName + '"'); + /** + * Reverses `array` so that the first element becomes the last, the second + * element becomes the second to last, and so on. + * + * **Note:** This method mutates `array` and is based on + * [`Array#reverse`](https://mdn.io/Array/reverse). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to modify. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3]; + * + * _.reverse(array); + * // => [3, 2, 1] + * + * console.log(array); + * // => [3, 2, 1] + */ + function reverse(array) { + return array == null ? array : nativeReverse.call(array); } - } - - skipSeparationSpace(state, true, -1); - - if (state.lineIndent === 0 && - state.input.charCodeAt(state.position) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { - state.position += 3; - skipSeparationSpace(state, true, -1); - - } else if (hasDirectives) { - throwError(state, 'directives end mark is expected'); - } - - composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); - skipSeparationSpace(state, true, -1); - - if (state.checkLineBreaks && - PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { - throwWarning(state, 'non-ASCII line breaks are interpreted as content'); - } - - state.documents.push(state.result); - if (state.position === state.lineStart && testDocumentSeparator(state)) { - - if (state.input.charCodeAt(state.position) === 0x2E/* . */) { - state.position += 3; - skipSeparationSpace(state, true, -1); + /** + * Creates a slice of `array` from `start` up to, but not including, `end`. + * + * **Note:** This method is used instead of + * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are + * returned. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ + function slice(array, start, end) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } + else { + start = start == null ? 0 : toInteger(start); + end = end === undefined ? length : toInteger(end); + } + return baseSlice(array, start, end); } - return; - } - - if (state.position < (state.length - 1)) { - throwError(state, 'end of the stream or a document separator is expected'); - } else { - return; - } -} - -function loadDocuments(input, options) { - input = String(input); - options = options || {}; - - if (input.length !== 0) { - - // Add tailing `\n` if not exists - if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && - input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { - input += '\n'; + /** + * Uses a binary search to determine the lowest index at which `value` + * should be inserted into `array` in order to maintain its sort order. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedIndex([30, 50], 40); + * // => 1 + */ + function sortedIndex(array, value) { + return baseSortedIndex(array, value); } - // Strip BOM - if (input.charCodeAt(0) === 0xFEFF) { - input = input.slice(1); + /** + * This method is like `_.sortedIndex` except that it accepts `iteratee` + * which is invoked for `value` and each element of `array` to compute their + * sort ranking. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * var objects = [{ 'x': 4 }, { 'x': 5 }]; + * + * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); + * // => 0 + */ + function sortedIndexBy(array, value, iteratee) { + return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); } - } - - var state = new State(input, options); - - var nullpos = input.indexOf('\0'); - - if (nullpos !== -1) { - state.position = nullpos; - throwError(state, 'null byte is not allowed in input'); - } - - // Use 0 as string terminator. That significantly simplifies bounds check. - state.input += '\0'; - - while (state.input.charCodeAt(state.position) === 0x20/* Space */) { - state.lineIndent += 1; - state.position += 1; - } - - while (state.position < (state.length - 1)) { - readDocument(state); - } - - return state.documents; -} - - -function loadAll(input, iterator, options) { - if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { - options = iterator; - iterator = null; - } - - var documents = loadDocuments(input, options); - - if (typeof iterator !== 'function') { - return documents; - } - - for (var index = 0, length = documents.length; index < length; index += 1) { - iterator(documents[index]); - } -} - - -function load(input, options) { - var documents = loadDocuments(input, options); - - if (documents.length === 0) { - /*eslint-disable no-undefined*/ - return undefined; - } else if (documents.length === 1) { - return documents[0]; - } - throw new YAMLException('expected a single document in the stream, but found more'); -} - - -module.exports.loadAll = loadAll; -module.exports.load = load; - - -/***/ }), - -/***/ 1082: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -/*eslint-disable max-len*/ - -var YAMLException = __nccwpck_require__(8179); -var Type = __nccwpck_require__(6073); - - -function compileList(schema, name) { - var result = []; - - schema[name].forEach(function (currentType) { - var newIndex = result.length; - - result.forEach(function (previousType, previousIndex) { - if (previousType.tag === currentType.tag && - previousType.kind === currentType.kind && - previousType.multi === currentType.multi) { - - newIndex = previousIndex; - } - }); - - result[newIndex] = currentType; - }); - - return result; -} - -function compileMap(/* lists... */) { - var result = { - scalar: {}, - sequence: {}, - mapping: {}, - fallback: {}, - multi: { - scalar: [], - sequence: [], - mapping: [], - fallback: [] + /** + * This method is like `_.indexOf` except that it performs a binary + * search on a sorted `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.sortedIndexOf([4, 5, 5, 5, 6], 5); + * // => 1 + */ + function sortedIndexOf(array, value) { + var length = array == null ? 0 : array.length; + if (length) { + var index = baseSortedIndex(array, value); + if (index < length && eq(array[index], value)) { + return index; } - }, index, length; - - function collectType(type) { - if (type.multi) { - result.multi[type.kind].push(type); - result.multi['fallback'].push(type); - } else { - result[type.kind][type.tag] = result['fallback'][type.tag] = type; + } + return -1; } - } - - for (index = 0, length = arguments.length; index < length; index += 1) { - arguments[index].forEach(collectType); - } - return result; -} - - -function Schema(definition) { - return this.extend(definition); -} - - -Schema.prototype.extend = function extend(definition) { - var implicit = []; - var explicit = []; - - if (definition instanceof Type) { - // Schema.extend(type) - explicit.push(definition); - - } else if (Array.isArray(definition)) { - // Schema.extend([ type1, type2, ... ]) - explicit = explicit.concat(definition); - - } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { - // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) - if (definition.implicit) implicit = implicit.concat(definition.implicit); - if (definition.explicit) explicit = explicit.concat(definition.explicit); - } else { - throw new YAMLException('Schema.extend argument should be a Type, [ Type ], ' + - 'or a schema definition ({ implicit: [...], explicit: [...] })'); - } + /** + * This method is like `_.sortedIndex` except that it returns the highest + * index at which `value` should be inserted into `array` in order to + * maintain its sort order. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedLastIndex([4, 5, 5, 5, 6], 5); + * // => 4 + */ + function sortedLastIndex(array, value) { + return baseSortedIndex(array, value, true); + } - implicit.forEach(function (type) { - if (!(type instanceof Type)) { - throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + /** + * This method is like `_.sortedLastIndex` except that it accepts `iteratee` + * which is invoked for `value` and each element of `array` to compute their + * sort ranking. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * var objects = [{ 'x': 4 }, { 'x': 5 }]; + * + * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); + * // => 1 + * + * // The `_.property` iteratee shorthand. + * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); + * // => 1 + */ + function sortedLastIndexBy(array, value, iteratee) { + return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); } - if (type.loadKind && type.loadKind !== 'scalar') { - throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); + /** + * This method is like `_.lastIndexOf` except that it performs a binary + * search on a sorted `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); + * // => 3 + */ + function sortedLastIndexOf(array, value) { + var length = array == null ? 0 : array.length; + if (length) { + var index = baseSortedIndex(array, value, true) - 1; + if (eq(array[index], value)) { + return index; + } + } + return -1; } - if (type.multi) { - throw new YAMLException('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); + /** + * This method is like `_.uniq` except that it's designed and optimized + * for sorted arrays. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.sortedUniq([1, 1, 2]); + * // => [1, 2] + */ + function sortedUniq(array) { + return (array && array.length) + ? baseSortedUniq(array) + : []; } - }); - explicit.forEach(function (type) { - if (!(type instanceof Type)) { - throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + /** + * This method is like `_.uniqBy` except that it's designed and optimized + * for sorted arrays. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); + * // => [1.1, 2.3] + */ + function sortedUniqBy(array, iteratee) { + return (array && array.length) + ? baseSortedUniq(array, getIteratee(iteratee, 2)) + : []; } - }); - - var result = Object.create(Schema.prototype); - - result.implicit = (this.implicit || []).concat(implicit); - result.explicit = (this.explicit || []).concat(explicit); - - result.compiledImplicit = compileList(result, 'implicit'); - result.compiledExplicit = compileList(result, 'explicit'); - result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); - - return result; -}; - - -module.exports = Schema; - - -/***/ }), - -/***/ 2011: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; -// Standard YAML's Core schema. -// http://www.yaml.org/spec/1.2/spec.html#id2804923 -// -// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. -// So, Core schema has no distinctions from JSON schema is JS-YAML. - - - - - -module.exports = __nccwpck_require__(1035); - - -/***/ }), - -/***/ 8759: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; -// JS-YAML's default schema for `safeLoad` function. -// It is not described in the YAML specification. -// -// This schema is based on standard YAML's Core schema and includes most of -// extra types described at YAML tag repository. (http://yaml.org/type/) - - - - - -module.exports = (__nccwpck_require__(2011).extend)({ - implicit: [ - __nccwpck_require__(9212), - __nccwpck_require__(6104) - ], - explicit: [ - __nccwpck_require__(7900), - __nccwpck_require__(9046), - __nccwpck_require__(6860), - __nccwpck_require__(9548) - ] -}); - - -/***/ }), - -/***/ 8562: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; -// Standard YAML's Failsafe schema. -// http://www.yaml.org/spec/1.2/spec.html#id2802346 - - + /** + * Gets all but the first element of `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.tail([1, 2, 3]); + * // => [2, 3] + */ + function tail(array) { + var length = array == null ? 0 : array.length; + return length ? baseSlice(array, 1, length) : []; + } + /** + * Creates a slice of `array` with `n` elements taken from the beginning. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.take([1, 2, 3]); + * // => [1] + * + * _.take([1, 2, 3], 2); + * // => [1, 2] + * + * _.take([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.take([1, 2, 3], 0); + * // => [] + */ + function take(array, n, guard) { + if (!(array && array.length)) { + return []; + } + n = (guard || n === undefined) ? 1 : toInteger(n); + return baseSlice(array, 0, n < 0 ? 0 : n); + } -var Schema = __nccwpck_require__(1082); + /** + * Creates a slice of `array` with `n` elements taken from the end. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.takeRight([1, 2, 3]); + * // => [3] + * + * _.takeRight([1, 2, 3], 2); + * // => [2, 3] + * + * _.takeRight([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.takeRight([1, 2, 3], 0); + * // => [] + */ + function takeRight(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + n = (guard || n === undefined) ? 1 : toInteger(n); + n = length - n; + return baseSlice(array, n < 0 ? 0 : n, length); + } + /** + * Creates a slice of `array` with elements taken from the end. Elements are + * taken until `predicate` returns falsey. The predicate is invoked with + * three arguments: (value, index, array). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * _.takeRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['fred', 'pebbles'] + * + * // The `_.matches` iteratee shorthand. + * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['pebbles'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.takeRightWhile(users, ['active', false]); + * // => objects for ['fred', 'pebbles'] + * + * // The `_.property` iteratee shorthand. + * _.takeRightWhile(users, 'active'); + * // => [] + */ + function takeRightWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), false, true) + : []; + } -module.exports = new Schema({ - explicit: [ - __nccwpck_require__(3619), - __nccwpck_require__(7283), - __nccwpck_require__(6150) - ] -}); + /** + * Creates a slice of `array` with elements taken from the beginning. Elements + * are taken until `predicate` returns falsey. The predicate is invoked with + * three arguments: (value, index, array). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.takeWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney', 'fred'] + * + * // The `_.matches` iteratee shorthand. + * _.takeWhile(users, { 'user': 'barney', 'active': false }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.takeWhile(users, ['active', false]); + * // => objects for ['barney', 'fred'] + * + * // The `_.property` iteratee shorthand. + * _.takeWhile(users, 'active'); + * // => [] + */ + function takeWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3)) + : []; + } + /** + * Creates an array of unique values, in order, from all given arrays using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of combined values. + * @example + * + * _.union([2], [1, 2]); + * // => [2, 1] + */ + var union = baseRest(function(arrays) { + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); + }); -/***/ }), + /** + * This method is like `_.union` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by + * which uniqueness is computed. Result values are chosen from the first + * array in which the value occurs. The iteratee is invoked with one argument: + * (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of combined values. + * @example + * + * _.unionBy([2.1], [1.2, 2.3], Math.floor); + * // => [2.1, 1.2] + * + * // The `_.property` iteratee shorthand. + * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] + */ + var unionBy = baseRest(function(arrays) { + var iteratee = last(arrays); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); + }); -/***/ 1035: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * This method is like `_.union` except that it accepts `comparator` which + * is invoked to compare elements of `arrays`. Result values are chosen from + * the first array in which the value occurs. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of combined values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.unionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + */ + var unionWith = baseRest(function(arrays) { + var comparator = last(arrays); + comparator = typeof comparator == 'function' ? comparator : undefined; + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); + }); -"use strict"; -// Standard YAML's JSON schema. -// http://www.yaml.org/spec/1.2/spec.html#id2803231 -// -// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. -// So, this schema is not such strict as defined in the YAML specification. -// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. + /** + * Creates a duplicate-free version of an array, using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons, in which only the first occurrence of each element + * is kept. The order of result values is determined by the order they occur + * in the array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.uniq([2, 1, 2]); + * // => [2, 1] + */ + function uniq(array) { + return (array && array.length) ? baseUniq(array) : []; + } + /** + * This method is like `_.uniq` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * uniqueness is computed. The order of result values is determined by the + * order they occur in the array. The iteratee is invoked with one argument: + * (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.uniqBy([2.1, 1.2, 2.3], Math.floor); + * // => [2.1, 1.2] + * + * // The `_.property` iteratee shorthand. + * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] + */ + function uniqBy(array, iteratee) { + return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; + } + /** + * This method is like `_.uniq` except that it accepts `comparator` which + * is invoked to compare elements of `array`. The order of result values is + * determined by the order they occur in the array.The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.uniqWith(objects, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] + */ + function uniqWith(array, comparator) { + comparator = typeof comparator == 'function' ? comparator : undefined; + return (array && array.length) ? baseUniq(array, undefined, comparator) : []; + } + /** + * This method is like `_.zip` except that it accepts an array of grouped + * elements and creates an array regrouping the elements to their pre-zip + * configuration. + * + * @static + * @memberOf _ + * @since 1.2.0 + * @category Array + * @param {Array} array The array of grouped elements to process. + * @returns {Array} Returns the new array of regrouped elements. + * @example + * + * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); + * // => [['a', 1, true], ['b', 2, false]] + * + * _.unzip(zipped); + * // => [['a', 'b'], [1, 2], [true, false]] + */ + function unzip(array) { + if (!(array && array.length)) { + return []; + } + var length = 0; + array = arrayFilter(array, function(group) { + if (isArrayLikeObject(group)) { + length = nativeMax(group.length, length); + return true; + } + }); + return baseTimes(length, function(index) { + return arrayMap(array, baseProperty(index)); + }); + } + /** + * This method is like `_.unzip` except that it accepts `iteratee` to specify + * how regrouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). + * + * @static + * @memberOf _ + * @since 3.8.0 + * @category Array + * @param {Array} array The array of grouped elements to process. + * @param {Function} [iteratee=_.identity] The function to combine + * regrouped values. + * @returns {Array} Returns the new array of regrouped elements. + * @example + * + * var zipped = _.zip([1, 2], [10, 20], [100, 200]); + * // => [[1, 10, 100], [2, 20, 200]] + * + * _.unzipWith(zipped, _.add); + * // => [3, 30, 300] + */ + function unzipWith(array, iteratee) { + if (!(array && array.length)) { + return []; + } + var result = unzip(array); + if (iteratee == null) { + return result; + } + return arrayMap(result, function(group) { + return apply(iteratee, undefined, group); + }); + } -module.exports = (__nccwpck_require__(8562).extend)({ - implicit: [ - __nccwpck_require__(721), - __nccwpck_require__(4993), - __nccwpck_require__(1615), - __nccwpck_require__(2705) - ] -}); + /** + * Creates an array excluding all given values using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * **Note:** Unlike `_.pull`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...*} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @see _.difference, _.xor + * @example + * + * _.without([2, 1, 2, 3], 1, 2); + * // => [3] + */ + var without = baseRest(function(array, values) { + return isArrayLikeObject(array) + ? baseDifference(array, values) + : []; + }); + /** + * Creates an array of unique values that is the + * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * of the given arrays. The order of result values is determined by the order + * they occur in the arrays. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of filtered values. + * @see _.difference, _.without + * @example + * + * _.xor([2, 1], [2, 3]); + * // => [1, 3] + */ + var xor = baseRest(function(arrays) { + return baseXor(arrayFilter(arrays, isArrayLikeObject)); + }); -/***/ }), + /** + * This method is like `_.xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by + * which by which they're compared. The order of result values is determined + * by the order they occur in the arrays. The iteratee is invoked with one + * argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [1.2, 3.4] + * + * // The `_.property` iteratee shorthand. + * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] + */ + var xorBy = baseRest(function(arrays) { + var iteratee = last(arrays); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); + }); -/***/ 6975: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * This method is like `_.xor` except that it accepts `comparator` which is + * invoked to compare elements of `arrays`. The order of result values is + * determined by the order they occur in the arrays. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.xorWith(objects, others, _.isEqual); + * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + */ + var xorWith = baseRest(function(arrays) { + var comparator = last(arrays); + comparator = typeof comparator == 'function' ? comparator : undefined; + return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); + }); -"use strict"; + /** + * Creates an array of grouped elements, the first of which contains the + * first elements of the given arrays, the second of which contains the + * second elements of the given arrays, and so on. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @returns {Array} Returns the new array of grouped elements. + * @example + * + * _.zip(['a', 'b'], [1, 2], [true, false]); + * // => [['a', 1, true], ['b', 2, false]] + */ + var zip = baseRest(unzip); + /** + * This method is like `_.fromPairs` except that it accepts two arrays, + * one of property identifiers and one of corresponding values. + * + * @static + * @memberOf _ + * @since 0.4.0 + * @category Array + * @param {Array} [props=[]] The property identifiers. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. + * @example + * + * _.zipObject(['a', 'b'], [1, 2]); + * // => { 'a': 1, 'b': 2 } + */ + function zipObject(props, values) { + return baseZipObject(props || [], values || [], assignValue); + } + /** + * This method is like `_.zipObject` except that it supports property paths. + * + * @static + * @memberOf _ + * @since 4.1.0 + * @category Array + * @param {Array} [props=[]] The property identifiers. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. + * @example + * + * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); + * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } + */ + function zipObjectDeep(props, values) { + return baseZipObject(props || [], values || [], baseSet); + } -var common = __nccwpck_require__(6829); + /** + * This method is like `_.zip` except that it accepts `iteratee` to specify + * how grouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). + * + * @static + * @memberOf _ + * @since 3.8.0 + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @param {Function} [iteratee=_.identity] The function to combine + * grouped values. + * @returns {Array} Returns the new array of grouped elements. + * @example + * + * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { + * return a + b + c; + * }); + * // => [111, 222] + */ + var zipWith = baseRest(function(arrays) { + var length = arrays.length, + iteratee = length > 1 ? arrays[length - 1] : undefined; + iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; + return unzipWith(arrays, iteratee); + }); -// get snippet for a single line, respecting maxLength -function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { - var head = ''; - var tail = ''; - var maxHalfLength = Math.floor(maxLineLength / 2) - 1; + /*------------------------------------------------------------------------*/ - if (position - lineStart > maxHalfLength) { - head = ' ... '; - lineStart = position - maxHalfLength + head.length; - } + /** + * Creates a `lodash` wrapper instance that wraps `value` with explicit method + * chain sequences enabled. The result of such sequences must be unwrapped + * with `_#value`. + * + * @static + * @memberOf _ + * @since 1.3.0 + * @category Seq + * @param {*} value The value to wrap. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'pebbles', 'age': 1 } + * ]; + * + * var youngest = _ + * .chain(users) + * .sortBy('age') + * .map(function(o) { + * return o.user + ' is ' + o.age; + * }) + * .head() + * .value(); + * // => 'pebbles is 1' + */ + function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; + } - if (lineEnd - position > maxHalfLength) { - tail = ' ...'; - lineEnd = position + maxHalfLength - tail.length; - } + /** + * This method invokes `interceptor` and returns `value`. The interceptor + * is invoked with one argument; (value). The purpose of this method is to + * "tap into" a method chain sequence in order to modify intermediate results. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Seq + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @returns {*} Returns `value`. + * @example + * + * _([1, 2, 3]) + * .tap(function(array) { + * // Mutate input array. + * array.pop(); + * }) + * .reverse() + * .value(); + * // => [2, 1] + */ + function tap(value, interceptor) { + interceptor(value); + return value; + } - return { - str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, - pos: position - lineStart + head.length // relative position - }; -} + /** + * This method is like `_.tap` except that it returns the result of `interceptor`. + * The purpose of this method is to "pass thru" values replacing intermediate + * results in a method chain sequence. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Seq + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @returns {*} Returns the result of `interceptor`. + * @example + * + * _(' abc ') + * .chain() + * .trim() + * .thru(function(value) { + * return [value]; + * }) + * .value(); + * // => ['abc'] + */ + function thru(value, interceptor) { + return interceptor(value); + } + /** + * This method is the wrapper version of `_.at`. + * + * @name at + * @memberOf _ + * @since 1.0.0 + * @category Seq + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * + * _(object).at(['a[0].b.c', 'a[1]']).value(); + * // => [3, 4] + */ + var wrapperAt = flatRest(function(paths) { + var length = paths.length, + start = length ? paths[0] : 0, + value = this.__wrapped__, + interceptor = function(object) { return baseAt(object, paths); }; -function padStart(string, max) { - return common.repeat(' ', max - string.length) + string; -} + if (length > 1 || this.__actions__.length || + !(value instanceof LazyWrapper) || !isIndex(start)) { + return this.thru(interceptor); + } + value = value.slice(start, +start + (length ? 1 : 0)); + value.__actions__.push({ + 'func': thru, + 'args': [interceptor], + 'thisArg': undefined + }); + return new LodashWrapper(value, this.__chain__).thru(function(array) { + if (length && !array.length) { + array.push(undefined); + } + return array; + }); + }); + /** + * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. + * + * @name chain + * @memberOf _ + * @since 0.1.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * // A sequence without explicit chaining. + * _(users).head(); + * // => { 'user': 'barney', 'age': 36 } + * + * // A sequence with explicit chaining. + * _(users) + * .chain() + * .head() + * .pick('user') + * .value(); + * // => { 'user': 'barney' } + */ + function wrapperChain() { + return chain(this); + } -function makeSnippet(mark, options) { - options = Object.create(options || null); + /** + * Executes the chain sequence and returns the wrapped result. + * + * @name commit + * @memberOf _ + * @since 3.2.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var array = [1, 2]; + * var wrapped = _(array).push(3); + * + * console.log(array); + * // => [1, 2] + * + * wrapped = wrapped.commit(); + * console.log(array); + * // => [1, 2, 3] + * + * wrapped.last(); + * // => 3 + * + * console.log(array); + * // => [1, 2, 3] + */ + function wrapperCommit() { + return new LodashWrapper(this.value(), this.__chain__); + } - if (!mark.buffer) return null; + /** + * Gets the next value on a wrapped object following the + * [iterator protocol](https://mdn.io/iteration_protocols#iterator). + * + * @name next + * @memberOf _ + * @since 4.0.0 + * @category Seq + * @returns {Object} Returns the next iterator value. + * @example + * + * var wrapped = _([1, 2]); + * + * wrapped.next(); + * // => { 'done': false, 'value': 1 } + * + * wrapped.next(); + * // => { 'done': false, 'value': 2 } + * + * wrapped.next(); + * // => { 'done': true, 'value': undefined } + */ + function wrapperNext() { + if (this.__values__ === undefined) { + this.__values__ = toArray(this.value()); + } + var done = this.__index__ >= this.__values__.length, + value = done ? undefined : this.__values__[this.__index__++]; - if (!options.maxLength) options.maxLength = 79; - if (typeof options.indent !== 'number') options.indent = 1; - if (typeof options.linesBefore !== 'number') options.linesBefore = 3; - if (typeof options.linesAfter !== 'number') options.linesAfter = 2; + return { 'done': done, 'value': value }; + } - var re = /\r?\n|\r|\0/g; - var lineStarts = [ 0 ]; - var lineEnds = []; - var match; - var foundLineNo = -1; + /** + * Enables the wrapper to be iterable. + * + * @name Symbol.iterator + * @memberOf _ + * @since 4.0.0 + * @category Seq + * @returns {Object} Returns the wrapper object. + * @example + * + * var wrapped = _([1, 2]); + * + * wrapped[Symbol.iterator]() === wrapped; + * // => true + * + * Array.from(wrapped); + * // => [1, 2] + */ + function wrapperToIterator() { + return this; + } - while ((match = re.exec(mark.buffer))) { - lineEnds.push(match.index); - lineStarts.push(match.index + match[0].length); + /** + * Creates a clone of the chain sequence planting `value` as the wrapped value. + * + * @name plant + * @memberOf _ + * @since 3.2.0 + * @category Seq + * @param {*} value The value to plant. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var wrapped = _([1, 2]).map(square); + * var other = wrapped.plant([3, 4]); + * + * other.value(); + * // => [9, 16] + * + * wrapped.value(); + * // => [1, 4] + */ + function wrapperPlant(value) { + var result, + parent = this; - if (mark.position <= match.index && foundLineNo < 0) { - foundLineNo = lineStarts.length - 2; + while (parent instanceof baseLodash) { + var clone = wrapperClone(parent); + clone.__index__ = 0; + clone.__values__ = undefined; + if (result) { + previous.__wrapped__ = clone; + } else { + result = clone; + } + var previous = clone; + parent = parent.__wrapped__; + } + previous.__wrapped__ = value; + return result; } - } - if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; + /** + * This method is the wrapper version of `_.reverse`. + * + * **Note:** This method mutates the wrapped array. + * + * @name reverse + * @memberOf _ + * @since 0.1.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var array = [1, 2, 3]; + * + * _(array).reverse().value() + * // => [3, 2, 1] + * + * console.log(array); + * // => [3, 2, 1] + */ + function wrapperReverse() { + var value = this.__wrapped__; + if (value instanceof LazyWrapper) { + var wrapped = value; + if (this.__actions__.length) { + wrapped = new LazyWrapper(this); + } + wrapped = wrapped.reverse(); + wrapped.__actions__.push({ + 'func': thru, + 'args': [reverse], + 'thisArg': undefined + }); + return new LodashWrapper(wrapped, this.__chain__); + } + return this.thru(reverse); + } - var result = '', i, line; - var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; - var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); + /** + * Executes the chain sequence to resolve the unwrapped value. + * + * @name value + * @memberOf _ + * @since 0.1.0 + * @alias toJSON, valueOf + * @category Seq + * @returns {*} Returns the resolved unwrapped value. + * @example + * + * _([1, 2, 3]).value(); + * // => [1, 2, 3] + */ + function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); + } - for (i = 1; i <= options.linesBefore; i++) { - if (foundLineNo - i < 0) break; - line = getLine( - mark.buffer, - lineStarts[foundLineNo - i], - lineEnds[foundLineNo - i], - mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), - maxLineLength - ); - result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n' + result; - } + /*------------------------------------------------------------------------*/ - line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); - result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n'; - result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The corresponding value of + * each key is the number of times the key was returned by `iteratee`. The + * iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.countBy([6.1, 4.2, 6.3], Math.floor); + * // => { '4': 1, '6': 2 } + * + * // The `_.property` iteratee shorthand. + * _.countBy(['one', 'two', 'three'], 'length'); + * // => { '3': 2, '5': 1 } + */ + var countBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + ++result[key]; + } else { + baseAssignValue(result, key, 1); + } + }); - for (i = 1; i <= options.linesAfter; i++) { - if (foundLineNo + i >= lineEnds.length) break; - line = getLine( - mark.buffer, - lineStarts[foundLineNo + i], - lineEnds[foundLineNo + i], - mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), - maxLineLength - ); - result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + - ' | ' + line.str + '\n'; - } + /** + * Checks if `predicate` returns truthy for **all** elements of `collection`. + * Iteration is stopped once `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index|key, collection). + * + * **Note:** This method returns `true` for + * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because + * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of + * elements of empty collections. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + * @example + * + * _.every([true, 1, null, 'yes'], Boolean); + * // => false + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * // The `_.matches` iteratee shorthand. + * _.every(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // The `_.matchesProperty` iteratee shorthand. + * _.every(users, ['active', false]); + * // => true + * + * // The `_.property` iteratee shorthand. + * _.every(users, 'active'); + * // => false + */ + function every(collection, predicate, guard) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (guard && isIterateeCall(collection, predicate, guard)) { + predicate = undefined; + } + return func(collection, getIteratee(predicate, 3)); + } - return result.replace(/\n$/, ''); -} + /** + * Iterates over elements of `collection`, returning an array of all elements + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * **Note:** Unlike `_.remove`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @see _.reject + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * _.filter(users, function(o) { return !o.active; }); + * // => objects for ['fred'] + * + * // The `_.matches` iteratee shorthand. + * _.filter(users, { 'age': 36, 'active': true }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, ['active', false]); + * // => objects for ['fred'] + * + * // The `_.property` iteratee shorthand. + * _.filter(users, 'active'); + * // => objects for ['barney'] + * + * // Combining several predicates using `_.overEvery` or `_.overSome`. + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); + * // => objects for ['fred', 'barney'] + */ + function filter(collection, predicate) { + var func = isArray(collection) ? arrayFilter : baseFilter; + return func(collection, getIteratee(predicate, 3)); + } + /** + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; + * + * _.find(users, function(o) { return o.age < 40; }); + * // => object for 'barney' + * + * // The `_.matches` iteratee shorthand. + * _.find(users, { 'age': 1, 'active': true }); + * // => object for 'pebbles' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.find(users, ['active', false]); + * // => object for 'fred' + * + * // The `_.property` iteratee shorthand. + * _.find(users, 'active'); + * // => object for 'barney' + */ + var find = createFind(findIndex); -module.exports = makeSnippet; + /** + * This method is like `_.find` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=collection.length-1] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * _.findLast([1, 2, 3, 4], function(n) { + * return n % 2 == 1; + * }); + * // => 3 + */ + var findLast = createFind(findLastIndex); + /** + * Creates a flattened array of values by running each element in `collection` + * thru `iteratee` and flattening the mapped results. The iteratee is invoked + * with three arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [n, n]; + * } + * + * _.flatMap([1, 2], duplicate); + * // => [1, 1, 2, 2] + */ + function flatMap(collection, iteratee) { + return baseFlatten(map(collection, iteratee), 1); + } -/***/ }), + /** + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDeep([1, 2], duplicate); + * // => [1, 1, 2, 2] + */ + function flatMapDeep(collection, iteratee) { + return baseFlatten(map(collection, iteratee), INFINITY); + } -/***/ 6073: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results up to `depth` times. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDepth([1, 2], duplicate, 2); + * // => [[1, 1], [2, 2]] + */ + function flatMapDepth(collection, iteratee, depth) { + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(map(collection, iteratee), depth); + } -"use strict"; + /** + * Iterates over elements of `collection` and invokes `iteratee` for each element. + * The iteratee is invoked with three arguments: (value, index|key, collection). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @alias each + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEachRight + * @example + * + * _.forEach([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `1` then `2`. + * + * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ + function forEach(collection, iteratee) { + var func = isArray(collection) ? arrayEach : baseEach; + return func(collection, getIteratee(iteratee, 3)); + } + /** + * This method is like `_.forEach` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @alias eachRight + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEach + * @example + * + * _.forEachRight([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `2` then `1`. + */ + function forEachRight(collection, iteratee) { + var func = isArray(collection) ? arrayEachRight : baseEachRight; + return func(collection, getIteratee(iteratee, 3)); + } -var YAMLException = __nccwpck_require__(8179); + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The order of grouped values + * is determined by the order they occur in `collection`. The corresponding + * value of each key is an array of elements responsible for generating the + * key. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.groupBy([6.1, 4.2, 6.3], Math.floor); + * // => { '4': [4.2], '6': [6.1, 6.3] } + * + * // The `_.property` iteratee shorthand. + * _.groupBy(['one', 'two', 'three'], 'length'); + * // => { '3': ['one', 'two'], '5': ['three'] } + */ + var groupBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + result[key].push(value); + } else { + baseAssignValue(result, key, [value]); + } + }); -var TYPE_CONSTRUCTOR_OPTIONS = [ - 'kind', - 'multi', - 'resolve', - 'construct', - 'instanceOf', - 'predicate', - 'represent', - 'representName', - 'defaultStyle', - 'styleAliases' -]; + /** + * Checks if `value` is in `collection`. If `collection` is a string, it's + * checked for a substring of `value`, otherwise + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * is used for equality comparisons. If `fromIndex` is negative, it's used as + * the offset from the end of `collection`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. + * @returns {boolean} Returns `true` if `value` is found, else `false`. + * @example + * + * _.includes([1, 2, 3], 1); + * // => true + * + * _.includes([1, 2, 3], 1, 2); + * // => false + * + * _.includes({ 'a': 1, 'b': 2 }, 1); + * // => true + * + * _.includes('abcd', 'bc'); + * // => true + */ + function includes(collection, value, fromIndex, guard) { + collection = isArrayLike(collection) ? collection : values(collection); + fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; -var YAML_NODE_KINDS = [ - 'scalar', - 'sequence', - 'mapping' -]; + var length = collection.length; + if (fromIndex < 0) { + fromIndex = nativeMax(length + fromIndex, 0); + } + return isString(collection) + ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) + : (!!length && baseIndexOf(collection, value, fromIndex) > -1); + } -function compileStyleAliases(map) { - var result = {}; + /** + * Invokes the method at `path` of each element in `collection`, returning + * an array of the results of each invoked method. Any additional arguments + * are provided to each invoked method. If `path` is a function, it's invoked + * for, and `this` bound to, each element in `collection`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array|Function|string} path The path of the method to invoke or + * the function invoked per iteration. + * @param {...*} [args] The arguments to invoke each method with. + * @returns {Array} Returns the array of results. + * @example + * + * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); + * // => [[1, 5, 7], [1, 2, 3]] + * + * _.invokeMap([123, 456], String.prototype.split, ''); + * // => [['1', '2', '3'], ['4', '5', '6']] + */ + var invokeMap = baseRest(function(collection, path, args) { + var index = -1, + isFunc = typeof path == 'function', + result = isArrayLike(collection) ? Array(collection.length) : []; - if (map !== null) { - Object.keys(map).forEach(function (style) { - map[style].forEach(function (alias) { - result[String(alias)] = style; + baseEach(collection, function(value) { + result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); }); + return result; }); - } - return result; -} + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The corresponding value of + * each key is the last element responsible for generating the key. The + * iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * var array = [ + * { 'dir': 'left', 'code': 97 }, + * { 'dir': 'right', 'code': 100 } + * ]; + * + * _.keyBy(array, function(o) { + * return String.fromCharCode(o.code); + * }); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + * + * _.keyBy(array, 'dir'); + * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } + */ + var keyBy = createAggregator(function(result, value, key) { + baseAssignValue(result, key, value); + }); -function Type(tag, options) { - options = options || {}; + /** + * Creates an array of values by running each element in `collection` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, + * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, + * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, + * `template`, `trim`, `trimEnd`, `trimStart`, and `words` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + * @example + * + * function square(n) { + * return n * n; + * } + * + * _.map([4, 8], square); + * // => [16, 64] + * + * _.map({ 'a': 4, 'b': 8 }, square); + * // => [16, 64] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // The `_.property` iteratee shorthand. + * _.map(users, 'user'); + * // => ['barney', 'fred'] + */ + function map(collection, iteratee) { + var func = isArray(collection) ? arrayMap : baseMap; + return func(collection, getIteratee(iteratee, 3)); + } - Object.keys(options).forEach(function (name) { - if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { - throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + /** + * This method is like `_.sortBy` except that it allows specifying the sort + * orders of the iteratees to sort by. If `orders` is unspecified, all values + * are sorted in ascending order. Otherwise, specify an order of "desc" for + * descending or "asc" for ascending sort order of corresponding values. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] + * The iteratees to sort by. + * @param {string[]} [orders] The sort orders of `iteratees`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 34 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'barney', 'age': 36 } + * ]; + * + * // Sort by `user` in ascending order and by `age` in descending order. + * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] + */ + function orderBy(collection, iteratees, orders, guard) { + if (collection == null) { + return []; + } + if (!isArray(iteratees)) { + iteratees = iteratees == null ? [] : [iteratees]; + } + orders = guard ? undefined : orders; + if (!isArray(orders)) { + orders = orders == null ? [] : [orders]; + } + return baseOrderBy(collection, iteratees, orders); } - }); - // TODO: Add tag format check. - this.options = options; // keep original options in case user wants to extend this type later - this.tag = tag; - this.kind = options['kind'] || null; - this.resolve = options['resolve'] || function () { return true; }; - this.construct = options['construct'] || function (data) { return data; }; - this.instanceOf = options['instanceOf'] || null; - this.predicate = options['predicate'] || null; - this.represent = options['represent'] || null; - this.representName = options['representName'] || null; - this.defaultStyle = options['defaultStyle'] || null; - this.multi = options['multi'] || false; - this.styleAliases = compileStyleAliases(options['styleAliases'] || null); + /** + * Creates an array of elements split into two groups, the first of which + * contains elements `predicate` returns truthy for, the second of which + * contains elements `predicate` returns falsey for. The predicate is + * invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the array of grouped elements. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true }, + * { 'user': 'pebbles', 'age': 1, 'active': false } + * ]; + * + * _.partition(users, function(o) { return o.active; }); + * // => objects for [['fred'], ['barney', 'pebbles']] + * + * // The `_.matches` iteratee shorthand. + * _.partition(users, { 'age': 1, 'active': false }); + * // => objects for [['pebbles'], ['barney', 'fred']] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.partition(users, ['active', false]); + * // => objects for [['barney', 'pebbles'], ['fred']] + * + * // The `_.property` iteratee shorthand. + * _.partition(users, 'active'); + * // => objects for [['fred'], ['barney', 'pebbles']] + */ + var partition = createAggregator(function(result, value, key) { + result[key ? 0 : 1].push(value); + }, function() { return [[], []]; }); - if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { - throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); - } -} + /** + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` thru `iteratee`, where each successive + * invocation is supplied the return value of the previous. If `accumulator` + * is not given, the first element of `collection` is used as the initial + * value. The iteratee is invoked with four arguments: + * (accumulator, value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.reduce`, `_.reduceRight`, and `_.transform`. + * + * The guarded methods are: + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, + * and `sortBy` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @see _.reduceRight + * @example + * + * _.reduce([1, 2], function(sum, n) { + * return sum + n; + * }, 0); + * // => 3 + * + * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * return result; + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) + */ + function reduce(collection, iteratee, accumulator) { + var func = isArray(collection) ? arrayReduce : baseReduce, + initAccum = arguments.length < 3; -module.exports = Type; + return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); + } + /** + * This method is like `_.reduce` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @see _.reduce + * @example + * + * var array = [[0, 1], [2, 3], [4, 5]]; + * + * _.reduceRight(array, function(flattened, other) { + * return flattened.concat(other); + * }, []); + * // => [4, 5, 2, 3, 0, 1] + */ + function reduceRight(collection, iteratee, accumulator) { + var func = isArray(collection) ? arrayReduceRight : baseReduce, + initAccum = arguments.length < 3; -/***/ }), + return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); + } -/***/ 7900: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * The opposite of `_.filter`; this method returns the elements of `collection` + * that `predicate` does **not** return truthy for. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @see _.filter + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true } + * ]; + * + * _.reject(users, function(o) { return !o.active; }); + * // => objects for ['fred'] + * + * // The `_.matches` iteratee shorthand. + * _.reject(users, { 'age': 40, 'active': true }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.reject(users, ['active', false]); + * // => objects for ['fred'] + * + * // The `_.property` iteratee shorthand. + * _.reject(users, 'active'); + * // => objects for ['barney'] + */ + function reject(collection, predicate) { + var func = isArray(collection) ? arrayFilter : baseFilter; + return func(collection, negate(getIteratee(predicate, 3))); + } -"use strict"; + /** + * Gets a random element from `collection`. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Collection + * @param {Array|Object} collection The collection to sample. + * @returns {*} Returns the random element. + * @example + * + * _.sample([1, 2, 3, 4]); + * // => 2 + */ + function sample(collection) { + var func = isArray(collection) ? arraySample : baseSample; + return func(collection); + } + + /** + * Gets `n` random elements at unique keys from `collection` up to the + * size of `collection`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to sample. + * @param {number} [n=1] The number of elements to sample. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the random elements. + * @example + * + * _.sampleSize([1, 2, 3], 2); + * // => [3, 1] + * + * _.sampleSize([1, 2, 3], 4); + * // => [2, 3, 1] + */ + function sampleSize(collection, n, guard) { + if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { + n = 1; + } else { + n = toInteger(n); + } + var func = isArray(collection) ? arraySampleSize : baseSampleSize; + return func(collection, n); + } + /** + * Creates an array of shuffled values, using a version of the + * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to shuffle. + * @returns {Array} Returns the new shuffled array. + * @example + * + * _.shuffle([1, 2, 3, 4]); + * // => [4, 1, 3, 2] + */ + function shuffle(collection) { + var func = isArray(collection) ? arrayShuffle : baseShuffle; + return func(collection); + } -/*eslint-disable no-bitwise*/ + /** + * Gets the size of `collection` by returning its length for array-like + * values or the number of own enumerable string keyed properties for objects. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @returns {number} Returns the collection size. + * @example + * + * _.size([1, 2, 3]); + * // => 3 + * + * _.size({ 'a': 1, 'b': 2 }); + * // => 2 + * + * _.size('pebbles'); + * // => 7 + */ + function size(collection) { + if (collection == null) { + return 0; + } + if (isArrayLike(collection)) { + return isString(collection) ? stringSize(collection) : collection.length; + } + var tag = getTag(collection); + if (tag == mapTag || tag == setTag) { + return collection.size; + } + return baseKeys(collection).length; + } + + /** + * Checks if `predicate` returns truthy for **any** element of `collection`. + * Iteration is stopped once `predicate` returns truthy. The predicate is + * invoked with three arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + * @example + * + * _.some([null, 0, 'yes', false], Boolean); + * // => true + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false } + * ]; + * + * // The `_.matches` iteratee shorthand. + * _.some(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // The `_.matchesProperty` iteratee shorthand. + * _.some(users, ['active', false]); + * // => true + * + * // The `_.property` iteratee shorthand. + * _.some(users, 'active'); + * // => true + */ + function some(collection, predicate, guard) { + var func = isArray(collection) ? arraySome : baseSome; + if (guard && isIterateeCall(collection, predicate, guard)) { + predicate = undefined; + } + return func(collection, getIteratee(predicate, 3)); + } + + /** + * Creates an array of elements, sorted in ascending order by the results of + * running each element in a collection thru each iteratee. This method + * performs a stable sort, that is, it preserves the original sort order of + * equal elements. The iteratees are invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {...(Function|Function[])} [iteratees=[_.identity]] + * The iteratees to sort by. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 30 }, + * { 'user': 'barney', 'age': 34 } + * ]; + * + * _.sortBy(users, [function(o) { return o.user; }]); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] + * + * _.sortBy(users, ['user', 'age']); + * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] + */ + var sortBy = baseRest(function(collection, iteratees) { + if (collection == null) { + return []; + } + var length = iteratees.length; + if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { + iteratees = []; + } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { + iteratees = [iteratees[0]]; + } + return baseOrderBy(collection, baseFlatten(iteratees, 1), []); + }); + /*------------------------------------------------------------------------*/ -var Type = __nccwpck_require__(6073); + /** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ + var now = ctxNow || function() { + return root.Date.now(); + }; + /*------------------------------------------------------------------------*/ -// [ 64, 65, 66 ] -> [ padding, CR, LF ] -var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; + /** + * The opposite of `_.before`; this method creates a function that invokes + * `func` once it's called `n` or more times. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {number} n The number of calls before `func` is invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var saves = ['profile', 'settings']; + * + * var done = _.after(saves.length, function() { + * console.log('done saving!'); + * }); + * + * _.forEach(saves, function(type) { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => Logs 'done saving!' after the two async saves have completed. + */ + function after(n, func) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + n = toInteger(n); + return function() { + if (--n < 1) { + return func.apply(this, arguments); + } + }; + } + /** + * Creates a function that invokes `func`, with up to `n` arguments, + * ignoring any additional arguments. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to cap arguments for. + * @param {number} [n=func.length] The arity cap. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new capped function. + * @example + * + * _.map(['6', '8', '10'], _.ary(parseInt, 1)); + * // => [6, 8, 10] + */ + function ary(func, n, guard) { + n = guard ? undefined : n; + n = (func && n == null) ? func.length : n; + return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); + } -function resolveYamlBinary(data) { - if (data === null) return false; + /** + * Creates a function that invokes `func`, with the `this` binding and arguments + * of the created function, while it's called less than `n` times. Subsequent + * calls to the created function return the result of the last `func` invocation. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {number} n The number of calls at which `func` is no longer invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * jQuery(element).on('click', _.before(5, addContactToList)); + * // => Allows adding up to 4 contacts to the list. + */ + function before(n, func) { + var result; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + n = toInteger(n); + return function() { + if (--n > 0) { + result = func.apply(this, arguments); + } + if (n <= 1) { + func = undefined; + } + return result; + }; + } - var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; + /** + * Creates a function that invokes `func` with the `this` binding of `thisArg` + * and `partials` prepended to the arguments it receives. + * + * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for partially applied arguments. + * + * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" + * property of bound functions. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * function greet(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * + * var object = { 'user': 'fred' }; + * + * var bound = _.bind(greet, object, 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * // Bound with placeholders. + * var bound = _.bind(greet, object, _, '!'); + * bound('hi'); + * // => 'hi fred!' + */ + var bind = baseRest(function(func, thisArg, partials) { + var bitmask = WRAP_BIND_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, getHolder(bind)); + bitmask |= WRAP_PARTIAL_FLAG; + } + return createWrap(func, bitmask, thisArg, partials, holders); + }); - // Convert one by one. - for (idx = 0; idx < max; idx++) { - code = map.indexOf(data.charAt(idx)); + /** + * Creates a function that invokes the method at `object[key]` with `partials` + * prepended to the arguments it receives. + * + * This method differs from `_.bind` by allowing bound functions to reference + * methods that may be redefined or don't yet exist. See + * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) + * for more details. + * + * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * @static + * @memberOf _ + * @since 0.10.0 + * @category Function + * @param {Object} object The object to invoke the method on. + * @param {string} key The key of the method. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var object = { + * 'user': 'fred', + * 'greet': function(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * }; + * + * var bound = _.bindKey(object, 'greet', 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * object.greet = function(greeting, punctuation) { + * return greeting + 'ya ' + this.user + punctuation; + * }; + * + * bound('!'); + * // => 'hiya fred!' + * + * // Bound with placeholders. + * var bound = _.bindKey(object, 'greet', _, '!'); + * bound('hi'); + * // => 'hiya fred!' + */ + var bindKey = baseRest(function(object, key, partials) { + var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, getHolder(bindKey)); + bitmask |= WRAP_PARTIAL_FLAG; + } + return createWrap(key, bitmask, object, partials, holders); + }); - // Skip CR/LF - if (code > 64) continue; + /** + * Creates a function that accepts arguments of `func` and either invokes + * `func` returning its result, if at least `arity` number of arguments have + * been provided, or returns a function that accepts the remaining `func` + * arguments, and so on. The arity of `func` may be specified if `func.length` + * is not sufficient. + * + * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for provided arguments. + * + * **Note:** This method doesn't set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curry(abc); + * + * curried(1)(2)(3); + * // => [1, 2, 3] + * + * curried(1, 2)(3); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // Curried with placeholders. + * curried(1)(_, 3)(2); + * // => [1, 2, 3] + */ + function curry(func, arity, guard) { + arity = guard ? undefined : arity; + var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curry.placeholder; + return result; + } - // Fail on illegal characters - if (code < 0) return false; + /** + * This method is like `_.curry` except that arguments are applied to `func` + * in the manner of `_.partialRight` instead of `_.partial`. + * + * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for provided arguments. + * + * **Note:** This method doesn't set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curryRight(abc); + * + * curried(3)(2)(1); + * // => [1, 2, 3] + * + * curried(2, 3)(1); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // Curried with placeholders. + * curried(3)(1, _)(2); + * // => [1, 2, 3] + */ + function curryRight(func, arity, guard) { + arity = guard ? undefined : arity; + var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curryRight.placeholder; + return result; + } - bitlen += 6; - } + /** + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed `func` invocations and a `flush` method to immediately invoke them. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. Subsequent + * calls to the debounced function return the result of the last `func` + * invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.debounce` and `_.throttle`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // Avoid costly calculations while the window size is in flux. + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * + * // Invoke `sendMail` when clicked, debouncing subsequent calls. + * jQuery(element).on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // Ensure `batchLog` is invoked once after 1 second of debounced calls. + * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); + * var source = new EventSource('/stream'); + * jQuery(source).on('message', debounced); + * + * // Cancel the trailing debounced invocation. + * jQuery(window).on('popstate', debounced.cancel); + */ + function debounce(func, wait, options) { + var lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime, + lastInvokeTime = 0, + leading = false, + maxing = false, + trailing = true; - // If there are any bits left, source was corrupted - return (bitlen % 8) === 0; -} + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + wait = toNumber(wait) || 0; + if (isObject(options)) { + leading = !!options.leading; + maxing = 'maxWait' in options; + maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } -function constructYamlBinary(data) { - var idx, tailbits, - input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan - max = input.length, - map = BASE64_MAP, - bits = 0, - result = []; + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; - // Collect by 6*4 bits (3 bytes) + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; + } - for (idx = 0; idx < max; idx++) { - if ((idx % 4 === 0) && idx) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); - } + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; + } - bits = (bits << 6) | map.indexOf(input.charAt(idx)); - } + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + timeWaiting = wait - timeSinceLastCall; - // Dump tail + return maxing + ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting; + } - tailbits = (max % 4) * 6; + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; - if (tailbits === 0) { - result.push((bits >> 16) & 0xFF); - result.push((bits >> 8) & 0xFF); - result.push(bits & 0xFF); - } else if (tailbits === 18) { - result.push((bits >> 10) & 0xFF); - result.push((bits >> 2) & 0xFF); - } else if (tailbits === 12) { - result.push((bits >> 4) & 0xFF); - } + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (lastCallTime === undefined || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); + } - return new Uint8Array(result); -} + function timerExpired() { + var time = now(); + if (shouldInvoke(time)) { + return trailingEdge(time); + } + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); + } -function representYamlBinary(object /*, style*/) { - var result = '', bits = 0, idx, tail, - max = object.length, - map = BASE64_MAP; + function trailingEdge(time) { + timerId = undefined; - // Convert every three bytes to 4 ASCII characters. + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); + } + lastArgs = lastThis = undefined; + return result; + } - for (idx = 0; idx < max; idx++) { - if ((idx % 3 === 0) && idx) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; - } + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastInvokeTime = 0; + lastArgs = lastCallTime = lastThis = timerId = undefined; + } - bits = (bits << 8) + object[idx]; - } + function flush() { + return timerId === undefined ? result : trailingEdge(now()); + } - // Dump tail + function debounced() { + var time = now(), + isInvoking = shouldInvoke(time); - tail = max % 3; + lastArgs = arguments; + lastThis = this; + lastCallTime = time; - if (tail === 0) { - result += map[(bits >> 18) & 0x3F]; - result += map[(bits >> 12) & 0x3F]; - result += map[(bits >> 6) & 0x3F]; - result += map[bits & 0x3F]; - } else if (tail === 2) { - result += map[(bits >> 10) & 0x3F]; - result += map[(bits >> 4) & 0x3F]; - result += map[(bits << 2) & 0x3F]; - result += map[64]; - } else if (tail === 1) { - result += map[(bits >> 2) & 0x3F]; - result += map[(bits << 4) & 0x3F]; - result += map[64]; - result += map[64]; - } + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); + } + if (maxing) { + // Handle invocations in a tight loop. + clearTimeout(timerId); + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); + } + } + if (timerId === undefined) { + timerId = setTimeout(timerExpired, wait); + } + return result; + } + debounced.cancel = cancel; + debounced.flush = flush; + return debounced; + } - return result; -} + /** + * Defers invoking the `func` until the current call stack has cleared. Any + * additional arguments are provided to `func` when it's invoked. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to defer. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {number} Returns the timer id. + * @example + * + * _.defer(function(text) { + * console.log(text); + * }, 'deferred'); + * // => Logs 'deferred' after one millisecond. + */ + var defer = baseRest(function(func, args) { + return baseDelay(func, 1, args); + }); -function isBinary(obj) { - return Object.prototype.toString.call(obj) === '[object Uint8Array]'; -} + /** + * Invokes `func` after `wait` milliseconds. Any additional arguments are + * provided to `func` when it's invoked. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {number} Returns the timer id. + * @example + * + * _.delay(function(text) { + * console.log(text); + * }, 1000, 'later'); + * // => Logs 'later' after one second. + */ + var delay = baseRest(function(func, wait, args) { + return baseDelay(func, toNumber(wait) || 0, args); + }); -module.exports = new Type('tag:yaml.org,2002:binary', { - kind: 'scalar', - resolve: resolveYamlBinary, - construct: constructYamlBinary, - predicate: isBinary, - represent: representYamlBinary -}); + /** + * Creates a function that invokes `func` with arguments reversed. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to flip arguments for. + * @returns {Function} Returns the new flipped function. + * @example + * + * var flipped = _.flip(function() { + * return _.toArray(arguments); + * }); + * + * flipped('a', 'b', 'c', 'd'); + * // => ['d', 'c', 'b', 'a'] + */ + function flip(func) { + return createWrap(func, WRAP_FLIP_FLAG); + } + /** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ + function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; -/***/ }), + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || MapCache); + return memoized; + } -/***/ 4993: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + // Expose `MapCache`. + memoize.Cache = MapCache; -"use strict"; + /** + * Creates a function that negates the result of the predicate `func`. The + * `func` predicate is invoked with the `this` binding and arguments of the + * created function. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} predicate The predicate to negate. + * @returns {Function} Returns the new negated function. + * @example + * + * function isEven(n) { + * return n % 2 == 0; + * } + * + * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); + * // => [1, 3, 5] + */ + function negate(predicate) { + if (typeof predicate != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function() { + var args = arguments; + switch (args.length) { + case 0: return !predicate.call(this); + case 1: return !predicate.call(this, args[0]); + case 2: return !predicate.call(this, args[0], args[1]); + case 3: return !predicate.call(this, args[0], args[1], args[2]); + } + return !predicate.apply(this, args); + }; + } + /** + * Creates a function that is restricted to invoking `func` once. Repeat calls + * to the function return the value of the first invocation. The `func` is + * invoked with the `this` binding and arguments of the created function. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var initialize = _.once(createApplication); + * initialize(); + * initialize(); + * // => `createApplication` is invoked once + */ + function once(func) { + return before(2, func); + } -var Type = __nccwpck_require__(6073); + /** + * Creates a function that invokes `func` with its arguments transformed. + * + * @static + * @since 4.0.0 + * @memberOf _ + * @category Function + * @param {Function} func The function to wrap. + * @param {...(Function|Function[])} [transforms=[_.identity]] + * The argument transforms. + * @returns {Function} Returns the new function. + * @example + * + * function doubled(n) { + * return n * 2; + * } + * + * function square(n) { + * return n * n; + * } + * + * var func = _.overArgs(function(x, y) { + * return [x, y]; + * }, [square, doubled]); + * + * func(9, 3); + * // => [81, 6] + * + * func(10, 5); + * // => [100, 10] + */ + var overArgs = castRest(function(func, transforms) { + transforms = (transforms.length == 1 && isArray(transforms[0])) + ? arrayMap(transforms[0], baseUnary(getIteratee())) + : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); -function resolveYamlBoolean(data) { - if (data === null) return false; + var funcsLength = transforms.length; + return baseRest(function(args) { + var index = -1, + length = nativeMin(args.length, funcsLength); - var max = data.length; + while (++index < length) { + args[index] = transforms[index].call(this, args[index]); + } + return apply(func, this, args); + }); + }); - return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || - (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); -} + /** + * Creates a function that invokes `func` with `partials` prepended to the + * arguments it receives. This method is like `_.bind` except it does **not** + * alter the `this` binding. + * + * The `_.partial.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method doesn't set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @since 0.2.0 + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * function greet(greeting, name) { + * return greeting + ' ' + name; + * } + * + * var sayHelloTo = _.partial(greet, 'hello'); + * sayHelloTo('fred'); + * // => 'hello fred' + * + * // Partially applied with placeholders. + * var greetFred = _.partial(greet, _, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + */ + var partial = baseRest(function(func, partials) { + var holders = replaceHolders(partials, getHolder(partial)); + return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); + }); -function constructYamlBoolean(data) { - return data === 'true' || - data === 'True' || - data === 'TRUE'; -} + /** + * This method is like `_.partial` except that partially applied arguments + * are appended to the arguments it receives. + * + * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method doesn't set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * function greet(greeting, name) { + * return greeting + ' ' + name; + * } + * + * var greetFred = _.partialRight(greet, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + * + * // Partially applied with placeholders. + * var sayHelloTo = _.partialRight(greet, 'hello', _); + * sayHelloTo('fred'); + * // => 'hello fred' + */ + var partialRight = baseRest(function(func, partials) { + var holders = replaceHolders(partials, getHolder(partialRight)); + return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); + }); -function isBoolean(object) { - return Object.prototype.toString.call(object) === '[object Boolean]'; -} + /** + * Creates a function that invokes `func` with arguments arranged according + * to the specified `indexes` where the argument value at the first index is + * provided as the first argument, the argument value at the second index is + * provided as the second argument, and so on. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to rearrange arguments for. + * @param {...(number|number[])} indexes The arranged argument indexes. + * @returns {Function} Returns the new function. + * @example + * + * var rearged = _.rearg(function(a, b, c) { + * return [a, b, c]; + * }, [2, 0, 1]); + * + * rearged('b', 'c', 'a') + * // => ['a', 'b', 'c'] + */ + var rearg = flatRest(function(func, indexes) { + return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); + }); -module.exports = new Type('tag:yaml.org,2002:bool', { - kind: 'scalar', - resolve: resolveYamlBoolean, - construct: constructYamlBoolean, - predicate: isBoolean, - represent: { - lowercase: function (object) { return object ? 'true' : 'false'; }, - uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, - camelcase: function (object) { return object ? 'True' : 'False'; } - }, - defaultStyle: 'lowercase' -}); + /** + * Creates a function that invokes `func` with the `this` binding of the + * created function and arguments from `start` and beyond provided as + * an array. + * + * **Note:** This method is based on the + * [rest parameter](https://mdn.io/rest_parameters). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.rest(function(what, names) { + * return what + ' ' + _.initial(names).join(', ') + + * (_.size(names) > 1 ? ', & ' : '') + _.last(names); + * }); + * + * say('hello', 'fred', 'barney', 'pebbles'); + * // => 'hello fred, barney, & pebbles' + */ + function rest(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = start === undefined ? start : toInteger(start); + return baseRest(func, start); + } + + /** + * Creates a function that invokes `func` with the `this` binding of the + * create function and an array of arguments much like + * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). + * + * **Note:** This method is based on the + * [spread operator](https://mdn.io/spread_operator). + * + * @static + * @memberOf _ + * @since 3.2.0 + * @category Function + * @param {Function} func The function to spread arguments over. + * @param {number} [start=0] The start position of the spread. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.spread(function(who, what) { + * return who + ' says ' + what; + * }); + * + * say(['fred', 'hello']); + * // => 'fred says hello' + * + * var numbers = Promise.all([ + * Promise.resolve(40), + * Promise.resolve(36) + * ]); + * + * numbers.then(_.spread(function(x, y) { + * return x + y; + * })); + * // => a Promise of 76 + */ + function spread(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = start == null ? 0 : nativeMax(toInteger(start), 0); + return baseRest(function(args) { + var array = args[start], + otherArgs = castSlice(args, 0, start); + if (array) { + arrayPush(otherArgs, array); + } + return apply(func, this, otherArgs); + }); + } -/***/ }), + /** + * Creates a throttled function that only invokes `func` at most once per + * every `wait` milliseconds. The throttled function comes with a `cancel` + * method to cancel delayed `func` invocations and a `flush` method to + * immediately invoke them. Provide `options` to indicate whether `func` + * should be invoked on the leading and/or trailing edge of the `wait` + * timeout. The `func` is invoked with the last arguments provided to the + * throttled function. Subsequent calls to the throttled function return the + * result of the last `func` invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the throttled function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.throttle` and `_.debounce`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to throttle. + * @param {number} [wait=0] The number of milliseconds to throttle invocations to. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=true] + * Specify invoking on the leading edge of the timeout. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new throttled function. + * @example + * + * // Avoid excessively updating the position while scrolling. + * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); + * + * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. + * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); + * jQuery(element).on('click', throttled); + * + * // Cancel the trailing throttled invocation. + * jQuery(window).on('popstate', throttled.cancel); + */ + function throttle(func, wait, options) { + var leading = true, + trailing = true; -/***/ 2705: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (isObject(options)) { + leading = 'leading' in options ? !!options.leading : leading; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + return debounce(func, wait, { + 'leading': leading, + 'maxWait': wait, + 'trailing': trailing + }); + } -"use strict"; + /** + * Creates a function that accepts up to one argument, ignoring any + * additional arguments. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + * @example + * + * _.map(['6', '8', '10'], _.unary(parseInt)); + * // => [6, 8, 10] + */ + function unary(func) { + return ary(func, 1); + } + /** + * Creates a function that provides `value` to `wrapper` as its first + * argument. Any additional arguments provided to the function are appended + * to those provided to the `wrapper`. The wrapper is invoked with the `this` + * binding of the created function. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {*} value The value to wrap. + * @param {Function} [wrapper=identity] The wrapper function. + * @returns {Function} Returns the new function. + * @example + * + * var p = _.wrap(_.escape, function(func, text) { + * return '

' + func(text) + '

'; + * }); + * + * p('fred, barney, & pebbles'); + * // => '

fred, barney, & pebbles

' + */ + function wrap(value, wrapper) { + return partial(castFunction(wrapper), value); + } -var common = __nccwpck_require__(6829); -var Type = __nccwpck_require__(6073); + /*------------------------------------------------------------------------*/ -var YAML_FLOAT_PATTERN = new RegExp( - // 2.5e4, 2.5 and integers - '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + - // .2e4, .2 - // special case, seems not from spec - '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + - // .inf - '|[-+]?\\.(?:inf|Inf|INF)' + - // .nan - '|\\.(?:nan|NaN|NAN))$'); + /** + * Casts `value` as an array if it's not one. + * + * @static + * @memberOf _ + * @since 4.4.0 + * @category Lang + * @param {*} value The value to inspect. + * @returns {Array} Returns the cast array. + * @example + * + * _.castArray(1); + * // => [1] + * + * _.castArray({ 'a': 1 }); + * // => [{ 'a': 1 }] + * + * _.castArray('abc'); + * // => ['abc'] + * + * _.castArray(null); + * // => [null] + * + * _.castArray(undefined); + * // => [undefined] + * + * _.castArray(); + * // => [] + * + * var array = [1, 2, 3]; + * console.log(_.castArray(array) === array); + * // => true + */ + function castArray() { + if (!arguments.length) { + return []; + } + var value = arguments[0]; + return isArray(value) ? value : [value]; + } -function resolveYamlFloat(data) { - if (data === null) return false; + /** + * Creates a shallow clone of `value`. + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) + * and supports cloning arrays, array buffers, booleans, date objects, maps, + * numbers, `Object` objects, regexes, sets, strings, symbols, and typed + * arrays. The own enumerable properties of `arguments` objects are cloned + * as plain objects. An empty object is returned for uncloneable values such + * as error objects, functions, DOM nodes, and WeakMaps. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to clone. + * @returns {*} Returns the cloned value. + * @see _.cloneDeep + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var shallow = _.clone(objects); + * console.log(shallow[0] === objects[0]); + * // => true + */ + function clone(value) { + return baseClone(value, CLONE_SYMBOLS_FLAG); + } - if (!YAML_FLOAT_PATTERN.test(data) || - // Quick hack to not allow integers end with `_` - // Probably should update regexp & check speed - data[data.length - 1] === '_') { - return false; - } + /** + * This method is like `_.clone` except that it accepts `customizer` which + * is invoked to produce the cloned value. If `customizer` returns `undefined`, + * cloning is handled by the method instead. The `customizer` is invoked with + * up to four arguments; (value [, index|key, object, stack]). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to clone. + * @param {Function} [customizer] The function to customize cloning. + * @returns {*} Returns the cloned value. + * @see _.cloneDeepWith + * @example + * + * function customizer(value) { + * if (_.isElement(value)) { + * return value.cloneNode(false); + * } + * } + * + * var el = _.cloneWith(document.body, customizer); + * + * console.log(el === document.body); + * // => false + * console.log(el.nodeName); + * // => 'BODY' + * console.log(el.childNodes.length); + * // => 0 + */ + function cloneWith(value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); + } - return true; -} + /** + * This method is like `_.clone` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @returns {*} Returns the deep cloned value. + * @see _.clone + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var deep = _.cloneDeep(objects); + * console.log(deep[0] === objects[0]); + * // => false + */ + function cloneDeep(value) { + return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); + } -function constructYamlFloat(data) { - var value, sign; + /** + * This method is like `_.cloneWith` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @param {Function} [customizer] The function to customize cloning. + * @returns {*} Returns the deep cloned value. + * @see _.cloneWith + * @example + * + * function customizer(value) { + * if (_.isElement(value)) { + * return value.cloneNode(true); + * } + * } + * + * var el = _.cloneDeepWith(document.body, customizer); + * + * console.log(el === document.body); + * // => false + * console.log(el.nodeName); + * // => 'BODY' + * console.log(el.childNodes.length); + * // => 20 + */ + function cloneDeepWith(value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); + } - value = data.replace(/_/g, '').toLowerCase(); - sign = value[0] === '-' ? -1 : 1; + /** + * Checks if `object` conforms to `source` by invoking the predicate + * properties of `source` with the corresponding property values of `object`. + * + * **Note:** This method is equivalent to `_.conforms` when `source` is + * partially applied. + * + * @static + * @memberOf _ + * @since 4.14.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property predicates to conform to. + * @returns {boolean} Returns `true` if `object` conforms, else `false`. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * + * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); + * // => true + * + * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); + * // => false + */ + function conformsTo(object, source) { + return source == null || baseConformsTo(object, source, keys(source)); + } - if ('+-'.indexOf(value[0]) >= 0) { - value = value.slice(1); - } + /** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ + function eq(value, other) { + return value === other || (value !== value && other !== other); + } - if (value === '.inf') { - return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + /** + * Checks if `value` is greater than `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + * @see _.lt + * @example + * + * _.gt(3, 1); + * // => true + * + * _.gt(3, 3); + * // => false + * + * _.gt(1, 3); + * // => false + */ + var gt = createRelationalOperation(baseGt); - } else if (value === '.nan') { - return NaN; - } - return sign * parseFloat(value, 10); -} + /** + * Checks if `value` is greater than or equal to `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than or equal to + * `other`, else `false`. + * @see _.lte + * @example + * + * _.gte(3, 1); + * // => true + * + * _.gte(3, 3); + * // => true + * + * _.gte(1, 3); + * // => false + */ + var gte = createRelationalOperation(function(value, other) { + return value >= other; + }); + /** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ + var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); + }; -var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; + /** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ + var isArray = Array.isArray; -function representYamlFloat(object, style) { - var res; + /** + * Checks if `value` is classified as an `ArrayBuffer` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. + * @example + * + * _.isArrayBuffer(new ArrayBuffer(2)); + * // => true + * + * _.isArrayBuffer(new Array(2)); + * // => false + */ + var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; - if (isNaN(object)) { - switch (style) { - case 'lowercase': return '.nan'; - case 'uppercase': return '.NAN'; - case 'camelcase': return '.NaN'; - } - } else if (Number.POSITIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '.inf'; - case 'uppercase': return '.INF'; - case 'camelcase': return '.Inf'; - } - } else if (Number.NEGATIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '-.inf'; - case 'uppercase': return '-.INF'; - case 'camelcase': return '-.Inf'; + /** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ + function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); } - } else if (common.isNegativeZero(object)) { - return '-0.0'; - } - - res = object.toString(10); - - // JS stringifier can build scientific format without dots: 5e-100, - // while YAML requres dot: 5.e-100. Fix it with simple hack - - return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; -} -function isFloat(object) { - return (Object.prototype.toString.call(object) === '[object Number]') && - (object % 1 !== 0 || common.isNegativeZero(object)); -} + /** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false + */ + function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); + } -module.exports = new Type('tag:yaml.org,2002:float', { - kind: 'scalar', - resolve: resolveYamlFloat, - construct: constructYamlFloat, - predicate: isFloat, - represent: representYamlFloat, - defaultStyle: 'lowercase' -}); + /** + * Checks if `value` is classified as a boolean primitive or object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. + * @example + * + * _.isBoolean(false); + * // => true + * + * _.isBoolean(null); + * // => false + */ + function isBoolean(value) { + return value === true || value === false || + (isObjectLike(value) && baseGetTag(value) == boolTag); + } + /** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ + var isBuffer = nativeIsBuffer || stubFalse; -/***/ }), + /** + * Checks if `value` is classified as a `Date` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a date object, else `false`. + * @example + * + * _.isDate(new Date); + * // => true + * + * _.isDate('Mon April 23 2012'); + * // => false + */ + var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; -/***/ 1615: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * Checks if `value` is likely a DOM element. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. + * @example + * + * _.isElement(document.body); + * // => true + * + * _.isElement(''); + * // => false + */ + function isElement(value) { + return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); + } -"use strict"; + /** + * Checks if `value` is an empty object, collection, map, or set. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Array-like values such as `arguments` objects, arrays, buffers, strings, or + * jQuery-like collections are considered empty if they have a `length` of `0`. + * Similarly, maps and sets are considered empty if they have a `size` of `0`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ + function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && + (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || + isBuffer(value) || isTypedArray(value) || isArguments(value))) { + return !value.length; + } + var tag = getTag(value); + if (tag == mapTag || tag == setTag) { + return !value.size; + } + if (isPrototype(value)) { + return !baseKeys(value).length; + } + for (var key in value) { + if (hasOwnProperty.call(value, key)) { + return false; + } + } + return true; + } + /** + * Performs a deep comparison between two values to determine if they are + * equivalent. + * + * **Note:** This method supports comparing arrays, array buffers, booleans, + * date objects, error objects, maps, numbers, `Object` objects, regexes, + * sets, strings, symbols, and typed arrays. `Object` objects are compared + * by their own, not inherited, enumerable properties. Functions and DOM + * nodes are compared by strict equality, i.e. `===`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.isEqual(object, other); + * // => true + * + * object === other; + * // => false + */ + function isEqual(value, other) { + return baseIsEqual(value, other); + } -var common = __nccwpck_require__(6829); -var Type = __nccwpck_require__(6073); + /** + * This method is like `_.isEqual` except that it accepts `customizer` which + * is invoked to compare values. If `customizer` returns `undefined`, comparisons + * are handled by the method instead. The `customizer` is invoked with up to + * six arguments: (objValue, othValue [, index|key, object, other, stack]). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * function isGreeting(value) { + * return /^h(?:i|ello)$/.test(value); + * } + * + * function customizer(objValue, othValue) { + * if (isGreeting(objValue) && isGreeting(othValue)) { + * return true; + * } + * } + * + * var array = ['hello', 'goodbye']; + * var other = ['hi', 'goodbye']; + * + * _.isEqualWith(array, other, customizer); + * // => true + */ + function isEqualWith(value, other, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + var result = customizer ? customizer(value, other) : undefined; + return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; + } -function isHexCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || - ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || - ((0x61/* a */ <= c) && (c <= 0x66/* f */)); -} + /** + * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, + * `SyntaxError`, `TypeError`, or `URIError` object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an error object, else `false`. + * @example + * + * _.isError(new Error); + * // => true + * + * _.isError(Error); + * // => false + */ + function isError(value) { + if (!isObjectLike(value)) { + return false; + } + var tag = baseGetTag(value); + return tag == errorTag || tag == domExcTag || + (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); + } -function isOctCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); -} + /** + * Checks if `value` is a finite primitive number. + * + * **Note:** This method is based on + * [`Number.isFinite`](https://mdn.io/Number/isFinite). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. + * @example + * + * _.isFinite(3); + * // => true + * + * _.isFinite(Number.MIN_VALUE); + * // => true + * + * _.isFinite(Infinity); + * // => false + * + * _.isFinite('3'); + * // => false + */ + function isFinite(value) { + return typeof value == 'number' && nativeIsFinite(value); + } -function isDecCode(c) { - return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); -} + /** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ + function isFunction(value) { + if (!isObject(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; + } -function resolveYamlInteger(data) { - if (data === null) return false; + /** + * Checks if `value` is an integer. + * + * **Note:** This method is based on + * [`Number.isInteger`](https://mdn.io/Number/isInteger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an integer, else `false`. + * @example + * + * _.isInteger(3); + * // => true + * + * _.isInteger(Number.MIN_VALUE); + * // => false + * + * _.isInteger(Infinity); + * // => false + * + * _.isInteger('3'); + * // => false + */ + function isInteger(value) { + return typeof value == 'number' && value == toInteger(value); + } - var max = data.length, - index = 0, - hasDigits = false, - ch; + /** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ + function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } - if (!max) return false; + /** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ + function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); + } - ch = data[index]; + /** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ + function isObjectLike(value) { + return value != null && typeof value == 'object'; + } - // sign - if (ch === '-' || ch === '+') { - ch = data[++index]; - } + /** + * Checks if `value` is classified as a `Map` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + * @example + * + * _.isMap(new Map); + * // => true + * + * _.isMap(new WeakMap); + * // => false + */ + var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; - if (ch === '0') { - // 0 - if (index + 1 === max) return true; - ch = data[++index]; + /** + * Performs a partial deep comparison between `object` and `source` to + * determine if `object` contains equivalent property values. + * + * **Note:** This method is equivalent to `_.matches` when `source` is + * partially applied. + * + * Partial comparisons will match empty array and empty object `source` + * values against any array or object value, respectively. See `_.isEqual` + * for a list of supported value comparisons. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * + * _.isMatch(object, { 'b': 2 }); + * // => true + * + * _.isMatch(object, { 'b': 1 }); + * // => false + */ + function isMatch(object, source) { + return object === source || baseIsMatch(object, source, getMatchData(source)); + } - // base 2, base 8, base 16 + /** + * This method is like `_.isMatch` except that it accepts `customizer` which + * is invoked to compare values. If `customizer` returns `undefined`, comparisons + * are handled by the method instead. The `customizer` is invoked with five + * arguments: (objValue, srcValue, index|key, object, source). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @example + * + * function isGreeting(value) { + * return /^h(?:i|ello)$/.test(value); + * } + * + * function customizer(objValue, srcValue) { + * if (isGreeting(objValue) && isGreeting(srcValue)) { + * return true; + * } + * } + * + * var object = { 'greeting': 'hello' }; + * var source = { 'greeting': 'hi' }; + * + * _.isMatchWith(object, source, customizer); + * // => true + */ + function isMatchWith(object, source, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseIsMatch(object, source, getMatchData(source), customizer); + } - if (ch === 'b') { - // base 2 - index++; + /** + * Checks if `value` is `NaN`. + * + * **Note:** This method is based on + * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as + * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for + * `undefined` and other non-number values. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + * @example + * + * _.isNaN(NaN); + * // => true + * + * _.isNaN(new Number(NaN)); + * // => true + * + * isNaN(undefined); + * // => true + * + * _.isNaN(undefined); + * // => false + */ + function isNaN(value) { + // An `NaN` primitive is the only value that is not equal to itself. + // Perform the `toStringTag` check first to avoid errors with some + // ActiveX objects in IE. + return isNumber(value) && value != +value; + } - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (ch !== '0' && ch !== '1') return false; - hasDigits = true; + /** + * Checks if `value` is a pristine native function. + * + * **Note:** This method can't reliably detect native functions in the presence + * of the core-js package because core-js circumvents this kind of detection. + * Despite multiple requests, the core-js maintainer has made it clear: any + * attempt to fix the detection will be obstructed. As a result, we're left + * with little choice but to throw an error. Unfortunately, this also affects + * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), + * which rely on core-js. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + * @example + * + * _.isNative(Array.prototype.push); + * // => true + * + * _.isNative(_); + * // => false + */ + function isNative(value) { + if (isMaskable(value)) { + throw new Error(CORE_ERROR_TEXT); } - return hasDigits && ch !== '_'; + return baseIsNative(value); } - - if (ch === 'x') { - // base 16 - index++; - - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isHexCode(data.charCodeAt(index))) return false; - hasDigits = true; - } - return hasDigits && ch !== '_'; + /** + * Checks if `value` is `null`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `null`, else `false`. + * @example + * + * _.isNull(null); + * // => true + * + * _.isNull(void 0); + * // => false + */ + function isNull(value) { + return value === null; } + /** + * Checks if `value` is `null` or `undefined`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is nullish, else `false`. + * @example + * + * _.isNil(null); + * // => true + * + * _.isNil(void 0); + * // => true + * + * _.isNil(NaN); + * // => false + */ + function isNil(value) { + return value == null; + } - if (ch === 'o') { - // base 8 - index++; + /** + * Checks if `value` is classified as a `Number` primitive or object. + * + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are + * classified as numbers, use the `_.isFinite` method. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a number, else `false`. + * @example + * + * _.isNumber(3); + * // => true + * + * _.isNumber(Number.MIN_VALUE); + * // => true + * + * _.isNumber(Infinity); + * // => true + * + * _.isNumber('3'); + * // => false + */ + function isNumber(value) { + return typeof value == 'number' || + (isObjectLike(value) && baseGetTag(value) == numberTag); + } - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isOctCode(data.charCodeAt(index))) return false; - hasDigits = true; + /** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * @static + * @memberOf _ + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ + function isPlainObject(value) { + if (!isObjectLike(value) || baseGetTag(value) != objectTag) { + return false; } - return hasDigits && ch !== '_'; + var proto = getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; + return typeof Ctor == 'function' && Ctor instanceof Ctor && + funcToString.call(Ctor) == objectCtorString; } - } - - // base 10 (except 0) - // value should not start with `_`; - if (ch === '_') return false; + /** + * Checks if `value` is classified as a `RegExp` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. + * @example + * + * _.isRegExp(/abc/); + * // => true + * + * _.isRegExp('/abc/'); + * // => false + */ + var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; - for (; index < max; index++) { - ch = data[index]; - if (ch === '_') continue; - if (!isDecCode(data.charCodeAt(index))) { - return false; + /** + * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 + * double precision number which isn't the result of a rounded unsafe integer. + * + * **Note:** This method is based on + * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. + * @example + * + * _.isSafeInteger(3); + * // => true + * + * _.isSafeInteger(Number.MIN_VALUE); + * // => false + * + * _.isSafeInteger(Infinity); + * // => false + * + * _.isSafeInteger('3'); + * // => false + */ + function isSafeInteger(value) { + return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; } - hasDigits = true; - } - - // Should have digits and should not end with `_` - if (!hasDigits || ch === '_') return false; - - return true; -} - -function constructYamlInteger(data) { - var value = data, sign = 1, ch; - - if (value.indexOf('_') !== -1) { - value = value.replace(/_/g, ''); - } - - ch = value[0]; - - if (ch === '-' || ch === '+') { - if (ch === '-') sign = -1; - value = value.slice(1); - ch = value[0]; - } - - if (value === '0') return 0; - - if (ch === '0') { - if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); - if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); - if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); - } - - return sign * parseInt(value, 10); -} - -function isInteger(object) { - return (Object.prototype.toString.call(object)) === '[object Number]' && - (object % 1 === 0 && !common.isNegativeZero(object)); -} - -module.exports = new Type('tag:yaml.org,2002:int', { - kind: 'scalar', - resolve: resolveYamlInteger, - construct: constructYamlInteger, - predicate: isInteger, - represent: { - binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, - octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, - decimal: function (obj) { return obj.toString(10); }, - /* eslint-disable max-len */ - hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } - }, - defaultStyle: 'decimal', - styleAliases: { - binary: [ 2, 'bin' ], - octal: [ 8, 'oct' ], - decimal: [ 10, 'dec' ], - hexadecimal: [ 16, 'hex' ] - } -}); - - -/***/ }), - -/***/ 6150: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -"use strict"; - - -var Type = __nccwpck_require__(6073); - -module.exports = new Type('tag:yaml.org,2002:map', { - kind: 'mapping', - construct: function (data) { return data !== null ? data : {}; } -}); - - -/***/ }), - -/***/ 6104: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -var Type = __nccwpck_require__(6073); - -function resolveYamlMerge(data) { - return data === '<<' || data === null; -} - -module.exports = new Type('tag:yaml.org,2002:merge', { - kind: 'scalar', - resolve: resolveYamlMerge -}); - - -/***/ }), - -/***/ 721: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; + /** + * Checks if `value` is classified as a `Set` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + * @example + * + * _.isSet(new Set); + * // => true + * + * _.isSet(new WeakSet); + * // => false + */ + var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; + /** + * Checks if `value` is classified as a `String` primitive or object. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a string, else `false`. + * @example + * + * _.isString('abc'); + * // => true + * + * _.isString(1); + * // => false + */ + function isString(value) { + return typeof value == 'string' || + (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); + } -var Type = __nccwpck_require__(6073); + /** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ + function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag); + } -function resolveYamlNull(data) { - if (data === null) return true; + /** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ + var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - var max = data.length; + /** + * Checks if `value` is `undefined`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. + * @example + * + * _.isUndefined(void 0); + * // => true + * + * _.isUndefined(null); + * // => false + */ + function isUndefined(value) { + return value === undefined; + } - return (max === 1 && data === '~') || - (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); -} + /** + * Checks if `value` is classified as a `WeakMap` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. + * @example + * + * _.isWeakMap(new WeakMap); + * // => true + * + * _.isWeakMap(new Map); + * // => false + */ + function isWeakMap(value) { + return isObjectLike(value) && getTag(value) == weakMapTag; + } -function constructYamlNull() { - return null; -} + /** + * Checks if `value` is classified as a `WeakSet` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. + * @example + * + * _.isWeakSet(new WeakSet); + * // => true + * + * _.isWeakSet(new Set); + * // => false + */ + function isWeakSet(value) { + return isObjectLike(value) && baseGetTag(value) == weakSetTag; + } -function isNull(object) { - return object === null; -} + /** + * Checks if `value` is less than `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + * @see _.gt + * @example + * + * _.lt(1, 3); + * // => true + * + * _.lt(3, 3); + * // => false + * + * _.lt(3, 1); + * // => false + */ + var lt = createRelationalOperation(baseLt); -module.exports = new Type('tag:yaml.org,2002:null', { - kind: 'scalar', - resolve: resolveYamlNull, - construct: constructYamlNull, - predicate: isNull, - represent: { - canonical: function () { return '~'; }, - lowercase: function () { return 'null'; }, - uppercase: function () { return 'NULL'; }, - camelcase: function () { return 'Null'; }, - empty: function () { return ''; } - }, - defaultStyle: 'lowercase' -}); + /** + * Checks if `value` is less than or equal to `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than or equal to + * `other`, else `false`. + * @see _.gte + * @example + * + * _.lte(1, 3); + * // => true + * + * _.lte(3, 3); + * // => true + * + * _.lte(3, 1); + * // => false + */ + var lte = createRelationalOperation(function(value, other) { + return value <= other; + }); + /** + * Converts `value` to an array. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @returns {Array} Returns the converted array. + * @example + * + * _.toArray({ 'a': 1, 'b': 2 }); + * // => [1, 2] + * + * _.toArray('abc'); + * // => ['a', 'b', 'c'] + * + * _.toArray(1); + * // => [] + * + * _.toArray(null); + * // => [] + */ + function toArray(value) { + if (!value) { + return []; + } + if (isArrayLike(value)) { + return isString(value) ? stringToArray(value) : copyArray(value); + } + if (symIterator && value[symIterator]) { + return iteratorToArray(value[symIterator]()); + } + var tag = getTag(value), + func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); -/***/ }), + return func(value); + } -/***/ 9046: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * Converts `value` to a finite number. + * + * @static + * @memberOf _ + * @since 4.12.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted number. + * @example + * + * _.toFinite(3.2); + * // => 3.2 + * + * _.toFinite(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toFinite(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toFinite('3.2'); + * // => 3.2 + */ + function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = (value < 0 ? -1 : 1); + return sign * MAX_INTEGER; + } + return value === value ? value : 0; + } -"use strict"; + /** + * Converts `value` to an integer. + * + * **Note:** This method is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toInteger(3.2); + * // => 3 + * + * _.toInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3.2'); + * // => 3 + */ + function toInteger(value) { + var result = toFinite(value), + remainder = result % 1; + return result === result ? (remainder ? result - remainder : result) : 0; + } -var Type = __nccwpck_require__(6073); + /** + * Converts `value` to an integer suitable for use as the length of an + * array-like object. + * + * **Note:** This method is based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toLength(3.2); + * // => 3 + * + * _.toLength(Number.MIN_VALUE); + * // => 0 + * + * _.toLength(Infinity); + * // => 4294967295 + * + * _.toLength('3.2'); + * // => 3 + */ + function toLength(value) { + return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; + } -var _hasOwnProperty = Object.prototype.hasOwnProperty; -var _toString = Object.prototype.toString; + /** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ + function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + if (isObject(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject(other) ? (other + '') : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = baseTrim(value); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); + } -function resolveYamlOmap(data) { - if (data === null) return true; + /** + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } + */ + function toPlainObject(value) { + return copyObject(value, keysIn(value)); + } - var objectKeys = [], index, length, pair, pairKey, pairHasKey, - object = data; + /** + * Converts `value` to a safe integer. A safe integer can be compared and + * represented correctly. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toSafeInteger(3.2); + * // => 3 + * + * _.toSafeInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toSafeInteger(Infinity); + * // => 9007199254740991 + * + * _.toSafeInteger('3.2'); + * // => 3 + */ + function toSafeInteger(value) { + return value + ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) + : (value === 0 ? value : 0); + } - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; - pairHasKey = false; + /** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ + function toString(value) { + return value == null ? '' : baseToString(value); + } - if (_toString.call(pair) !== '[object Object]') return false; + /*------------------------------------------------------------------------*/ - for (pairKey in pair) { - if (_hasOwnProperty.call(pair, pairKey)) { - if (!pairHasKey) pairHasKey = true; - else return false; + /** + * Assigns own enumerable string keyed properties of source objects to the + * destination object. Source objects are applied from left to right. + * Subsequent sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object` and is loosely based on + * [`Object.assign`](https://mdn.io/Object/assign). + * + * @static + * @memberOf _ + * @since 0.10.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.assignIn + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * function Bar() { + * this.c = 3; + * } + * + * Foo.prototype.b = 2; + * Bar.prototype.d = 4; + * + * _.assign({ 'a': 0 }, new Foo, new Bar); + * // => { 'a': 1, 'c': 3 } + */ + var assign = createAssigner(function(object, source) { + if (isPrototype(source) || isArrayLike(source)) { + copyObject(source, keys(source), object); + return; } - } - - if (!pairHasKey) return false; + for (var key in source) { + if (hasOwnProperty.call(source, key)) { + assignValue(object, key, source[key]); + } + } + }); - if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); - else return false; - } + /** + * This method is like `_.assign` except that it iterates over own and + * inherited source properties. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias extend + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.assign + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * function Bar() { + * this.c = 3; + * } + * + * Foo.prototype.b = 2; + * Bar.prototype.d = 4; + * + * _.assignIn({ 'a': 0 }, new Foo, new Bar); + * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } + */ + var assignIn = createAssigner(function(object, source) { + copyObject(source, keysIn(source), object); + }); - return true; -} + /** + * This method is like `_.assignIn` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined`, assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias extendWith + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @see _.assignWith + * @example + * + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } + * + * var defaults = _.partialRight(_.assignInWith, customizer); + * + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { + copyObject(source, keysIn(source), object, customizer); + }); -function constructYamlOmap(data) { - return data !== null ? data : []; -} + /** + * This method is like `_.assign` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined`, assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @see _.assignInWith + * @example + * + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } + * + * var defaults = _.partialRight(_.assignWith, customizer); + * + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var assignWith = createAssigner(function(object, source, srcIndex, customizer) { + copyObject(source, keys(source), object, customizer); + }); -module.exports = new Type('tag:yaml.org,2002:omap', { - kind: 'sequence', - resolve: resolveYamlOmap, - construct: constructYamlOmap -}); + /** + * Creates an array of values corresponding to `paths` of `object`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Array} Returns the picked values. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * + * _.at(object, ['a[0].b.c', 'a[1]']); + * // => [3, 4] + */ + var at = flatRest(baseAt); + /** + * Creates an object that inherits from the `prototype` object. If a + * `properties` object is given, its own enumerable string keyed properties + * are assigned to the created object. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Object + * @param {Object} prototype The object to inherit from. + * @param {Object} [properties] The properties to assign to the object. + * @returns {Object} Returns the new object. + * @example + * + * function Shape() { + * this.x = 0; + * this.y = 0; + * } + * + * function Circle() { + * Shape.call(this); + * } + * + * Circle.prototype = _.create(Shape.prototype, { + * 'constructor': Circle + * }); + * + * var circle = new Circle; + * circle instanceof Circle; + * // => true + * + * circle instanceof Shape; + * // => true + */ + function create(prototype, properties) { + var result = baseCreate(prototype); + return properties == null ? result : baseAssign(result, properties); + } -/***/ }), + /** + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. + * + * **Note:** This method mutates `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaultsDeep + * @example + * + * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var defaults = baseRest(function(object, sources) { + object = Object(object); -/***/ 6860: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + var index = -1; + var length = sources.length; + var guard = length > 2 ? sources[2] : undefined; -"use strict"; + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + length = 1; + } + while (++index < length) { + var source = sources[index]; + var props = keysIn(source); + var propsIndex = -1; + var propsLength = props.length; -var Type = __nccwpck_require__(6073); + while (++propsIndex < propsLength) { + var key = props[propsIndex]; + var value = object[key]; -var _toString = Object.prototype.toString; + if (value === undefined || + (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { + object[key] = source[key]; + } + } + } -function resolveYamlPairs(data) { - if (data === null) return true; + return object; + }); - var index, length, pair, keys, result, - object = data; + /** + * This method is like `_.defaults` except that it recursively assigns + * default properties. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.10.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaults + * @example + * + * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); + * // => { 'a': { 'b': 2, 'c': 3 } } + */ + var defaultsDeep = baseRest(function(args) { + args.push(undefined, customDefaultsMerge); + return apply(mergeWith, undefined, args); + }); - result = new Array(object.length); + /** + * This method is like `_.find` except that it returns the key of the first + * element `predicate` returns truthy for instead of the element itself. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Object + * @param {Object} object The object to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. + * @example + * + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * + * _.findKey(users, function(o) { return o.age < 40; }); + * // => 'barney' (iteration order is not guaranteed) + * + * // The `_.matches` iteratee shorthand. + * _.findKey(users, { 'age': 1, 'active': true }); + * // => 'pebbles' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findKey(users, ['active', false]); + * // => 'fred' + * + * // The `_.property` iteratee shorthand. + * _.findKey(users, 'active'); + * // => 'barney' + */ + function findKey(object, predicate) { + return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); + } - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; + /** + * This method is like `_.findKey` except that it iterates over elements of + * a collection in the opposite order. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. + * @example + * + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * + * _.findLastKey(users, function(o) { return o.age < 40; }); + * // => returns 'pebbles' assuming `_.findKey` returns 'barney' + * + * // The `_.matches` iteratee shorthand. + * _.findLastKey(users, { 'age': 36, 'active': true }); + * // => 'barney' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findLastKey(users, ['active', false]); + * // => 'fred' + * + * // The `_.property` iteratee shorthand. + * _.findLastKey(users, 'active'); + * // => 'pebbles' + */ + function findLastKey(object, predicate) { + return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); + } - if (_toString.call(pair) !== '[object Object]') return false; + /** + * Iterates over own and inherited enumerable string keyed properties of an + * object and invokes `iteratee` for each property. The iteratee is invoked + * with three arguments: (value, key, object). Iteratee functions may exit + * iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forInRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forIn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). + */ + function forIn(object, iteratee) { + return object == null + ? object + : baseFor(object, getIteratee(iteratee, 3), keysIn); + } - keys = Object.keys(pair); + /** + * This method is like `_.forIn` except that it iterates over properties of + * `object` in the opposite order. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forIn + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forInRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. + */ + function forInRight(object, iteratee) { + return object == null + ? object + : baseForRight(object, getIteratee(iteratee, 3), keysIn); + } - if (keys.length !== 1) return false; + /** + * Iterates over own enumerable string keyed properties of an object and + * invokes `iteratee` for each property. The iteratee is invoked with three + * arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwnRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ + function forOwn(object, iteratee) { + return object && baseForOwn(object, getIteratee(iteratee, 3)); + } - result[index] = [ keys[0], pair[keys[0]] ]; - } + /** + * This method is like `_.forOwn` except that it iterates over properties of + * `object` in the opposite order. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwn + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwnRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. + */ + function forOwnRight(object, iteratee) { + return object && baseForOwnRight(object, getIteratee(iteratee, 3)); + } - return true; -} + /** + * Creates an array of function property names from own enumerable properties + * of `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the function names. + * @see _.functionsIn + * @example + * + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functions(new Foo); + * // => ['a', 'b'] + */ + function functions(object) { + return object == null ? [] : baseFunctions(object, keys(object)); + } -function constructYamlPairs(data) { - if (data === null) return []; + /** + * Creates an array of function property names from own and inherited + * enumerable properties of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the function names. + * @see _.functions + * @example + * + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functionsIn(new Foo); + * // => ['a', 'b', 'c'] + */ + function functionsIn(object) { + return object == null ? [] : baseFunctions(object, keysIn(object)); + } - var index, length, pair, keys, result, - object = data; + /** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ + function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, path); + return result === undefined ? defaultValue : result; + } - result = new Array(object.length); + /** + * Checks if `path` is a direct property of `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = { 'a': { 'b': 2 } }; + * var other = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.has(object, 'a'); + * // => true + * + * _.has(object, 'a.b'); + * // => true + * + * _.has(object, ['a', 'b']); + * // => true + * + * _.has(other, 'a'); + * // => false + */ + function has(object, path) { + return object != null && hasPath(object, path, baseHas); + } - for (index = 0, length = object.length; index < length; index += 1) { - pair = object[index]; + /** + * Checks if `path` is a direct or inherited property of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.hasIn(object, 'a'); + * // => true + * + * _.hasIn(object, 'a.b'); + * // => true + * + * _.hasIn(object, ['a', 'b']); + * // => true + * + * _.hasIn(object, 'b'); + * // => false + */ + function hasIn(object, path) { + return object != null && hasPath(object, path, baseHasIn); + } - keys = Object.keys(pair); + /** + * Creates an object composed of the inverted keys and values of `object`. + * If `object` contains duplicate values, subsequent values overwrite + * property assignments of previous values. + * + * @static + * @memberOf _ + * @since 0.7.0 + * @category Object + * @param {Object} object The object to invert. + * @returns {Object} Returns the new inverted object. + * @example + * + * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * + * _.invert(object); + * // => { '1': 'c', '2': 'b' } + */ + var invert = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } - result[index] = [ keys[0], pair[keys[0]] ]; - } + result[value] = key; + }, constant(identity)); - return result; -} + /** + * This method is like `_.invert` except that the inverted object is generated + * from the results of running each element of `object` thru `iteratee`. The + * corresponding inverted value of each inverted key is an array of keys + * responsible for generating the inverted value. The iteratee is invoked + * with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.1.0 + * @category Object + * @param {Object} object The object to invert. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Object} Returns the new inverted object. + * @example + * + * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * + * _.invertBy(object); + * // => { '1': ['a', 'c'], '2': ['b'] } + * + * _.invertBy(object, function(value) { + * return 'group' + value; + * }); + * // => { 'group1': ['a', 'c'], 'group2': ['b'] } + */ + var invertBy = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } -module.exports = new Type('tag:yaml.org,2002:pairs', { - kind: 'sequence', - resolve: resolveYamlPairs, - construct: constructYamlPairs -}); + if (hasOwnProperty.call(result, value)) { + result[value].push(key); + } else { + result[value] = [key]; + } + }, getIteratee); + /** + * Invokes the method at `path` of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {...*} [args] The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + * @example + * + * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; + * + * _.invoke(object, 'a[0].b.c.slice', 1, 3); + * // => [2, 3] + */ + var invoke = baseRest(baseInvoke); -/***/ }), + /** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ + function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + } -/***/ 7283: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ + function keysIn(object) { + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); + } -"use strict"; + /** + * The opposite of `_.mapValues`; this method creates an object with the + * same values as `object` and keys generated by running each own enumerable + * string keyed property of `object` thru `iteratee`. The iteratee is invoked + * with three arguments: (value, key, object). + * + * @static + * @memberOf _ + * @since 3.8.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapValues + * @example + * + * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { + * return key + value; + * }); + * // => { 'a1': 1, 'b2': 2 } + */ + function mapKeys(object, iteratee) { + var result = {}; + iteratee = getIteratee(iteratee, 3); + baseForOwn(object, function(value, key, object) { + baseAssignValue(result, iteratee(value, key, object), value); + }); + return result; + } -var Type = __nccwpck_require__(6073); + /** + * Creates an object with the same keys as `object` and values generated + * by running each own enumerable string keyed property of `object` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, key, object). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapKeys + * @example + * + * var users = { + * 'fred': { 'user': 'fred', 'age': 40 }, + * 'pebbles': { 'user': 'pebbles', 'age': 1 } + * }; + * + * _.mapValues(users, function(o) { return o.age; }); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * + * // The `_.property` iteratee shorthand. + * _.mapValues(users, 'age'); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + */ + function mapValues(object, iteratee) { + var result = {}; + iteratee = getIteratee(iteratee, 3); -module.exports = new Type('tag:yaml.org,2002:seq', { - kind: 'sequence', - construct: function (data) { return data !== null ? data : []; } -}); + baseForOwn(object, function(value, key, object) { + baseAssignValue(result, key, iteratee(value, key, object)); + }); + return result; + } + /** + * This method is like `_.assign` except that it recursively merges own and + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively. Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * var object = { + * 'a': [{ 'b': 2 }, { 'd': 4 }] + * }; + * + * var other = { + * 'a': [{ 'c': 3 }, { 'e': 5 }] + * }; + * + * _.merge(object, other); + * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + */ + var merge = createAssigner(function(object, source, srcIndex) { + baseMerge(object, source, srcIndex); + }); -/***/ }), + /** + * This method is like `_.merge` except that it accepts `customizer` which + * is invoked to produce the merged values of the destination and source + * properties. If `customizer` returns `undefined`, merging is handled by the + * method instead. The `customizer` is invoked with six arguments: + * (objValue, srcValue, key, object, source, stack). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} customizer The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * function customizer(objValue, srcValue) { + * if (_.isArray(objValue)) { + * return objValue.concat(srcValue); + * } + * } + * + * var object = { 'a': [1], 'b': [2] }; + * var other = { 'a': [3], 'b': [4] }; + * + * _.mergeWith(object, other, customizer); + * // => { 'a': [1, 3], 'b': [2, 4] } + */ + var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { + baseMerge(object, source, srcIndex, customizer); + }); -/***/ 9548: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * The opposite of `_.pick`; this method creates an object composed of the + * own and inherited enumerable property paths of `object` that are not omitted. + * + * **Note:** This method is considerably slower than `_.pick`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {...(string|string[])} [paths] The property paths to omit. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.omit(object, ['a', 'c']); + * // => { 'b': '2' } + */ + var omit = flatRest(function(object, paths) { + var result = {}; + if (object == null) { + return result; + } + var isDeep = false; + paths = arrayMap(paths, function(path) { + path = castPath(path, object); + isDeep || (isDeep = path.length > 1); + return path; + }); + copyObject(object, getAllKeysIn(object), result); + if (isDeep) { + result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); + } + var length = paths.length; + while (length--) { + baseUnset(result, paths[length]); + } + return result; + }); -"use strict"; + /** + * The opposite of `_.pickBy`; this method creates an object composed of + * the own and inherited enumerable string keyed properties of `object` that + * `predicate` doesn't return truthy for. The predicate is invoked with two + * arguments: (value, key). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The source object. + * @param {Function} [predicate=_.identity] The function invoked per property. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.omitBy(object, _.isNumber); + * // => { 'b': '2' } + */ + function omitBy(object, predicate) { + return pickBy(object, negate(getIteratee(predicate))); + } + /** + * Creates an object composed of the picked `object` properties. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pick(object, ['a', 'c']); + * // => { 'a': 1, 'c': 3 } + */ + var pick = flatRest(function(object, paths) { + return object == null ? {} : basePick(object, paths); + }); -var Type = __nccwpck_require__(6073); + /** + * Creates an object composed of the `object` properties `predicate` returns + * truthy for. The predicate is invoked with two arguments: (value, key). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The source object. + * @param {Function} [predicate=_.identity] The function invoked per property. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pickBy(object, _.isNumber); + * // => { 'a': 1, 'c': 3 } + */ + function pickBy(object, predicate) { + if (object == null) { + return {}; + } + var props = arrayMap(getAllKeysIn(object), function(prop) { + return [prop]; + }); + predicate = getIteratee(predicate); + return basePickBy(object, props, function(value, path) { + return predicate(value, path[0]); + }); + } -var _hasOwnProperty = Object.prototype.hasOwnProperty; + /** + * This method is like `_.get` except that if the resolved value is a + * function it's invoked with the `this` binding of its parent object and + * its result is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to resolve. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; + * + * _.result(object, 'a[0].b.c1'); + * // => 3 + * + * _.result(object, 'a[0].b.c2'); + * // => 4 + * + * _.result(object, 'a[0].b.c3', 'default'); + * // => 'default' + * + * _.result(object, 'a[0].b.c3', _.constant('default')); + * // => 'default' + */ + function result(object, path, defaultValue) { + path = castPath(path, object); -function resolveYamlSet(data) { - if (data === null) return true; + var index = -1, + length = path.length; - var key, object = data; + // Ensure the loop is entered when path is empty. + if (!length) { + length = 1; + object = undefined; + } + while (++index < length) { + var value = object == null ? undefined : object[toKey(path[index])]; + if (value === undefined) { + index = length; + value = defaultValue; + } + object = isFunction(value) ? value.call(object) : value; + } + return object; + } - for (key in object) { - if (_hasOwnProperty.call(object, key)) { - if (object[key] !== null) return false; + /** + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, ['x', '0', 'y', 'z'], 5); + * console.log(object.x[0].y.z); + * // => 5 + */ + function set(object, path, value) { + return object == null ? object : baseSet(object, path, value); } - } - return true; -} + /** + * This method is like `_.set` except that it accepts `customizer` which is + * invoked to produce the objects of `path`. If `customizer` returns `undefined` + * path creation is handled by the method instead. The `customizer` is invoked + * with three arguments: (nsValue, key, nsObject). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * var object = {}; + * + * _.setWith(object, '[0][1]', 'a', Object); + * // => { '0': { '1': 'a' } } + */ + function setWith(object, path, value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return object == null ? object : baseSet(object, path, value, customizer); + } -function constructYamlSet(data) { - return data !== null ? data : {}; -} + /** + * Creates an array of own enumerable string keyed-value pairs for `object` + * which can be consumed by `_.fromPairs`. If `object` is a map or set, its + * entries are returned. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias entries + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the key-value pairs. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.toPairs(new Foo); + * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) + */ + var toPairs = createToPairs(keys); -module.exports = new Type('tag:yaml.org,2002:set', { - kind: 'mapping', - resolve: resolveYamlSet, - construct: constructYamlSet -}); + /** + * Creates an array of own and inherited enumerable string keyed-value pairs + * for `object` which can be consumed by `_.fromPairs`. If `object` is a map + * or set, its entries are returned. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias entriesIn + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the key-value pairs. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.toPairsIn(new Foo); + * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) + */ + var toPairsIn = createToPairs(keysIn); + /** + * An alternative to `_.reduce`; this method transforms `object` to a new + * `accumulator` object which is the result of running each of its own + * enumerable string keyed properties thru `iteratee`, with each invocation + * potentially mutating the `accumulator` object. If `accumulator` is not + * provided, a new object with the same `[[Prototype]]` will be used. The + * iteratee is invoked with four arguments: (accumulator, value, key, object). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 1.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The custom accumulator value. + * @returns {*} Returns the accumulated value. + * @example + * + * _.transform([2, 3, 4], function(result, n) { + * result.push(n *= n); + * return n % 2 == 0; + * }, []); + * // => [4, 9] + * + * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } + */ + function transform(object, iteratee, accumulator) { + var isArr = isArray(object), + isArrLike = isArr || isBuffer(object) || isTypedArray(object); -/***/ }), + iteratee = getIteratee(iteratee, 4); + if (accumulator == null) { + var Ctor = object && object.constructor; + if (isArrLike) { + accumulator = isArr ? new Ctor : []; + } + else if (isObject(object)) { + accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; + } + else { + accumulator = {}; + } + } + (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { + return iteratee(accumulator, value, index, object); + }); + return accumulator; + } -/***/ 3619: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * Removes the property at `path` of `object`. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to unset. + * @returns {boolean} Returns `true` if the property is deleted, else `false`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 7 } }] }; + * _.unset(object, 'a[0].b.c'); + * // => true + * + * console.log(object); + * // => { 'a': [{ 'b': {} }] }; + * + * _.unset(object, ['a', '0', 'b', 'c']); + * // => true + * + * console.log(object); + * // => { 'a': [{ 'b': {} }] }; + */ + function unset(object, path) { + return object == null ? true : baseUnset(object, path); + } -"use strict"; + /** + * This method is like `_.set` except that accepts `updater` to produce the + * value to set. Use `_.updateWith` to customize `path` creation. The `updater` + * is invoked with one argument: (value). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.6.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {Function} updater The function to produce the updated value. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.update(object, 'a[0].b.c', function(n) { return n * n; }); + * console.log(object.a[0].b.c); + * // => 9 + * + * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); + * console.log(object.x[0].y.z); + * // => 0 + */ + function update(object, path, updater) { + return object == null ? object : baseUpdate(object, path, castFunction(updater)); + } + /** + * This method is like `_.update` except that it accepts `customizer` which is + * invoked to produce the objects of `path`. If `customizer` returns `undefined` + * path creation is handled by the method instead. The `customizer` is invoked + * with three arguments: (nsValue, key, nsObject). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.6.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {Function} updater The function to produce the updated value. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * var object = {}; + * + * _.updateWith(object, '[0][1]', _.constant('a'), Object); + * // => { '0': { '1': 'a' } } + */ + function updateWith(object, path, updater, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); + } -var Type = __nccwpck_require__(6073); + /** + * Creates an array of the own enumerable string keyed property values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.values(new Foo); + * // => [1, 2] (iteration order is not guaranteed) + * + * _.values('hi'); + * // => ['h', 'i'] + */ + function values(object) { + return object == null ? [] : baseValues(object, keys(object)); + } -module.exports = new Type('tag:yaml.org,2002:str', { - kind: 'scalar', - construct: function (data) { return data !== null ? data : ''; } -}); + /** + * Creates an array of the own and inherited enumerable string keyed property + * values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.valuesIn(new Foo); + * // => [1, 2, 3] (iteration order is not guaranteed) + */ + function valuesIn(object) { + return object == null ? [] : baseValues(object, keysIn(object)); + } + /*------------------------------------------------------------------------*/ -/***/ }), + /** + * Clamps `number` within the inclusive `lower` and `upper` bounds. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Number + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. + * @example + * + * _.clamp(-10, -5, 5); + * // => -5 + * + * _.clamp(10, -5, 5); + * // => 5 + */ + function clamp(number, lower, upper) { + if (upper === undefined) { + upper = lower; + lower = undefined; + } + if (upper !== undefined) { + upper = toNumber(upper); + upper = upper === upper ? upper : 0; + } + if (lower !== undefined) { + lower = toNumber(lower); + lower = lower === lower ? lower : 0; + } + return baseClamp(toNumber(number), lower, upper); + } -/***/ 9212: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + /** + * Checks if `n` is between `start` and up to, but not including, `end`. If + * `end` is not specified, it's set to `start` with `start` then set to `0`. + * If `start` is greater than `end` the params are swapped to support + * negative ranges. + * + * @static + * @memberOf _ + * @since 3.3.0 + * @category Number + * @param {number} number The number to check. + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. + * @see _.range, _.rangeRight + * @example + * + * _.inRange(3, 2, 4); + * // => true + * + * _.inRange(4, 8); + * // => true + * + * _.inRange(4, 2); + * // => false + * + * _.inRange(2, 2); + * // => false + * + * _.inRange(1.2, 2); + * // => true + * + * _.inRange(5.2, 4); + * // => false + * + * _.inRange(-3, -2, -6); + * // => true + */ + function inRange(number, start, end) { + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + number = toNumber(number); + return baseInRange(number, start, end); + } -"use strict"; + /** + * Produces a random number between the inclusive `lower` and `upper` bounds. + * If only one argument is provided a number between `0` and the given number + * is returned. If `floating` is `true`, or either `lower` or `upper` are + * floats, a floating-point number is returned instead of an integer. + * + * **Note:** JavaScript follows the IEEE-754 standard for resolving + * floating-point values which can produce unexpected results. + * + * @static + * @memberOf _ + * @since 0.7.0 + * @category Number + * @param {number} [lower=0] The lower bound. + * @param {number} [upper=1] The upper bound. + * @param {boolean} [floating] Specify returning a floating-point number. + * @returns {number} Returns the random number. + * @example + * + * _.random(0, 5); + * // => an integer between 0 and 5 + * + * _.random(5); + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 + */ + function random(lower, upper, floating) { + if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { + upper = floating = undefined; + } + if (floating === undefined) { + if (typeof upper == 'boolean') { + floating = upper; + upper = undefined; + } + else if (typeof lower == 'boolean') { + floating = lower; + lower = undefined; + } + } + if (lower === undefined && upper === undefined) { + lower = 0; + upper = 1; + } + else { + lower = toFinite(lower); + if (upper === undefined) { + upper = lower; + lower = 0; + } else { + upper = toFinite(upper); + } + } + if (lower > upper) { + var temp = lower; + lower = upper; + upper = temp; + } + if (floating || lower % 1 || upper % 1) { + var rand = nativeRandom(); + return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); + } + return baseRandom(lower, upper); + } + /*------------------------------------------------------------------------*/ -var Type = __nccwpck_require__(6073); + /** + * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the camel cased string. + * @example + * + * _.camelCase('Foo Bar'); + * // => 'fooBar' + * + * _.camelCase('--foo-bar--'); + * // => 'fooBar' + * + * _.camelCase('__FOO_BAR__'); + * // => 'fooBar' + */ + var camelCase = createCompounder(function(result, word, index) { + word = word.toLowerCase(); + return result + (index ? capitalize(word) : word); + }); -var YAML_DATE_REGEXP = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9])' + // [2] month - '-([0-9][0-9])$'); // [3] day + /** + * Converts the first character of `string` to upper case and the remaining + * to lower case. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to capitalize. + * @returns {string} Returns the capitalized string. + * @example + * + * _.capitalize('FRED'); + * // => 'Fred' + */ + function capitalize(string) { + return upperFirst(toString(string).toLowerCase()); + } -var YAML_TIMESTAMP_REGEXP = new RegExp( - '^([0-9][0-9][0-9][0-9])' + // [1] year - '-([0-9][0-9]?)' + // [2] month - '-([0-9][0-9]?)' + // [3] day - '(?:[Tt]|[ \\t]+)' + // ... - '([0-9][0-9]?)' + // [4] hour - ':([0-9][0-9])' + // [5] minute - ':([0-9][0-9])' + // [6] second - '(?:\\.([0-9]*))?' + // [7] fraction - '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour - '(?::([0-9][0-9]))?))?$'); // [11] tz_minute + /** + * Deburrs `string` by converting + * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) + * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) + * letters to basic Latin letters and removing + * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to deburr. + * @returns {string} Returns the deburred string. + * @example + * + * _.deburr('déjà vu'); + * // => 'deja vu' + */ + function deburr(string) { + string = toString(string); + return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); + } -function resolveYamlTimestamp(data) { - if (data === null) return false; - if (YAML_DATE_REGEXP.exec(data) !== null) return true; - if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; - return false; -} + /** + * Checks if `string` ends with the given target string. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {string} [target] The string to search for. + * @param {number} [position=string.length] The position to search up to. + * @returns {boolean} Returns `true` if `string` ends with `target`, + * else `false`. + * @example + * + * _.endsWith('abc', 'c'); + * // => true + * + * _.endsWith('abc', 'b'); + * // => false + * + * _.endsWith('abc', 'b', 2); + * // => true + */ + function endsWith(string, target, position) { + string = toString(string); + target = baseToString(target); -function constructYamlTimestamp(data) { - var match, year, month, day, hour, minute, second, fraction = 0, - delta = null, tz_hour, tz_minute, date; + var length = string.length; + position = position === undefined + ? length + : baseClamp(toInteger(position), 0, length); - match = YAML_DATE_REGEXP.exec(data); - if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); + var end = position; + position -= target.length; + return position >= 0 && string.slice(position, end) == target; + } - if (match === null) throw new Error('Date resolve error'); + /** + * Converts the characters "&", "<", ">", '"', and "'" in `string` to their + * corresponding HTML entities. + * + * **Note:** No other characters are escaped. To escape additional + * characters use a third-party library like [_he_](https://mths.be/he). + * + * Though the ">" character is escaped for symmetry, characters like + * ">" and "/" don't need escaping in HTML and have no special meaning + * unless they're part of a tag or unquoted attribute value. See + * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) + * (under "semi-related fun fact") for more details. + * + * When working with HTML you should always + * [quote attribute values](http://wonko.com/post/html-escaping) to reduce + * XSS vectors. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escape('fred, barney, & pebbles'); + * // => 'fred, barney, & pebbles' + */ + function escape(string) { + string = toString(string); + return (string && reHasUnescapedHtml.test(string)) + ? string.replace(reUnescapedHtml, escapeHtmlChar) + : string; + } - // match: [1] year [2] month [3] day + /** + * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", + * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escapeRegExp('[lodash](https://lodash.com/)'); + * // => '\[lodash\]\(https://lodash\.com/\)' + */ + function escapeRegExp(string) { + string = toString(string); + return (string && reHasRegExpChar.test(string)) + ? string.replace(reRegExpChar, '\\$&') + : string; + } - year = +(match[1]); - month = +(match[2]) - 1; // JS month starts with 0 - day = +(match[3]); + /** + * Converts `string` to + * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the kebab cased string. + * @example + * + * _.kebabCase('Foo Bar'); + * // => 'foo-bar' + * + * _.kebabCase('fooBar'); + * // => 'foo-bar' + * + * _.kebabCase('__FOO_BAR__'); + * // => 'foo-bar' + */ + var kebabCase = createCompounder(function(result, word, index) { + return result + (index ? '-' : '') + word.toLowerCase(); + }); - if (!match[4]) { // no hour - return new Date(Date.UTC(year, month, day)); - } + /** + * Converts `string`, as space separated words, to lower case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the lower cased string. + * @example + * + * _.lowerCase('--Foo-Bar--'); + * // => 'foo bar' + * + * _.lowerCase('fooBar'); + * // => 'foo bar' + * + * _.lowerCase('__FOO_BAR__'); + * // => 'foo bar' + */ + var lowerCase = createCompounder(function(result, word, index) { + return result + (index ? ' ' : '') + word.toLowerCase(); + }); - // match: [4] hour [5] minute [6] second [7] fraction + /** + * Converts the first character of `string` to lower case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.lowerFirst('Fred'); + * // => 'fred' + * + * _.lowerFirst('FRED'); + * // => 'fRED' + */ + var lowerFirst = createCaseFirst('toLowerCase'); - hour = +(match[4]); - minute = +(match[5]); - second = +(match[6]); + /** + * Pads `string` on the left and right sides if it's shorter than `length`. + * Padding characters are truncated if they can't be evenly divided by `length`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.pad('abc', 8); + * // => ' abc ' + * + * _.pad('abc', 8, '_-'); + * // => '_-abc_-_' + * + * _.pad('abc', 3); + * // => 'abc' + */ + function pad(string, length, chars) { + string = toString(string); + length = toInteger(length); - if (match[7]) { - fraction = match[7].slice(0, 3); - while (fraction.length < 3) { // milli-seconds - fraction += '0'; + var strLength = length ? stringSize(string) : 0; + if (!length || strLength >= length) { + return string; + } + var mid = (length - strLength) / 2; + return ( + createPadding(nativeFloor(mid), chars) + + string + + createPadding(nativeCeil(mid), chars) + ); } - fraction = +fraction; - } - // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute + /** + * Pads `string` on the right side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padEnd('abc', 6); + * // => 'abc ' + * + * _.padEnd('abc', 6, '_-'); + * // => 'abc_-_' + * + * _.padEnd('abc', 3); + * // => 'abc' + */ + function padEnd(string, length, chars) { + string = toString(string); + length = toInteger(length); - if (match[9]) { - tz_hour = +(match[10]); - tz_minute = +(match[11] || 0); - delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds - if (match[9] === '-') delta = -delta; - } + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (string + createPadding(length - strLength, chars)) + : string; + } - date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + /** + * Pads `string` on the left side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padStart('abc', 6); + * // => ' abc' + * + * _.padStart('abc', 6, '_-'); + * // => '_-_abc' + * + * _.padStart('abc', 3); + * // => 'abc' + */ + function padStart(string, length, chars) { + string = toString(string); + length = toInteger(length); - if (delta) date.setTime(date.getTime() - delta); + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (createPadding(length - strLength, chars) + string) + : string; + } - return date; -} + /** + * Converts `string` to an integer of the specified radix. If `radix` is + * `undefined` or `0`, a `radix` of `10` is used unless `value` is a + * hexadecimal, in which case a `radix` of `16` is used. + * + * **Note:** This method aligns with the + * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category String + * @param {string} string The string to convert. + * @param {number} [radix=10] The radix to interpret `value` by. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {number} Returns the converted integer. + * @example + * + * _.parseInt('08'); + * // => 8 + * + * _.map(['6', '08', '10'], _.parseInt); + * // => [6, 8, 10] + */ + function parseInt(string, radix, guard) { + if (guard || radix == null) { + radix = 0; + } else if (radix) { + radix = +radix; + } + return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); + } -function representYamlTimestamp(object /*, style*/) { - return object.toISOString(); -} + /** + * Repeats the given string `n` times. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to repeat. + * @param {number} [n=1] The number of times to repeat the string. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {string} Returns the repeated string. + * @example + * + * _.repeat('*', 3); + * // => '***' + * + * _.repeat('abc', 2); + * // => 'abcabc' + * + * _.repeat('abc', 0); + * // => '' + */ + function repeat(string, n, guard) { + if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { + n = 1; + } else { + n = toInteger(n); + } + return baseRepeat(toString(string), n); + } -module.exports = new Type('tag:yaml.org,2002:timestamp', { - kind: 'scalar', - resolve: resolveYamlTimestamp, - construct: constructYamlTimestamp, - instanceOf: Date, - represent: representYamlTimestamp -}); + /** + * Replaces matches for `pattern` in `string` with `replacement`. + * + * **Note:** This method is based on + * [`String#replace`](https://mdn.io/String/replace). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to modify. + * @param {RegExp|string} pattern The pattern to replace. + * @param {Function|string} replacement The match replacement. + * @returns {string} Returns the modified string. + * @example + * + * _.replace('Hi Fred', 'Fred', 'Barney'); + * // => 'Hi Barney' + */ + function replace() { + var args = arguments, + string = toString(args[0]); + return args.length < 3 ? string : string.replace(args[1], args[2]); + } -/***/ }), + /** + * Converts `string` to + * [snake case](https://en.wikipedia.org/wiki/Snake_case). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the snake cased string. + * @example + * + * _.snakeCase('Foo Bar'); + * // => 'foo_bar' + * + * _.snakeCase('fooBar'); + * // => 'foo_bar' + * + * _.snakeCase('--FOO-BAR--'); + * // => 'foo_bar' + */ + var snakeCase = createCompounder(function(result, word, index) { + return result + (index ? '_' : '') + word.toLowerCase(); + }); -/***/ 250: -/***/ (function(module, exports, __nccwpck_require__) { + /** + * Splits `string` by `separator`. + * + * **Note:** This method is based on + * [`String#split`](https://mdn.io/String/split). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to split. + * @param {RegExp|string} separator The separator pattern to split by. + * @param {number} [limit] The length to truncate results to. + * @returns {Array} Returns the string segments. + * @example + * + * _.split('a-b-c', '-', 2); + * // => ['a', 'b'] + */ + function split(string, separator, limit) { + if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { + separator = limit = undefined; + } + limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; + if (!limit) { + return []; + } + string = toString(string); + if (string && ( + typeof separator == 'string' || + (separator != null && !isRegExp(separator)) + )) { + separator = baseToString(separator); + if (!separator && hasUnicode(string)) { + return castSlice(stringToArray(string), 0, limit); + } + } + return string.split(separator, limit); + } -/* module decorator */ module = __nccwpck_require__.nmd(module); -/** - * @license - * Lodash - * Copyright OpenJS Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ -;(function() { + /** + * Converts `string` to + * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). + * + * @static + * @memberOf _ + * @since 3.1.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the start cased string. + * @example + * + * _.startCase('--foo-bar--'); + * // => 'Foo Bar' + * + * _.startCase('fooBar'); + * // => 'Foo Bar' + * + * _.startCase('__FOO_BAR__'); + * // => 'FOO BAR' + */ + var startCase = createCompounder(function(result, word, index) { + return result + (index ? ' ' : '') + upperFirst(word); + }); - /** Used as a safe reference for `undefined` in pre-ES5 environments. */ - var undefined; + /** + * Checks if `string` starts with the given target string. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {string} [target] The string to search for. + * @param {number} [position=0] The position to search from. + * @returns {boolean} Returns `true` if `string` starts with `target`, + * else `false`. + * @example + * + * _.startsWith('abc', 'a'); + * // => true + * + * _.startsWith('abc', 'b'); + * // => false + * + * _.startsWith('abc', 'b', 1); + * // => true + */ + function startsWith(string, target, position) { + string = toString(string); + position = position == null + ? 0 + : baseClamp(toInteger(position), 0, string.length); - /** Used as the semantic version number. */ - var VERSION = '4.17.21'; + target = baseToString(target); + return string.slice(position, position + target.length) == target; + } - /** Used as the size to enable large array optimizations. */ - var LARGE_ARRAY_SIZE = 200; + /** + * Creates a compiled template function that can interpolate data properties + * in "interpolate" delimiters, HTML-escape interpolated data properties in + * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data + * properties may be accessed as free variables in the template. If a setting + * object is given, it takes precedence over `_.templateSettings` values. + * + * **Note:** In the development build `_.template` utilizes + * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) + * for easier debugging. + * + * For more information on precompiling templates see + * [lodash's custom builds documentation](https://lodash.com/custom-builds). + * + * For more information on Chrome extension sandboxes see + * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category String + * @param {string} [string=''] The template string. + * @param {Object} [options={}] The options object. + * @param {RegExp} [options.escape=_.templateSettings.escape] + * The HTML "escape" delimiter. + * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] + * The "evaluate" delimiter. + * @param {Object} [options.imports=_.templateSettings.imports] + * An object to import into the template as free variables. + * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] + * The "interpolate" delimiter. + * @param {string} [options.sourceURL='lodash.templateSources[n]'] + * The sourceURL of the compiled template. + * @param {string} [options.variable='obj'] + * The data object variable name. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the compiled template function. + * @example + * + * // Use the "interpolate" delimiter to create a compiled template. + * var compiled = _.template('hello <%= user %>!'); + * compiled({ 'user': 'fred' }); + * // => 'hello fred!' + * + * // Use the HTML "escape" delimiter to escape data property values. + * var compiled = _.template('<%- value %>'); + * compiled({ 'value': '