@tsed/cli-core 3.20.16 → 3.21.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/CliCore.js +97 -0
- package/lib/cjs/CliCore.js.map +1 -0
- package/lib/cjs/decorators/command.js +11 -0
- package/lib/cjs/decorators/command.js.map +1 -0
- package/lib/cjs/decorators/index.js +9 -0
- package/lib/cjs/decorators/index.js.map +1 -0
- package/lib/cjs/decorators/on.js +13 -0
- package/lib/cjs/decorators/on.js.map +1 -0
- package/lib/cjs/decorators/onAdd.js +10 -0
- package/lib/cjs/decorators/onAdd.js.map +1 -0
- package/lib/cjs/decorators/onExec.js +10 -0
- package/lib/cjs/decorators/onExec.js.map +1 -0
- package/lib/cjs/decorators/onPostInstall.js +10 -0
- package/lib/cjs/decorators/onPostInstall.js.map +1 -0
- package/lib/cjs/decorators/onPrompt.js +10 -0
- package/lib/cjs/decorators/onPrompt.js.map +1 -0
- package/lib/cjs/domains/CliError.js +14 -0
- package/lib/cjs/domains/CliError.js.map +1 -0
- package/lib/cjs/domains/CommandStoreKeys.js +12 -0
- package/lib/cjs/domains/CommandStoreKeys.js.map +1 -0
- package/lib/cjs/index.js +30 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/CliDefaultOptions.js +3 -0
- package/lib/cjs/interfaces/CliDefaultOptions.js.map +1 -0
- package/lib/cjs/interfaces/CommandMetadata.js +3 -0
- package/lib/cjs/interfaces/CommandMetadata.js.map +1 -0
- package/lib/cjs/interfaces/CommandParameters.js +3 -0
- package/lib/cjs/interfaces/CommandParameters.js.map +1 -0
- package/lib/cjs/interfaces/CommandProvider.js +3 -0
- package/lib/cjs/interfaces/CommandProvider.js.map +1 -0
- package/lib/cjs/interfaces/PackageJson.js +3 -0
- package/lib/cjs/interfaces/PackageJson.js.map +1 -0
- package/lib/cjs/interfaces/ProjectPreferences.js +10 -0
- package/lib/cjs/interfaces/ProjectPreferences.js.map +1 -0
- package/lib/cjs/interfaces/Tasks.js +3 -0
- package/lib/cjs/interfaces/Tasks.js.map +1 -0
- package/lib/cjs/interfaces/index.js +11 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/registries/CommandRegistry.js +13 -0
- package/lib/cjs/registries/CommandRegistry.js.map +1 -0
- package/lib/cjs/services/CliConfiguration.js +21 -0
- package/lib/cjs/services/CliConfiguration.js.map +1 -0
- package/lib/cjs/services/CliDockerComposeYaml.js +83 -0
- package/lib/cjs/services/CliDockerComposeYaml.js.map +1 -0
- package/lib/cjs/services/CliExeca.js +45 -0
- package/lib/cjs/services/CliExeca.js.map +1 -0
- package/lib/cjs/services/CliFs.js +55 -0
- package/lib/cjs/services/CliFs.js.map +1 -0
- package/lib/cjs/services/CliHooks.js +34 -0
- package/lib/cjs/services/CliHooks.js.map +1 -0
- package/lib/cjs/services/CliHttpClient.js +107 -0
- package/lib/cjs/services/CliHttpClient.js.map +1 -0
- package/lib/cjs/services/CliHttpLogClient.js +83 -0
- package/lib/cjs/services/CliHttpLogClient.js.map +1 -0
- package/lib/cjs/services/CliPackageJson.js +16 -0
- package/lib/cjs/services/CliPackageJson.js.map +1 -0
- package/lib/cjs/services/CliPlugins.js +78 -0
- package/lib/cjs/services/CliPlugins.js.map +1 -0
- package/lib/cjs/services/CliProxyAgent.js +87 -0
- package/lib/cjs/services/CliProxyAgent.js.map +1 -0
- package/lib/cjs/services/CliRunScript.js +31 -0
- package/lib/cjs/services/CliRunScript.js.map +1 -0
- package/lib/cjs/services/CliService.js +271 -0
- package/lib/cjs/services/CliService.js.map +1 -0
- package/lib/cjs/services/CliYaml.js +37 -0
- package/lib/cjs/services/CliYaml.js.map +1 -0
- package/lib/cjs/services/NpmRegistryClient.js +121 -0
- package/lib/cjs/services/NpmRegistryClient.js.map +1 -0
- package/lib/cjs/services/ProjectPackageJson.js +420 -0
- package/lib/cjs/services/ProjectPackageJson.js.map +1 -0
- package/lib/cjs/services/Renderer.js +154 -0
- package/lib/cjs/services/Renderer.js.map +1 -0
- package/lib/cjs/services/index.js +17 -0
- package/lib/cjs/services/index.js.map +1 -0
- package/lib/cjs/utils/createInjector.js +35 -0
- package/lib/cjs/utils/createInjector.js.map +1 -0
- package/lib/cjs/utils/createTasksRunner.js +75 -0
- package/lib/cjs/utils/createTasksRunner.js.map +1 -0
- package/lib/cjs/utils/getCommandMetadata.js +19 -0
- package/lib/cjs/utils/getCommandMetadata.js.map +1 -0
- package/lib/cjs/utils/getPackageJson.js +38 -0
- package/lib/cjs/utils/getPackageJson.js.map +1 -0
- package/lib/cjs/utils/hbs/array.js +522 -0
- package/lib/cjs/utils/hbs/array.js.map +1 -0
- package/lib/cjs/utils/hbs/collection.js +66 -0
- package/lib/cjs/utils/hbs/collection.js.map +1 -0
- package/lib/cjs/utils/hbs/comparison.js +437 -0
- package/lib/cjs/utils/hbs/comparison.js.map +1 -0
- package/lib/cjs/utils/hbs/index.js +15 -0
- package/lib/cjs/utils/hbs/index.js.map +1 -0
- package/lib/cjs/utils/hbs/object.js +245 -0
- package/lib/cjs/utils/hbs/object.js.map +1 -0
- package/lib/cjs/utils/hbs/switch.js +14 -0
- package/lib/cjs/utils/hbs/switch.js.map +1 -0
- package/lib/cjs/utils/index.js +14 -0
- package/lib/cjs/utils/index.js.map +1 -0
- package/lib/cjs/utils/isValidVersion.js +11 -0
- package/lib/cjs/utils/isValidVersion.js.map +1 -0
- package/lib/cjs/utils/loadPlugins.js +47 -0
- package/lib/cjs/utils/loadPlugins.js.map +1 -0
- package/lib/cjs/utils/logToCurl.js +19 -0
- package/lib/cjs/utils/logToCurl.js.map +1 -0
- package/lib/cjs/utils/mapCommanderArgs.js +40 -0
- package/lib/cjs/utils/mapCommanderArgs.js.map +1 -0
- package/lib/cjs/utils/mapCommanderOptions.js +16 -0
- package/lib/cjs/utils/mapCommanderOptions.js.map +1 -0
- package/lib/cjs/utils/normalizePath.js +19 -0
- package/lib/cjs/utils/normalizePath.js.map +1 -0
- package/lib/cjs/utils/parseOption.js +27 -0
- package/lib/cjs/utils/parseOption.js.map +1 -0
- package/lib/cjs/utils/patchCommander.js +58 -0
- package/lib/cjs/utils/patchCommander.js.map +1 -0
- package/lib/cjs/utils/renderer/insertAfter.js +17 -0
- package/lib/cjs/utils/renderer/insertAfter.js.map +1 -0
- package/lib/cjs/utils/renderer/insertImport.js +16 -0
- package/lib/cjs/utils/renderer/insertImport.js.map +1 -0
- package/lib/esm/CliCore.js +94 -0
- package/lib/esm/CliCore.js.map +1 -0
- package/lib/esm/decorators/command.js +7 -0
- package/lib/esm/decorators/command.js.map +1 -0
- package/lib/esm/decorators/index.js +6 -0
- package/lib/esm/decorators/index.js.map +1 -0
- package/lib/esm/decorators/on.js +9 -0
- package/lib/esm/decorators/on.js.map +1 -0
- package/lib/esm/decorators/onAdd.js +6 -0
- package/lib/esm/decorators/onAdd.js.map +1 -0
- package/lib/esm/decorators/onExec.js +6 -0
- package/lib/esm/decorators/onExec.js.map +1 -0
- package/lib/esm/decorators/onPostInstall.js +6 -0
- package/lib/esm/decorators/onPostInstall.js.map +1 -0
- package/lib/esm/decorators/onPrompt.js +6 -0
- package/lib/esm/decorators/onPrompt.js.map +1 -0
- package/lib/esm/domains/CliError.js +10 -0
- package/lib/esm/domains/CliError.js.map +1 -0
- package/lib/esm/domains/CommandStoreKeys.js +9 -0
- package/lib/esm/domains/CommandStoreKeys.js.map +1 -0
- package/lib/esm/index.js +12 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/CliDefaultOptions.js +2 -0
- package/lib/esm/interfaces/CliDefaultOptions.js.map +1 -0
- package/lib/esm/interfaces/CommandMetadata.js +2 -0
- package/lib/esm/interfaces/CommandMetadata.js.map +1 -0
- package/lib/esm/interfaces/CommandParameters.js +2 -0
- package/lib/esm/interfaces/CommandParameters.js.map +1 -0
- package/lib/esm/interfaces/CommandProvider.js +2 -0
- package/lib/esm/interfaces/CommandProvider.js.map +1 -0
- package/lib/esm/interfaces/PackageJson.js +2 -0
- package/lib/esm/interfaces/PackageJson.js.map +1 -0
- package/lib/esm/interfaces/ProjectPreferences.js +7 -0
- package/lib/esm/interfaces/ProjectPreferences.js.map +1 -0
- package/lib/esm/interfaces/Tasks.js +2 -0
- package/lib/esm/interfaces/Tasks.js.map +1 -0
- package/lib/esm/interfaces/index.js +8 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/registries/CommandRegistry.js +10 -0
- package/lib/esm/registries/CommandRegistry.js.map +1 -0
- package/lib/esm/services/CliConfiguration.js +18 -0
- package/lib/esm/services/CliConfiguration.js.map +1 -0
- package/lib/esm/services/CliDockerComposeYaml.js +80 -0
- package/lib/esm/services/CliDockerComposeYaml.js.map +1 -0
- package/lib/esm/services/CliExeca.js +42 -0
- package/lib/esm/services/CliExeca.js.map +1 -0
- package/lib/esm/services/CliFs.js +52 -0
- package/lib/esm/services/CliFs.js.map +1 -0
- package/lib/esm/services/CliHooks.js +31 -0
- package/lib/esm/services/CliHooks.js.map +1 -0
- package/lib/esm/services/CliHttpClient.js +104 -0
- package/lib/esm/services/CliHttpClient.js.map +1 -0
- package/lib/esm/services/CliHttpLogClient.js +80 -0
- package/lib/esm/services/CliHttpLogClient.js.map +1 -0
- package/lib/esm/services/CliPackageJson.js +12 -0
- package/lib/esm/services/CliPackageJson.js.map +1 -0
- package/lib/esm/services/CliPlugins.js +75 -0
- package/lib/esm/services/CliPlugins.js.map +1 -0
- package/lib/esm/services/CliProxyAgent.js +84 -0
- package/lib/esm/services/CliProxyAgent.js.map +1 -0
- package/lib/esm/services/CliRunScript.js +28 -0
- package/lib/esm/services/CliRunScript.js.map +1 -0
- package/lib/esm/services/CliService.js +268 -0
- package/lib/esm/services/CliService.js.map +1 -0
- package/lib/esm/services/CliYaml.js +34 -0
- package/lib/esm/services/CliYaml.js.map +1 -0
- package/lib/esm/services/NpmRegistryClient.js +117 -0
- package/lib/esm/services/NpmRegistryClient.js.map +1 -0
- package/lib/esm/services/ProjectPackageJson.js +417 -0
- package/lib/esm/services/ProjectPackageJson.js.map +1 -0
- package/lib/esm/services/Renderer.js +150 -0
- package/lib/esm/services/Renderer.js.map +1 -0
- package/lib/esm/services/index.js +14 -0
- package/lib/esm/services/index.js.map +1 -0
- package/lib/esm/utils/createInjector.js +30 -0
- package/lib/esm/utils/createInjector.js.map +1 -0
- package/lib/esm/utils/createTasksRunner.js +69 -0
- package/lib/esm/utils/createTasksRunner.js.map +1 -0
- package/lib/esm/utils/getCommandMetadata.js +15 -0
- package/lib/esm/utils/getCommandMetadata.js.map +1 -0
- package/lib/esm/utils/getPackageJson.js +33 -0
- package/lib/esm/utils/getPackageJson.js.map +1 -0
- package/lib/esm/utils/hbs/array.js +518 -0
- package/lib/esm/utils/hbs/array.js.map +1 -0
- package/lib/esm/utils/hbs/collection.js +62 -0
- package/lib/esm/utils/hbs/collection.js.map +1 -0
- package/lib/esm/utils/hbs/comparison.js +433 -0
- package/lib/esm/utils/hbs/comparison.js.map +1 -0
- package/lib/esm/utils/hbs/index.js +12 -0
- package/lib/esm/utils/hbs/index.js.map +1 -0
- package/lib/esm/utils/hbs/object.js +241 -0
- package/lib/esm/utils/hbs/object.js.map +1 -0
- package/lib/esm/utils/hbs/switch.js +11 -0
- package/lib/esm/utils/hbs/switch.js.map +1 -0
- package/lib/esm/utils/index.js +11 -0
- package/lib/esm/utils/index.js.map +1 -0
- package/lib/esm/utils/isValidVersion.js +6 -0
- package/lib/esm/utils/isValidVersion.js.map +1 -0
- package/lib/esm/utils/loadPlugins.js +42 -0
- package/lib/esm/utils/loadPlugins.js.map +1 -0
- package/lib/esm/utils/logToCurl.js +14 -0
- package/lib/esm/utils/logToCurl.js.map +1 -0
- package/lib/esm/utils/mapCommanderArgs.js +36 -0
- package/lib/esm/utils/mapCommanderArgs.js.map +1 -0
- package/lib/esm/utils/mapCommanderOptions.js +12 -0
- package/lib/esm/utils/mapCommanderOptions.js.map +1 -0
- package/lib/esm/utils/normalizePath.js +14 -0
- package/lib/esm/utils/normalizePath.js.map +1 -0
- package/lib/esm/utils/parseOption.js +23 -0
- package/lib/esm/utils/parseOption.js.map +1 -0
- package/lib/esm/utils/patchCommander.js +55 -0
- package/lib/esm/utils/patchCommander.js.map +1 -0
- package/lib/esm/utils/renderer/insertAfter.js +13 -0
- package/lib/esm/utils/renderer/insertAfter.js.map +1 -0
- package/lib/esm/utils/renderer/insertImport.js +12 -0
- package/lib/esm/utils/renderer/insertImport.js.map +1 -0
- package/lib/{CliCore.d.ts → types/CliCore.d.ts} +0 -0
- package/lib/{decorators → types/decorators}/command.d.ts +0 -0
- package/lib/{decorators → types/decorators}/index.d.ts +0 -0
- package/lib/{decorators → types/decorators}/on.d.ts +0 -0
- package/lib/{decorators → types/decorators}/onAdd.d.ts +0 -0
- package/lib/{decorators → types/decorators}/onExec.d.ts +0 -0
- package/lib/{decorators → types/decorators}/onPostInstall.d.ts +0 -0
- package/lib/{decorators → types/decorators}/onPrompt.d.ts +0 -0
- package/lib/{domains → types/domains}/CliError.d.ts +0 -0
- package/lib/{domains → types/domains}/CommandStoreKeys.d.ts +0 -0
- package/lib/{index.d.ts → types/index.d.ts} +0 -0
- package/lib/{interfaces → types/interfaces}/CliDefaultOptions.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/CommandMetadata.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/CommandParameters.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/CommandProvider.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/PackageJson.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/ProjectPreferences.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/Tasks.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/index.d.ts +0 -0
- package/lib/{registries → types/registries}/CommandRegistry.d.ts +0 -0
- package/lib/{services → types/services}/CliConfiguration.d.ts +0 -0
- package/lib/{services → types/services}/CliDockerComposeYaml.d.ts +0 -0
- package/lib/{services → types/services}/CliExeca.d.ts +1 -0
- package/lib/{services → types/services}/CliFs.d.ts +1 -0
- package/lib/{services → types/services}/CliHooks.d.ts +0 -0
- package/lib/{services → types/services}/CliHttpClient.d.ts +0 -0
- package/lib/{services → types/services}/CliHttpLogClient.d.ts +0 -0
- package/lib/{services → types/services}/CliPackageJson.d.ts +0 -0
- package/lib/{services → types/services}/CliPlugins.d.ts +0 -0
- package/lib/{services → types/services}/CliProxyAgent.d.ts +0 -0
- package/lib/{services → types/services}/CliRunScript.d.ts +0 -0
- package/lib/{services → types/services}/CliService.d.ts +0 -0
- package/lib/{services → types/services}/CliYaml.d.ts +0 -0
- package/lib/{services → types/services}/NpmRegistryClient.d.ts +0 -0
- package/lib/{services → types/services}/ProjectPackageJson.d.ts +0 -0
- package/lib/{services → types/services}/Renderer.d.ts +0 -0
- package/lib/{services → types/services}/index.d.ts +0 -0
- package/lib/{utils → types/utils}/createInjector.d.ts +0 -0
- package/lib/{utils → types/utils}/createTasksRunner.d.ts +0 -0
- package/lib/{utils → types/utils}/getCommandMetadata.d.ts +0 -0
- package/lib/{utils → types/utils}/getPackageJson.d.ts +0 -0
- package/lib/{utils → types/utils}/hbs/array.d.ts +0 -0
- package/lib/{utils → types/utils}/hbs/collection.d.ts +0 -0
- package/lib/{utils → types/utils}/hbs/comparison.d.ts +0 -0
- package/lib/{utils → types/utils}/hbs/index.d.ts +0 -0
- package/lib/{utils → types/utils}/hbs/object.d.ts +0 -0
- package/lib/{utils → types/utils}/hbs/switch.d.ts +0 -0
- package/lib/{utils → types/utils}/index.d.ts +0 -0
- package/lib/{utils → types/utils}/isValidVersion.d.ts +0 -0
- package/lib/{utils → types/utils}/loadPlugins.d.ts +0 -0
- package/lib/{utils → types/utils}/logToCurl.d.ts +0 -0
- package/lib/{utils → types/utils}/mapCommanderArgs.d.ts +0 -0
- package/lib/{utils → types/utils}/mapCommanderOptions.d.ts +0 -0
- package/lib/{utils → types/utils}/normalizePath.d.ts +0 -0
- package/lib/{utils → types/utils}/parseOption.d.ts +0 -0
- package/lib/{utils → types/utils}/patchCommander.d.ts +0 -0
- package/lib/{utils → types/utils}/renderer/insertAfter.d.ts +0 -0
- package/lib/{utils → types/utils}/renderer/insertImport.d.ts +0 -0
- package/package.json +19 -9
- package/tsconfig.compile.esm.json +12 -0
- package/lib/index.js +0 -3992
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -3832
- package/lib/index.modern.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../src/utils/hbs/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC3E,6DAA6D;AAC7D,aAAa;AACb,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,6DAA6D;AAC7D,aAAa;AACb,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAEpC,MAAM,CAAC,MAAM,OAAO,GAAQ,EAAE,CAAC;AAE/B;;;;;;;;;;;;;GAaG;AAEH,OAAO,CAAC,KAAK,GAAG,UAAU,KAAqB,EAAE,CAAM;IACrD,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AAEH,OAAO,CAAC,QAAQ,GAAG,UAAU,KAAU;IACrC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACzD,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AAEH,OAAO,CAAC,MAAM,GAAG,UAAU,KAAqB,EAAE,CAAS;IACzD,IAAI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IAAI,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE;QACrC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;KAC/B;IACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AAEH,OAAO,CAAC,MAAM,GAAG,UAAU,KAAY;IACrC,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEvC,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,KAAK,EAAE,GAAG;QAC5C,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {getValue, isArray, isNumber, isObject, isString} from \"@tsed/core\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport createFrame from \"create-frame\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport util from \"handlebars-utils\";\n\nexport const helpers: any = {};\n\n/**\n * Returns all of the items in an array after the specified index.\n * Opposite of [before](#before).\n *\n * ```handlebars\n * <!-- array: ['a', 'b', 'c'] -->\n * {{after array 1}}\n * <!-- results in: '[\"c\"]' -->\n * ```\n * @param {Array} `array` Collection\n * @param {Number} `n` Starting index (number of items to exclude)\n * @return {Array} Array exluding `n` items.\n * @api public\n */\n\nhelpers.after = function (array: string | any[], n: any) {\n if (util.isUndefined(array)) return \"\";\n return array.slice(n);\n};\n\n/**\n * Cast the given `value` to an array.\n *\n * ```handlebars\n * {{arrayify \"foo\"}}\n * <!-- results in: [ \"foo\" ] -->\n * ```\n * @param {any} `value`\n * @return {Array}\n * @api public\n */\n\nhelpers.arrayify = function (value: any) {\n return value ? (isArray(value) ? value : [value]) : [];\n};\n\n/**\n * Return all of the items in the collection before the specified\n * count. Opposite of [after](#after).\n *\n * ```handlebars\n * <!-- array: ['a', 'b', 'c'] -->\n * {{before array 2}}\n * <!-- results in: '[\"a\", \"b\"]' -->\n * ```\n * @param {Array} `array`\n * @param {Number} `n`\n * @return {Array} Array excluding items after the given number.\n * @api public\n */\n\nhelpers.before = function (array: string | any[], n: number) {\n if (util.isUndefined(array)) return \"\";\n return array.slice(0, -n);\n};\n\n/**\n * ```handlebars\n * <!-- array: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] -->\n * {{#eachIndex array}}\n * {{item}} is {{index}}\n * {{/eachIndex}}\n * ```\n * @param {Array} `array`\n * @param {Object} `options`\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.eachIndex = function (array: string | any[], options: {fn: (arg0: {item: any; index: number}) => string}) {\n let result = \"\";\n for (let i = 0; i < array.length; i++) {\n result += options.fn({item: array[i], index: i});\n }\n return result;\n};\n\n/**\n * Block helper that filters the given array and renders the block for values that\n * evaluate to `true`, otherwise the inverse block is returned.\n *\n * ```handlebars\n * <!-- array: ['a', 'b', 'c'] -->\n * {{#filter array \"foo\"}}AAA{{else}}BBB{{/filter}}\n * <!-- results in: 'BBB' -->\n * ```\n * @param {Array} `array`\n * @param {any} `value`\n * @param {Object} `options`\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.filter = function (\n array: any[],\n value: any,\n options: {hash: {property: any; prop: any}; fn: (arg0: any) => string; inverse: (arg0: any) => any}\n) {\n let content = \"\";\n let results = [];\n\n // filter on a specific property\n const prop = options.hash && (options.hash.property || options.hash.prop);\n if (prop) {\n results = array.filter(function (val) {\n return value === getValue(val, prop);\n });\n } else {\n // filter on a string value\n results = array.filter(function (v) {\n return value === v;\n });\n }\n\n if (results && results.length > 0) {\n for (let i = 0; i < results.length; i++) {\n content += options.fn(results[i]);\n }\n return content;\n }\n return options.inverse(this);\n};\n\n/**\n * Returns the first item, or first `n` items of an array.\n *\n * ```handlebars\n * {{first \"['a', 'b', 'c', 'd', 'e']\" 2}}\n * <!-- results in: '[\"a\", \"b\"]' -->\n * ```\n * @param {Array} `array`\n * @param {Number} `n` Number of items to return, starting at `0`.\n * @return {Array}\n * @api public\n */\n\nhelpers.first = function (array: string | any[], n: any) {\n if (array === undefined) return \"\";\n if (!isNumber(n)) {\n return array[0];\n }\n return array.slice(0, n);\n};\n\n/**\n * Iterates over each item in an array and exposes the current item\n * in the array as context to the inner block. In addition to\n * the current array item, the helper exposes the following variables\n * to the inner block:\n *\n * - `index`\n * - `total`\n * - `isFirst`\n * - `isLast`\n *\n * Also, `@index` is exposed as a private variable, and additional\n * private variables may be defined as hash arguments.\n *\n * ```handlebars\n * <!-- accounts = [\n * {'name': 'John', 'email': 'john@example.com'},\n * {'name': 'Malcolm', 'email': 'malcolm@example.com'},\n * {'name': 'David', 'email': 'david@example.com'}\n * ] -->\n *\n * {{#forEach accounts}}\n * <a href=\"mailto:{{ email }}\" title=\"Send an email to {{ name }}\">\n * {{ name }}\n * </a>{{#unless isLast}}, {{/unless}}\n * {{/forEach}}\n * ```\n * @source <http://stackoverflow.com/questions/13861007>\n * @param {Array} `array`\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.forEach = function (array: string | any[], options: any) {\n const data = createFrame(options, options.hash);\n const len = array.length;\n let buffer = \"\";\n let i = -1;\n\n while (++i < len) {\n const item = array[i];\n data.index = i;\n item.index = i + 1;\n item.total = len;\n item.isFirst = i === 0;\n item.isLast = i === len - 1;\n buffer += options.fn(item, {data: data});\n }\n return buffer;\n};\n\n/**\n * Block helper that renders the block if an array has the\n * given `value`. Optionally specify an inverse block to render\n * when the array does not have the given value.\n *\n * ```handlebars\n * <!-- array: ['a', 'b', 'c'] -->\n * {{#inArray array \"d\"}}\n * foo\n * {{else}}\n * bar\n * {{/inArray}}\n * <!-- results in: 'bar' -->\n * ```\n * @param {Array} `array`\n * @param {any} `value`\n * @param {Object} `options`\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.inArray = function (array: any[], value: any, options: any) {\n return util.value(util.indexOf(array, value) > -1, this, options);\n};\n\n/**\n * Returns true if `value` is an es5 array.\n *\n * ```handlebars\n * {{isArray \"abc\"}}\n * <!-- results in: false -->\n *\n * <!-- array: [1, 2, 3] -->\n * {{isArray array}}\n * <!-- results in: true -->\n * ```\n * @param {any} `value` The value to test.\n * @return {Boolean}\n * @api public\n */\n\nhelpers.isArray = function (value: any) {\n return Array.isArray(value);\n};\n\n/**\n * Returns the item from `array` at index `idx`.\n *\n * ```handlebars\n * <!-- array: ['a', 'b', 'c'] -->\n * {{itemAt array 1}}\n * <!-- results in: 'b' -->\n * ```\n * @param {Array} `array`\n * @param {Number} `idx`\n * @return {any} `value`\n * @block\n * @api public\n */\n\nhelpers.itemAt = function (array: string | any[], idx: number) {\n array = util.result(array);\n if (isArray(array)) {\n idx = isNumber(idx) ? +idx : 0;\n if (idx < 0) {\n return array[array.length + idx];\n }\n if (idx < array.length) {\n return array[idx];\n }\n }\n};\n\n/**\n * Join all elements of array into a string, optionally using a\n * given separator.\n *\n * ```handlebars\n * <!-- array: ['a', 'b', 'c'] -->\n * {{join array}}\n * <!-- results in: 'a, b, c' -->\n *\n * {{join array '-'}}\n * <!-- results in: 'a-b-c' -->\n * ```\n * @param {Array} `array`\n * @param {String} `separator` The separator to use. Defaults to `, `.\n * @return {String}\n * @api public\n */\n\nhelpers.join = function (array: string | any[], separator: string | undefined) {\n if (isString(array)) return array;\n if (!isArray(array)) return \"\";\n separator = util.isString(separator) ? separator : \", \";\n return array.join(separator);\n};\n\n/**\n * Returns true if the the length of the given `value` is equal\n * to the given `length`. Can be used as a block or inline helper.\n *\n * @param {Array|String} `value`\n * @param {Number} `length`\n * @param {Object} `options`\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.equalsLength = function (value: string | any[], length: number, options: any) {\n if (util.isOptions(length)) {\n options = length;\n length = 0;\n }\n\n let len = 0;\n if (typeof value === \"string\" || Array.isArray(value)) {\n len = value.length;\n }\n\n return util.value(len === length, this, options);\n};\n\n/**\n * Returns the last item, or last `n` items of an array or string.\n * Opposite of [first](#first).\n *\n * ```handlebars\n * <!-- var value = ['a', 'b', 'c', 'd', 'e'] -->\n *\n * {{last value}}\n * <!-- results in: ['e'] -->\n *\n * {{last value 2}}\n * <!-- results in: ['d', 'e'] -->\n *\n * {{last value 3}}\n * <!-- results in: ['c', 'd', 'e'] -->\n * ```\n * @param {Array|String} `value` Array or string.\n * @param {Number} `n` Number of items to return from the end of the array.\n * @return {Array}\n * @api public\n */\n\nhelpers.last = function (value: string | any[], n: number) {\n if (!isArray(value) && typeof value !== \"string\") {\n return \"\";\n }\n if (!isNumber(n)) {\n return value[value.length - 1];\n }\n return value.slice(-Math.abs(n));\n};\n\n/**\n * Returns the length of the given string or array.\n *\n * ```handlebars\n * {{length '[\"a\", \"b\", \"c\"]'}}\n * <!-- results in: 3 -->\n *\n * <!-- results in: myArray = ['a', 'b', 'c', 'd', 'e']; -->\n * {{length myArray}}\n * <!-- results in: 5 -->\n *\n * <!-- results in: myObject = {'a': 'a', 'b': 'b'}; -->\n * {{length myObject}}\n * <!-- results in: 2 -->\n * ```\n * @param {Array|Object|String} `value`\n * @return {Number} The length of the value.\n * @api public\n */\n\nhelpers.length = function (value: string | any[]) {\n if (isObject(value) && !util.isOptions(value)) {\n value = Object.keys(value);\n }\n if (typeof value === \"string\" || Array.isArray(value)) {\n return value.length;\n }\n return 0;\n};\n\n/**\n * Returns a new array, created by calling `function` on each\n * element of the given `array`. For example,\n *\n * ```handlebars\n * <!-- array: ['a', 'b', 'c'], and \"double\" is a\n * fictitious function that duplicates letters -->\n * {{map array double}}\n * <!-- results in: '[\"aa\", \"bb\", \"cc\"]' -->\n * ```\n *\n * @param {Array} `array`\n * @param {Function} `fn`\n * @return {String}\n * @api public\n */\n\nhelpers.map = function (array: string | any[], iter: (arg0: any, arg1: number, arg2: any[]) => any) {\n if (!Array.isArray(array)) return \"\";\n const len = array.length;\n const res = new Array(len);\n let i = -1;\n\n if (typeof iter !== \"function\") {\n return array;\n }\n\n while (++i < len) {\n res[i] = iter(array[i], i, array);\n }\n return res;\n};\n\n/**\n * Map over the given object or array or objects and create an array of values\n * from the given `prop`. Dot-notation may be used (as a string) to get\n * nested properties.\n *\n * ```handlebars\n * // {{pluck items \"data.title\"}}\n * <!-- results in: '[\"aa\", \"bb\", \"cc\"]' -->\n * ```\n * @param {Array|Object} `collection`\n * @param {Function} `prop`\n * @return {String}\n * @api public\n */\n\nhelpers.pluck = function (arr: string | any[], prop: any) {\n if (util.isUndefined(arr)) return \"\";\n const res = [];\n for (let i = 0; i < arr.length; i++) {\n const val = getValue(arr[i], prop);\n if (typeof val !== \"undefined\") {\n res.push(val);\n }\n }\n return res;\n};\n\n/**\n * Reverse the elements in an array, or the characters in a string.\n *\n * ```handlebars\n * <!-- value: 'abcd' -->\n * {{reverse value}}\n * <!-- results in: 'dcba' -->\n * <!-- value: ['a', 'b', 'c', 'd'] -->\n * {{reverse value}}\n * <!-- results in: ['d', 'c', 'b', 'a'] -->\n * ```\n * @param {Array|String} `value`\n * @return {Array|String} Returns the reversed string or array.\n * @api public\n */\n\nhelpers.reverse = function (val: string | []) {\n if (Array.isArray(val)) {\n val.reverse();\n return val;\n }\n if (val && isString(val)) {\n return val.split(\"\").reverse().join(\"\");\n }\n};\n\n/**\n * Block helper that returns the block if the callback returns true\n * for some value in the given array.\n *\n * ```handlebars\n * <!-- array: [1, 'b', 3] -->\n * {{#some array isString}}\n * Render me if the array has a string.\n * {{else}}\n * Render me if it doesn't.\n * {{/some}}\n * <!-- results in: 'Render me if the array has a string.' -->\n * ```\n * @param {Array} `array`\n * @param {Function} `iter` Iteratee\n * @param {Options} Handlebars provided options object\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.some = function (array: string | any[], iter: (arg0: any, arg1: number, arg2: any[]) => any, options: any) {\n if (Array.isArray(array)) {\n for (let i = 0; i < array.length; i++) {\n if (iter(array[i], i, array)) {\n return options.fn(this);\n }\n }\n }\n return options.inverse(this);\n};\n\n/**\n * Sort the given `array`. If an array of objects is passed,\n * you may optionally pass a `key` to sort on as the second\n * argument. You may alternatively pass a sorting function as\n * the second argument.\n *\n * ```handlebars\n * <!-- array: ['b', 'a', 'c'] -->\n * {{sort array}}\n * <!-- results in: '[\"a\", \"b\", \"c\"]' -->\n * ```\n *\n * @param {Array} `array` the array to sort.\n * @param {String|Function} `key` The object key to sort by, or sorting function.\n * @api public\n */\n\nhelpers.sort = function (array: any[], options: any) {\n if (!Array.isArray(array)) return \"\";\n if (getValue(options, \"hash.reverse\")) {\n return array.sort().reverse();\n }\n return array.sort();\n};\n\n/**\n * Block helper that return an array with all duplicate\n * values removed. Best used along with a [each](#each) helper.\n *\n * ```handlebars\n * <!-- array: ['a', 'a', 'c', 'b', 'e', 'e'] -->\n * {{#each (unique array)}}{{.}}{{/each}}\n * <!-- results in: 'acbe' -->\n * ```\n * @param {Array} `array`\n * @param {Object} `options`\n * @return {Array}\n * @api public\n */\n\nhelpers.unique = function (array: any[]) {\n if (util.isUndefined(array)) return \"\";\n\n return array.filter(function (item, index, arr) {\n return arr.indexOf(item) === index;\n });\n};\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import util from "handlebars-utils";
|
|
4
|
+
import { helpers as object } from "./object.js";
|
|
5
|
+
import { helpers as array } from "./array.js";
|
|
6
|
+
const forEach = array.forEach;
|
|
7
|
+
const forOwn = object.forOwn;
|
|
8
|
+
export const helpers = {};
|
|
9
|
+
/**
|
|
10
|
+
* Inline, subexpression, or block helper that returns true (or the block)
|
|
11
|
+
* if the given collection is empty, or false (or the inverse block, if
|
|
12
|
+
* supplied) if the colleciton is not empty.
|
|
13
|
+
*
|
|
14
|
+
* ```handlebars
|
|
15
|
+
* <!-- array: [] -->
|
|
16
|
+
* {{#isEmpty array}}AAA{{else}}BBB{{/isEmpty}}
|
|
17
|
+
* <!-- results in: 'AAA' -->
|
|
18
|
+
*
|
|
19
|
+
* <!-- array: [] -->
|
|
20
|
+
* {{isEmpty array}}
|
|
21
|
+
* <!-- results in: true -->
|
|
22
|
+
* ```
|
|
23
|
+
* @param {Object} `collection`
|
|
24
|
+
* @param {Object} `options`
|
|
25
|
+
* @return {String}
|
|
26
|
+
* @block
|
|
27
|
+
* @api public
|
|
28
|
+
*/
|
|
29
|
+
helpers.isEmpty = function (collection, options) {
|
|
30
|
+
if (!util.isOptions(options)) {
|
|
31
|
+
options = collection;
|
|
32
|
+
return util.fn(true, this, options);
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(collection) && !collection.length) {
|
|
35
|
+
return util.fn(true, this, options);
|
|
36
|
+
}
|
|
37
|
+
const keys = Object.keys(collection);
|
|
38
|
+
const isEmpty = typeof collection === "object" && !keys.length;
|
|
39
|
+
return util.value(isEmpty, this, options);
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Block helper that iterates over an array or object. If
|
|
43
|
+
* an array is given, `.forEach` is called, or if an object
|
|
44
|
+
* is given, `.forOwn` is called, otherwise the inverse block
|
|
45
|
+
* is returned.
|
|
46
|
+
*
|
|
47
|
+
* @param {Object|Array} `collection` The collection to iterate over
|
|
48
|
+
* @param {Object} `options`
|
|
49
|
+
* @return {String}
|
|
50
|
+
* @block
|
|
51
|
+
* @api public
|
|
52
|
+
*/
|
|
53
|
+
helpers.iterate = function (collection, options) {
|
|
54
|
+
if (Array.isArray(collection)) {
|
|
55
|
+
return forEach.apply(null, [collection, options]);
|
|
56
|
+
}
|
|
57
|
+
if (util.isObject(collection)) {
|
|
58
|
+
return forOwn.apply(null, [collection, options]);
|
|
59
|
+
}
|
|
60
|
+
return options.inverse(this);
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../../src/utils/hbs/collection.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,aAAa;AACb,OAAO,IAAI,MA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AAC,UAAU,CAAC,EAAE;QAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;KAClD;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport util from \"handlebars-utils\";\nimport {helpers as object} from \"./object\";\nimport {helpers as array} from \"./array\";\n\nconst forEach = array.forEach;\nconst forOwn = object.forOwn;\nexport const helpers: any = {};\n\n/**\n * Inline, subexpression, or block helper that returns true (or the block)\n * if the given collection is empty, or false (or the inverse block, if\n * supplied) if the colleciton is not empty.\n *\n * ```handlebars\n * <!-- array: [] -->\n * {{#isEmpty array}}AAA{{else}}BBB{{/isEmpty}}\n * <!-- results in: 'AAA' -->\n *\n * <!-- array: [] -->\n * {{isEmpty array}}\n * <!-- results in: true -->\n * ```\n * @param {Object} `collection`\n * @param {Object} `options`\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.isEmpty = function (collection: any, options: any) {\n if (!util.isOptions(options)) {\n options = collection;\n return util.fn(true, this, options);\n }\n\n if (Array.isArray(collection) && !collection.length) {\n return util.fn(true, this, options);\n }\n\n const keys = Object.keys(collection);\n const isEmpty = typeof collection === \"object\" && !keys.length;\n return util.value(isEmpty, this, options);\n};\n\n/**\n * Block helper that iterates over an array or object. If\n * an array is given, `.forEach` is called, or if an object\n * is given, `.forOwn` is called, otherwise the inverse block\n * is returned.\n *\n * @param {Object|Array} `collection` The collection to iterate over\n * @param {Object} `options`\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.iterate = function (collection: any, options: any) {\n if (Array.isArray(collection)) {\n return forEach.apply(null, [collection, options]);\n }\n if (util.isObject(collection)) {\n return forOwn.apply(null, [collection, options]);\n }\n return options.inverse(this);\n};\n"]}
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import { isNumber } from "@tsed/core";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import util from "handlebars-utils";
|
|
5
|
+
export const helpers = {};
|
|
6
|
+
const contains = (val, obj, start) => {
|
|
7
|
+
if (val == null || obj == null || !isNumber(val.length)) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return val.indexOf(obj, start) !== -1;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Helper that renders the block if **both** of the given values
|
|
14
|
+
* are truthy. If an inverse block is specified it will be rendered
|
|
15
|
+
* when falsy. Works as a block helper, inline helper or
|
|
16
|
+
* subexpression.
|
|
17
|
+
*
|
|
18
|
+
* ```handlebars
|
|
19
|
+
* <!-- {great: true, magnificent: true} -->
|
|
20
|
+
* {{#and great magnificent}}A{{else}}B{{/and}}
|
|
21
|
+
* <!-- results in: 'A' -->
|
|
22
|
+
* ```
|
|
23
|
+
* @param {any} `a`
|
|
24
|
+
* @param {any} `b`
|
|
25
|
+
* @param {Object} `options` Handlebars provided options object
|
|
26
|
+
* @return {String}
|
|
27
|
+
* @block
|
|
28
|
+
* @api public
|
|
29
|
+
*/
|
|
30
|
+
helpers.and = (...args) => {
|
|
31
|
+
const len = args.length - 1;
|
|
32
|
+
const options = args[len];
|
|
33
|
+
let val = true;
|
|
34
|
+
for (let i = 0; i < len; i++) {
|
|
35
|
+
if (!args[i]) {
|
|
36
|
+
val = false;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return util.value(val, this, options);
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Render a block when a comparison of the first and third
|
|
44
|
+
* arguments returns true. The second argument is
|
|
45
|
+
* the [arithemetic operator][operators] to use. You may also
|
|
46
|
+
* optionally specify an inverse block to render when falsy.
|
|
47
|
+
*
|
|
48
|
+
* @param `a`
|
|
49
|
+
* @param `operator` The operator to use. Operators must be enclosed in quotes: `">"`, `"="`, `"<="`, and so on.
|
|
50
|
+
* @param `b`
|
|
51
|
+
* @param {Object} `options` Handlebars provided options object
|
|
52
|
+
* @return {String} Block, or if specified the inverse block is rendered if falsey.
|
|
53
|
+
* @block
|
|
54
|
+
* @api public
|
|
55
|
+
*/
|
|
56
|
+
helpers.compare = function (a, operator, b, options) {
|
|
57
|
+
/*eslint eqeqeq: 0*/
|
|
58
|
+
if (arguments.length < 4) {
|
|
59
|
+
throw new Error("handlebars Helper {{compare}} expects 4 arguments");
|
|
60
|
+
}
|
|
61
|
+
let result;
|
|
62
|
+
switch (operator) {
|
|
63
|
+
case "==":
|
|
64
|
+
result = a == b;
|
|
65
|
+
break;
|
|
66
|
+
case "===":
|
|
67
|
+
result = a === b;
|
|
68
|
+
break;
|
|
69
|
+
case "!=":
|
|
70
|
+
result = a != b;
|
|
71
|
+
break;
|
|
72
|
+
case "!==":
|
|
73
|
+
result = a !== b;
|
|
74
|
+
break;
|
|
75
|
+
case "<":
|
|
76
|
+
result = a < b;
|
|
77
|
+
break;
|
|
78
|
+
case ">":
|
|
79
|
+
result = a > b;
|
|
80
|
+
break;
|
|
81
|
+
case "<=":
|
|
82
|
+
result = a <= b;
|
|
83
|
+
break;
|
|
84
|
+
case ">=":
|
|
85
|
+
result = a >= b;
|
|
86
|
+
break;
|
|
87
|
+
case "typeof":
|
|
88
|
+
result = typeof a === b;
|
|
89
|
+
break;
|
|
90
|
+
default: {
|
|
91
|
+
throw new Error("helper {{compare}}: invalid operator: `" + operator + "`");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return util.value(result, this, options);
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Block helper that renders the block if `collection` has the
|
|
98
|
+
* given `value`, using strict equality (`===`) for comparison,
|
|
99
|
+
* otherwise the inverse block is rendered (if specified). If a
|
|
100
|
+
* `startIndex` is specified and is negative, it is used as the
|
|
101
|
+
* offset from the end of the collection.
|
|
102
|
+
*
|
|
103
|
+
* ```handlebars
|
|
104
|
+
* <!-- array = ['a', 'b', 'c'] -->
|
|
105
|
+
* {{#contains array "d"}}
|
|
106
|
+
* This will not be rendered.
|
|
107
|
+
* {{else}}
|
|
108
|
+
* This will be rendered.
|
|
109
|
+
* {{/contains}}
|
|
110
|
+
* ```
|
|
111
|
+
* @param {Array|Object|String} `collection` The collection to iterate over.
|
|
112
|
+
* @param {any} `value` The value to check for.
|
|
113
|
+
* @param {Number} `[startIndex=0]` Optionally define the starting index.
|
|
114
|
+
* @param {Object} `options` Handlebars provided options object.
|
|
115
|
+
* @block
|
|
116
|
+
* @api public
|
|
117
|
+
*/
|
|
118
|
+
helpers.contains = function (collection, value, startIndex, options) {
|
|
119
|
+
if (typeof startIndex === "object") {
|
|
120
|
+
options = startIndex;
|
|
121
|
+
startIndex = undefined;
|
|
122
|
+
}
|
|
123
|
+
const val = contains(collection, value, startIndex);
|
|
124
|
+
return util.value(val, this, options);
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Returns the first value that is not undefined, otherwise the "default" value is returned.
|
|
128
|
+
*
|
|
129
|
+
* @param {any} `value`
|
|
130
|
+
* @param {any} `defaultValue`
|
|
131
|
+
* @return {String}
|
|
132
|
+
* @alias .or
|
|
133
|
+
* @api public
|
|
134
|
+
*/
|
|
135
|
+
helpers.default = (...args) => {
|
|
136
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
137
|
+
if (args[i] != null)
|
|
138
|
+
return args[i];
|
|
139
|
+
}
|
|
140
|
+
return "";
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Block helper that renders a block if `a` is **equal to** `b`.
|
|
144
|
+
* If an inverse block is specified it will be rendered when falsy.
|
|
145
|
+
* You may optionally use the `compare=""` hash argument for the
|
|
146
|
+
* second value.
|
|
147
|
+
*
|
|
148
|
+
* @param {String} `a`
|
|
149
|
+
* @param {String} `b`
|
|
150
|
+
* @param {Object} `options` Handlebars provided options object
|
|
151
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
152
|
+
* @alias is
|
|
153
|
+
* @block
|
|
154
|
+
* @api public
|
|
155
|
+
*/
|
|
156
|
+
helpers.eq = function (a, b, options) {
|
|
157
|
+
if (arguments.length === 2) {
|
|
158
|
+
options = b;
|
|
159
|
+
b = options.hash.compare;
|
|
160
|
+
}
|
|
161
|
+
return util.value(a === b, this, options);
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Block helper that renders a block if `a` is **greater than** `b`.
|
|
165
|
+
*
|
|
166
|
+
* If an inverse block is specified it will be rendered when falsy.
|
|
167
|
+
* You may optionally use the `compare=""` hash argument for the
|
|
168
|
+
* second value.
|
|
169
|
+
*
|
|
170
|
+
* @param {String} `a`
|
|
171
|
+
* @param {String} `b`
|
|
172
|
+
* @param {Object} `options` Handlebars provided options object
|
|
173
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
174
|
+
* @block
|
|
175
|
+
* @api public
|
|
176
|
+
*/
|
|
177
|
+
helpers.gt = function (a, b, options) {
|
|
178
|
+
if (arguments.length === 2) {
|
|
179
|
+
options = b;
|
|
180
|
+
b = options.hash.compare;
|
|
181
|
+
}
|
|
182
|
+
return util.value(a > b, this, options);
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Block helper that renders a block if `a` is **greater than or
|
|
186
|
+
* equal to** `b`.
|
|
187
|
+
*
|
|
188
|
+
* If an inverse block is specified it will be rendered when falsy.
|
|
189
|
+
* You may optionally use the `compare=""` hash argument for the
|
|
190
|
+
* second value.
|
|
191
|
+
*
|
|
192
|
+
* @param {String} `a`
|
|
193
|
+
* @param {String} `b`
|
|
194
|
+
* @param {Object} `options` Handlebars provided options object
|
|
195
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
196
|
+
* @block
|
|
197
|
+
* @api public
|
|
198
|
+
*/
|
|
199
|
+
helpers.gte = function (a, b, options) {
|
|
200
|
+
if (arguments.length === 2) {
|
|
201
|
+
options = b;
|
|
202
|
+
b = options.hash.compare;
|
|
203
|
+
}
|
|
204
|
+
return util.value(a >= b, this, options);
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Block helper that renders a block if `a` is **equal to** `b`.
|
|
208
|
+
* If an inverse block is specified it will be rendered when falsy.
|
|
209
|
+
* Similar to [eq](#eq) but does not do strict equality.
|
|
210
|
+
*
|
|
211
|
+
* @param {any} `a`
|
|
212
|
+
* @param {any} `b`
|
|
213
|
+
* @param {Object} `options` Handlebars provided options object
|
|
214
|
+
* @return {String}
|
|
215
|
+
* @block
|
|
216
|
+
* @api public
|
|
217
|
+
*/
|
|
218
|
+
helpers.is = function (a, b, options) {
|
|
219
|
+
if (arguments.length === 2) {
|
|
220
|
+
options = b;
|
|
221
|
+
b = options.hash.compare;
|
|
222
|
+
}
|
|
223
|
+
return util.value(a == b, this, options);
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Block helper that renders a block if `a` is **not equal to** `b`.
|
|
227
|
+
* If an inverse block is specified it will be rendered when falsy.
|
|
228
|
+
* Similar to [unlessEq](#unlesseq) but does not use strict equality for
|
|
229
|
+
* comparisons.
|
|
230
|
+
*
|
|
231
|
+
* @param {String} `a`
|
|
232
|
+
* @param {String} `b`
|
|
233
|
+
* @param {Object} `options` Handlebars provided options object
|
|
234
|
+
* @return {String}
|
|
235
|
+
* @block
|
|
236
|
+
* @api public
|
|
237
|
+
*/
|
|
238
|
+
helpers.isnt = function (a, b, options) {
|
|
239
|
+
if (arguments.length === 2) {
|
|
240
|
+
options = b;
|
|
241
|
+
b = options.hash.compare;
|
|
242
|
+
}
|
|
243
|
+
return util.value(a != b, this, options);
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Block helper that renders a block if `a` is **less than** `b`.
|
|
247
|
+
*
|
|
248
|
+
* If an inverse block is specified it will be rendered when falsy.
|
|
249
|
+
* You may optionally use the `compare=""` hash argument for the
|
|
250
|
+
* second value.
|
|
251
|
+
*
|
|
252
|
+
* @param {Object} `context`
|
|
253
|
+
* @param {Object} `options` Handlebars provided options object
|
|
254
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
255
|
+
* @block
|
|
256
|
+
* @api public
|
|
257
|
+
*/
|
|
258
|
+
helpers.lt = function (a, b, options) {
|
|
259
|
+
if (arguments.length === 2) {
|
|
260
|
+
options = b;
|
|
261
|
+
b = options.hash.compare;
|
|
262
|
+
}
|
|
263
|
+
return util.value(a < b, this, options);
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Block helper that renders a block if `a` is **less than or
|
|
267
|
+
* equal to** `b`.
|
|
268
|
+
*
|
|
269
|
+
* If an inverse block is specified it will be rendered when falsy.
|
|
270
|
+
* You may optionally use the `compare=""` hash argument for the
|
|
271
|
+
* second value.
|
|
272
|
+
*
|
|
273
|
+
* @param {Sring} `a`
|
|
274
|
+
* @param {Sring} `b`
|
|
275
|
+
* @param {Object} `options` Handlebars provided options object
|
|
276
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
277
|
+
* @block
|
|
278
|
+
* @api public
|
|
279
|
+
*/
|
|
280
|
+
helpers.lte = function (a, b, options) {
|
|
281
|
+
if (arguments.length === 2) {
|
|
282
|
+
options = b;
|
|
283
|
+
b = options.hash.compare;
|
|
284
|
+
}
|
|
285
|
+
return util.value(a <= b, this, options);
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Block helper that renders a block if **neither of** the given values
|
|
289
|
+
* are truthy. If an inverse block is specified it will be rendered
|
|
290
|
+
* when falsy.
|
|
291
|
+
*
|
|
292
|
+
* @param {any} `a`
|
|
293
|
+
* @param {any} `b`
|
|
294
|
+
* @param `options` Handlebars options object
|
|
295
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
296
|
+
* @block
|
|
297
|
+
* @api public
|
|
298
|
+
*/
|
|
299
|
+
helpers.neither = function (a, b, options) {
|
|
300
|
+
return util.value(!a && !b, this, options);
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Returns true if `val` is falsey. Works as a block or inline helper.
|
|
304
|
+
*
|
|
305
|
+
* @param {String} `val`
|
|
306
|
+
* @param {Object} `options` Handlebars provided options object
|
|
307
|
+
* @return {String}
|
|
308
|
+
* @block
|
|
309
|
+
* @api public
|
|
310
|
+
*/
|
|
311
|
+
helpers.not = function (val, options) {
|
|
312
|
+
return util.value(!val, this, options);
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* Block helper that renders a block if **any of** the given values
|
|
316
|
+
* is truthy. If an inverse block is specified it will be rendered
|
|
317
|
+
* when falsy.
|
|
318
|
+
*
|
|
319
|
+
* ```handlebars
|
|
320
|
+
* {{#or a b c}}
|
|
321
|
+
* If any value is true this will be rendered.
|
|
322
|
+
* {{/or}}
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @param {...any} `arguments` Variable number of arguments
|
|
326
|
+
* @param {Object} `options` Handlebars options object
|
|
327
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
328
|
+
* @block
|
|
329
|
+
* @api public
|
|
330
|
+
*/
|
|
331
|
+
helpers.or = function (...args) {
|
|
332
|
+
const len = args.length - 1;
|
|
333
|
+
const options = args[len];
|
|
334
|
+
let val = false;
|
|
335
|
+
for (let i = 0; i < len; i++) {
|
|
336
|
+
if (args[i]) {
|
|
337
|
+
val = true;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return util.value(val, this, options);
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Block helper that always renders the inverse block **unless `a` is
|
|
345
|
+
* is equal to `b`**.
|
|
346
|
+
*
|
|
347
|
+
* @param {String} `a`
|
|
348
|
+
* @param {String} `b`
|
|
349
|
+
* @param {Object} `options` Handlebars provided options object
|
|
350
|
+
* @return {String} Inverse block by default, or block if falsey.
|
|
351
|
+
* @block
|
|
352
|
+
* @api public
|
|
353
|
+
*/
|
|
354
|
+
helpers.unlessEq = function (a, b, options) {
|
|
355
|
+
if (util.isOptions(b)) {
|
|
356
|
+
options = b;
|
|
357
|
+
b = options.hash.compare;
|
|
358
|
+
}
|
|
359
|
+
return util.value(a !== b, this, options);
|
|
360
|
+
};
|
|
361
|
+
/**
|
|
362
|
+
* Block helper that always renders the inverse block **unless `a` is
|
|
363
|
+
* is greater than `b`**.
|
|
364
|
+
*
|
|
365
|
+
* @param {Object} `a` The default value
|
|
366
|
+
* @param {Object} `b` The value to compare
|
|
367
|
+
* @param {Object} `options` Handlebars provided options object
|
|
368
|
+
* @return {String} Inverse block by default, or block if falsey.
|
|
369
|
+
* @block
|
|
370
|
+
* @api public
|
|
371
|
+
*/
|
|
372
|
+
helpers.unlessGt = function (a, b, options) {
|
|
373
|
+
if (util.isOptions(b)) {
|
|
374
|
+
options = b;
|
|
375
|
+
b = options.hash.compare;
|
|
376
|
+
}
|
|
377
|
+
return util.value(a <= b, this, options);
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* Block helper that always renders the inverse block **unless `a` is
|
|
381
|
+
* is less than `b`**.
|
|
382
|
+
*
|
|
383
|
+
* @param {Object} `a` The default value
|
|
384
|
+
* @param {Object} `b` The value to compare
|
|
385
|
+
* @param {Object} `options` Handlebars provided options object
|
|
386
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
387
|
+
* @block
|
|
388
|
+
* @api public
|
|
389
|
+
*/
|
|
390
|
+
helpers.unlessLt = function (a, b, options) {
|
|
391
|
+
if (util.isOptions(b)) {
|
|
392
|
+
options = b;
|
|
393
|
+
b = options.hash.compare;
|
|
394
|
+
}
|
|
395
|
+
return util.value(a >= b, this, options);
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* Block helper that always renders the inverse block **unless `a` is
|
|
399
|
+
* is greater than or equal to `b`**.
|
|
400
|
+
*
|
|
401
|
+
* @param {any} `a`
|
|
402
|
+
* @param {any} `b`
|
|
403
|
+
* @param {Object} `options` Handlebars provided options object
|
|
404
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
405
|
+
* @block
|
|
406
|
+
* @api public
|
|
407
|
+
*/
|
|
408
|
+
helpers.unlessGteq = function (a, b, options) {
|
|
409
|
+
if (util.isOptions(b)) {
|
|
410
|
+
options = b;
|
|
411
|
+
b = options.hash.compare;
|
|
412
|
+
}
|
|
413
|
+
return util.value(a < b, this, options);
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Block helper that always renders the inverse block **unless `a` is
|
|
417
|
+
* is less than or equal to `b`**.
|
|
418
|
+
*
|
|
419
|
+
* @param {any} `a`
|
|
420
|
+
* @param {any} `b`
|
|
421
|
+
* @param {Object} `options` Handlebars provided options object
|
|
422
|
+
* @return {String} Block, or inverse block if specified and falsey.
|
|
423
|
+
* @block
|
|
424
|
+
* @api public
|
|
425
|
+
*/
|
|
426
|
+
helpers.unlessLteq = function (a, b, options) {
|
|
427
|
+
if (util.isOptions(b)) {
|
|
428
|
+
options = b;
|
|
429
|
+
b = options.hash.compare;
|
|
430
|
+
}
|
|
431
|
+
return util.value(a > b, this, options);
|
|
432
|
+
};
|
|
433
|
+
//# sourceMappingURL=comparison.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparison.js","sourceRoot":"","sources":["../../../../src/utils/hbs/comparison.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,6DAA6D;AAC7D,aAAa;AACb,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAEpC,MAAM,CAAC,MAAM,OAAO,GAAQ,EAAE,CAAC;AAE/B,MAAM,QAAQ,GAAG,CAAC,GAAQ,EAAE,GAAQ,EAAE,KAAc,EAAE,EAAE;IACtD,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QACvD,OAAO,KAAK,CAAC;KACd;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CA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AAC","sourcesContent":["import {isNumber} from \"@tsed/core\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport util from \"handlebars-utils\";\n\nexport const helpers: any = {};\n\nconst contains = (val: any, obj: any, start?: number) => {\n if (val == null || obj == null || !isNumber(val.length)) {\n return false;\n }\n return val.indexOf(obj, start) !== -1;\n};\n/**\n * Helper that renders the block if **both** of the given values\n * are truthy. If an inverse block is specified it will be rendered\n * when falsy. Works as a block helper, inline helper or\n * subexpression.\n *\n * ```handlebars\n * <!-- {great: true, magnificent: true} -->\n * {{#and great magnificent}}A{{else}}B{{/and}}\n * <!-- results in: 'A' -->\n * ```\n * @param {any} `a`\n * @param {any} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.and = (...args: any[]) => {\n const len = args.length - 1;\n const options = args[len];\n let val = true;\n\n for (let i = 0; i < len; i++) {\n if (!args[i]) {\n val = false;\n break;\n }\n }\n\n return util.value(val, this, options);\n};\n\n/**\n * Render a block when a comparison of the first and third\n * arguments returns true. The second argument is\n * the [arithemetic operator][operators] to use. You may also\n * optionally specify an inverse block to render when falsy.\n *\n * @param `a`\n * @param `operator` The operator to use. Operators must be enclosed in quotes: `\">\"`, `\"=\"`, `\"<=\"`, and so on.\n * @param `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Block, or if specified the inverse block is rendered if falsey.\n * @block\n * @api public\n */\n\nhelpers.compare = function (a: any, operator: any, b: any, options: any) {\n /*eslint eqeqeq: 0*/\n\n if (arguments.length < 4) {\n throw new Error(\"handlebars Helper {{compare}} expects 4 arguments\");\n }\n\n let result;\n switch (operator) {\n case \"==\":\n result = a == b;\n break;\n case \"===\":\n result = a === b;\n break;\n case \"!=\":\n result = a != b;\n break;\n case \"!==\":\n result = a !== b;\n break;\n case \"<\":\n result = a < b;\n break;\n case \">\":\n result = a > b;\n break;\n case \"<=\":\n result = a <= b;\n break;\n case \">=\":\n result = a >= b;\n break;\n case \"typeof\":\n result = typeof a === b;\n break;\n default: {\n throw new Error(\"helper {{compare}}: invalid operator: `\" + operator + \"`\");\n }\n }\n\n return util.value(result, this, options);\n};\n\n/**\n * Block helper that renders the block if `collection` has the\n * given `value`, using strict equality (`===`) for comparison,\n * otherwise the inverse block is rendered (if specified). If a\n * `startIndex` is specified and is negative, it is used as the\n * offset from the end of the collection.\n *\n * ```handlebars\n * <!-- array = ['a', 'b', 'c'] -->\n * {{#contains array \"d\"}}\n * This will not be rendered.\n * {{else}}\n * This will be rendered.\n * {{/contains}}\n * ```\n * @param {Array|Object|String} `collection` The collection to iterate over.\n * @param {any} `value` The value to check for.\n * @param {Number} `[startIndex=0]` Optionally define the starting index.\n * @param {Object} `options` Handlebars provided options object.\n * @block\n * @api public\n */\n\nhelpers.contains = function (collection: any, value: any, startIndex: number | undefined, options: any) {\n if (typeof startIndex === \"object\") {\n options = startIndex;\n startIndex = undefined;\n }\n const val = contains(collection, value, startIndex);\n return util.value(val, this, options);\n};\n\n/**\n * Returns the first value that is not undefined, otherwise the \"default\" value is returned.\n *\n * @param {any} `value`\n * @param {any} `defaultValue`\n * @return {String}\n * @alias .or\n * @api public\n */\n\nhelpers.default = (...args: any[]) => {\n for (let i = 0; i < args.length - 1; i++) {\n if (args[i] != null) return args[i];\n }\n return \"\";\n};\n\n/**\n * Block helper that renders a block if `a` is **equal to** `b`.\n * If an inverse block is specified it will be rendered when falsy.\n * You may optionally use the `compare=\"\"` hash argument for the\n * second value.\n *\n * @param {String} `a`\n * @param {String} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @alias is\n * @block\n * @api public\n */\n\nhelpers.eq = function (a: any, b: any, options: any) {\n if (arguments.length === 2) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a === b, this, options);\n};\n\n/**\n * Block helper that renders a block if `a` is **greater than** `b`.\n *\n * If an inverse block is specified it will be rendered when falsy.\n * You may optionally use the `compare=\"\"` hash argument for the\n * second value.\n *\n * @param {String} `a`\n * @param {String} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @block\n * @api public\n */\n\nhelpers.gt = function (a: any, b: any, options: any) {\n if (arguments.length === 2) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a > b, this, options);\n};\n\n/**\n * Block helper that renders a block if `a` is **greater than or\n * equal to** `b`.\n *\n * If an inverse block is specified it will be rendered when falsy.\n * You may optionally use the `compare=\"\"` hash argument for the\n * second value.\n *\n * @param {String} `a`\n * @param {String} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @block\n * @api public\n */\n\nhelpers.gte = function (a: any, b: any, options: any) {\n if (arguments.length === 2) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a >= b, this, options);\n};\n\n/**\n * Block helper that renders a block if `a` is **equal to** `b`.\n * If an inverse block is specified it will be rendered when falsy.\n * Similar to [eq](#eq) but does not do strict equality.\n *\n * @param {any} `a`\n * @param {any} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String}\n * @block\n * @api public\n */\nhelpers.is = function (a: any, b: any, options: any) {\n if (arguments.length === 2) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a == b, this, options);\n};\n\n/**\n * Block helper that renders a block if `a` is **not equal to** `b`.\n * If an inverse block is specified it will be rendered when falsy.\n * Similar to [unlessEq](#unlesseq) but does not use strict equality for\n * comparisons.\n *\n * @param {String} `a`\n * @param {String} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.isnt = function (a: any, b: any, options: any) {\n if (arguments.length === 2) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a != b, this, options);\n};\n\n/**\n * Block helper that renders a block if `a` is **less than** `b`.\n *\n * If an inverse block is specified it will be rendered when falsy.\n * You may optionally use the `compare=\"\"` hash argument for the\n * second value.\n *\n * @param {Object} `context`\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @block\n * @api public\n */\n\nhelpers.lt = function (a: any, b: any, options: any) {\n if (arguments.length === 2) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a < b, this, options);\n};\n\n/**\n * Block helper that renders a block if `a` is **less than or\n * equal to** `b`.\n *\n * If an inverse block is specified it will be rendered when falsy.\n * You may optionally use the `compare=\"\"` hash argument for the\n * second value.\n *\n * @param {Sring} `a`\n * @param {Sring} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @block\n * @api public\n */\n\nhelpers.lte = function (a: any, b: any, options: any) {\n if (arguments.length === 2) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a <= b, this, options);\n};\n\n/**\n * Block helper that renders a block if **neither of** the given values\n * are truthy. If an inverse block is specified it will be rendered\n * when falsy.\n *\n * @param {any} `a`\n * @param {any} `b`\n * @param `options` Handlebars options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @block\n * @api public\n */\n\nhelpers.neither = function (a: any, b: any, options: any) {\n return util.value(!a && !b, this, options);\n};\n\n/**\n * Returns true if `val` is falsey. Works as a block or inline helper.\n *\n * @param {String} `val`\n * @param {Object} `options` Handlebars provided options object\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.not = function (val: any, options: any) {\n return util.value(!val, this, options);\n};\n\n/**\n * Block helper that renders a block if **any of** the given values\n * is truthy. If an inverse block is specified it will be rendered\n * when falsy.\n *\n * ```handlebars\n * {{#or a b c}}\n * If any value is true this will be rendered.\n * {{/or}}\n * ```\n *\n * @param {...any} `arguments` Variable number of arguments\n * @param {Object} `options` Handlebars options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @block\n * @api public\n */\n\nhelpers.or = function (...args: any[]) {\n const len = args.length - 1;\n const options = args[len];\n let val = false;\n\n for (let i = 0; i < len; i++) {\n if (args[i]) {\n val = true;\n break;\n }\n }\n return util.value(val, this, options);\n};\n\n/**\n * Block helper that always renders the inverse block **unless `a` is\n * is equal to `b`**.\n *\n * @param {String} `a`\n * @param {String} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Inverse block by default, or block if falsey.\n * @block\n * @api public\n */\n\nhelpers.unlessEq = function (a: any, b: any, options: any) {\n if (util.isOptions(b)) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a !== b, this, options);\n};\n\n/**\n * Block helper that always renders the inverse block **unless `a` is\n * is greater than `b`**.\n *\n * @param {Object} `a` The default value\n * @param {Object} `b` The value to compare\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Inverse block by default, or block if falsey.\n * @block\n * @api public\n */\n\nhelpers.unlessGt = function (a: any, b: any, options: any) {\n if (util.isOptions(b)) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a <= b, this, options);\n};\n\n/**\n * Block helper that always renders the inverse block **unless `a` is\n * is less than `b`**.\n *\n * @param {Object} `a` The default value\n * @param {Object} `b` The value to compare\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @block\n * @api public\n */\n\nhelpers.unlessLt = function (a: any, b: any, options: any) {\n if (util.isOptions(b)) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a >= b, this, options);\n};\n\n/**\n * Block helper that always renders the inverse block **unless `a` is\n * is greater than or equal to `b`**.\n *\n * @param {any} `a`\n * @param {any} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @block\n * @api public\n */\n\nhelpers.unlessGteq = function (a: any, b: any, options: any) {\n if (util.isOptions(b)) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a < b, this, options);\n};\n\n/**\n * Block helper that always renders the inverse block **unless `a` is\n * is less than or equal to `b`**.\n *\n * @param {any} `a`\n * @param {any} `b`\n * @param {Object} `options` Handlebars provided options object\n * @return {String} Block, or inverse block if specified and falsey.\n * @block\n * @api public\n */\n\nhelpers.unlessLteq = function (a: any, b: any, options: any) {\n if (util.isOptions(b)) {\n options = b;\n b = options.hash.compare;\n }\n return util.value(a > b, this, options);\n};\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import handlebars from "handlebars";
|
|
2
|
+
import { helpers as comparison } from "./comparison.js";
|
|
3
|
+
import { helpers as array } from "./array.js";
|
|
4
|
+
import { helpers as object } from "./object.js";
|
|
5
|
+
import { helpers as collection } from "./collection.js";
|
|
6
|
+
import { helpers as switchHelpers } from "./switch.js";
|
|
7
|
+
handlebars.registerHelper(array);
|
|
8
|
+
handlebars.registerHelper(object);
|
|
9
|
+
handlebars.registerHelper(collection);
|
|
10
|
+
handlebars.registerHelper(comparison);
|
|
11
|
+
handlebars.registerHelper(switchHelpers);
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/hbs/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,UAAU,CAAC;AAElD,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AACjC,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAClC,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;AACtC,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;AACtC,UAAU,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import handlebars from \"handlebars\";\nimport {helpers as comparison} from \"./comparison\";\nimport {helpers as array} from \"./array\";\nimport {helpers as object} from \"./object\";\nimport {helpers as collection} from \"./collection\";\nimport {helpers as switchHelpers} from \"./switch\";\n\nhandlebars.registerHelper(array);\nhandlebars.registerHelper(object);\nhandlebars.registerHelper(collection);\nhandlebars.registerHelper(comparison);\nhandlebars.registerHelper(switchHelpers);\n"]}
|