Skip to content

Commit 9c19511

Browse files
committed
Remove redundant functions
1 parent b7e2118 commit 9c19511

20 files changed

Lines changed: 181 additions & 205 deletions

dist/angular-ts.esm.js

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Version: 0.27.0 - May 16, 2026 06:37:44 */
1+
/* Version: 0.27.0 - May 16, 2026 06:50:12 */
22
/**
33
* Canonical token names for the built-in injectables exposed by the core `ng`
44
* module.
@@ -2141,48 +2141,22 @@ function createPersistentProxy(target, key, storage, options = {}) {
21412141
});
21422142
}
21432143

2144-
/**
2145-
* A value is "injectable" if it is a function, or if it is an ng1
2146-
* array-notation-style array where the head is strings and the tail is a
2147-
* function.
2148-
*/
2149-
function isInjectable(val) {
2150-
if (isArray(val) && val.length > 0) {
2151-
const lastIndex = val.length - 1;
2152-
for (let i = 0; i < lastIndex; i++) {
2153-
if (!isString(val[i]))
2154-
return false;
2155-
}
2156-
return isFunction(val[lastIndex]);
2157-
}
2158-
return isFunction(val);
2159-
}
2160-
/**
2161-
* It is probably a Promise if it's an object and it has a function `then`.
2162-
*/
2163-
function isPromise(obj) {
2164-
return (obj !== null &&
2165-
typeof obj === "object" &&
2166-
isFunction(obj.then));
2167-
}
2168-
21692144
const BADARG = "badarg";
21702145
const reasons = new Map([
21712146
[notNullOrUndefined, "required"],
21722147
[isArray, "notarray"],
2173-
[isInjectable, "notinjectable"],
21742148
[isDefined, "required"],
21752149
[isString, "notstring"],
21762150
]);
2177-
function getReason(val) {
2178-
return reasons.get(val) ?? "fail";
2151+
function getReason(val, reason) {
2152+
return reason ?? reasons.get(val) ?? "fail";
21792153
}
21802154
/**
21812155
* Validate a value using a predicate function.
21822156
* Throws if the predicate returns false.
21832157
* IMPORTANT: use this function only for developer errors and not user/data errors.
21842158
*/
2185-
function validate(fn, arg, name) {
2159+
function validate(fn, arg, name, reason) {
21862160
if (fn(arg)) {
21872161
return arg;
21882162
}
@@ -2193,7 +2167,7 @@ function validate(fn, arg, name) {
21932167
catch {
21942168
serialized = String(arg);
21952169
}
2196-
throw new TypeError(`badarg:${getReason(fn)} ${name}=${serialized}`);
2170+
throw new TypeError(`badarg:${getReason(fn, reason)} ${name}=${serialized}`);
21972171
}
21982172
function validateRequired(arg, name) {
21992173
return validate(notNullOrUndefined, arg, name);
@@ -2474,6 +2448,23 @@ function supportObject(delegate) {
24742448
};
24752449
}
24762450

2451+
/**
2452+
* A value is injectable if it is a function, class constructor, or ng1
2453+
* array-notation-style value where dependency names are strings and the final
2454+
* item is callable.
2455+
*/
2456+
function isInjectable(val) {
2457+
if (isArray(val) && val.length > 0) {
2458+
const lastIndex = val.length - 1;
2459+
for (let i = 0; i < lastIndex; i++) {
2460+
if (!isString(val[i]))
2461+
return false;
2462+
}
2463+
return isFunction(val[lastIndex]);
2464+
}
2465+
return isFunction(val);
2466+
}
2467+
24772468
let eventBusInstance;
24782469
/**
24792470
* Configurable provider for the application-wide {@link PubSub} event bus.
@@ -2715,7 +2706,7 @@ class NgModule {
27152706
* @returns {NgModule}
27162707
*/
27172708
config(configFn) {
2718-
validate(isInjectable, configFn, "configFn");
2709+
validate(isInjectable, configFn, "configFn", "notinjectable");
27192710
this._configBlocks.push([_injector, "invoke", [configFn]]);
27202711
return this;
27212712
}
@@ -2724,7 +2715,7 @@ class NgModule {
27242715
* @returns {NgModule}
27252716
*/
27262717
run(block) {
2727-
validate(isInjectable, block, "block");
2718+
validate(isInjectable, block, "block", "notinjectable");
27282719
this._runBlocks.push(block);
27292720
return this;
27302721
}
@@ -22366,13 +22357,13 @@ function stringify(value) {
2236622357
return "undefined";
2236722358
if (isNull(item))
2236822359
return "null";
22369-
if (isPromise(item))
22360+
if (isPromiseLike(item))
2237022361
return "[Promise]";
2237122362
if (isRejection(item))
2237222363
return String(item._transitionRejection);
2237322364
if (hasToString(item))
2237422365
return String(callFunction(item.toString, item));
22375-
if (isInjectable(item))
22366+
if (isFunction(item))
2237622367
return functionToString(item);
2237722368
return item;
2237822369
}
@@ -25984,7 +25975,7 @@ class TransitionHook {
2598425975
static _invokeHooks(hooks, doneCallback) {
2598525976
for (let idx = 0; idx < hooks.length; idx++) {
2598625977
const hookResult = hooks[idx]._invokeHook();
25987-
if (isPromise(hookResult)) {
25978+
if (isPromiseLike(hookResult)) {
2598825979
return TransitionHook._chainThenDone(hooks, idx + 1, Promise.resolve(hookResult), doneCallback);
2598925980
}
2599025981
}
@@ -26007,7 +25998,7 @@ class TransitionHook {
2600725998
}
2600825999
/** @internal */
2600926000
static _logRejectedResult(hook, result) {
26010-
if (isPromise(result)) {
26001+
if (isPromiseLike(result)) {
2601126002
Promise.resolve(result).catch((err) => {
2601226003
hook._logError(Rejection.normalize(err));
2601326004
});
@@ -26092,7 +26083,7 @@ class TransitionHook {
2609226083
return notCurrent;
2609326084
try {
2609426085
const result = this._invokeCallback(hook);
26095-
if (!this._type._synchronous && isPromise(result)) {
26086+
if (!this._type._synchronous && isPromiseLike(result)) {
2609626087
return this._handleAsyncResult(result);
2609726088
}
2609826089
return this._handleResult(result);
@@ -26113,7 +26104,7 @@ class TransitionHook {
2611326104
const notCurrent = this._getNotCurrentRejection();
2611426105
if (notCurrent)
2611526106
return notCurrent;
26116-
if (isPromise(result)) {
26107+
if (isPromiseLike(result)) {
2611726108
return this._handleAsyncHookResult(Promise.resolve(result));
2611826109
}
2611926110
if (result === false) {

dist/angular-ts.umd.js

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Version: 0.27.0 - May 16, 2026 06:37:41 */
1+
/* Version: 0.27.0 - May 16, 2026 06:50:09 */
22
(function (global, factory) {
33
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
44
typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -2147,48 +2147,22 @@
21472147
});
21482148
}
21492149

2150-
/**
2151-
* A value is "injectable" if it is a function, or if it is an ng1
2152-
* array-notation-style array where the head is strings and the tail is a
2153-
* function.
2154-
*/
2155-
function isInjectable(val) {
2156-
if (isArray(val) && val.length > 0) {
2157-
const lastIndex = val.length - 1;
2158-
for (let i = 0; i < lastIndex; i++) {
2159-
if (!isString(val[i]))
2160-
return false;
2161-
}
2162-
return isFunction(val[lastIndex]);
2163-
}
2164-
return isFunction(val);
2165-
}
2166-
/**
2167-
* It is probably a Promise if it's an object and it has a function `then`.
2168-
*/
2169-
function isPromise(obj) {
2170-
return (obj !== null &&
2171-
typeof obj === "object" &&
2172-
isFunction(obj.then));
2173-
}
2174-
21752150
const BADARG = "badarg";
21762151
const reasons = new Map([
21772152
[notNullOrUndefined, "required"],
21782153
[isArray, "notarray"],
2179-
[isInjectable, "notinjectable"],
21802154
[isDefined, "required"],
21812155
[isString, "notstring"],
21822156
]);
2183-
function getReason(val) {
2184-
return reasons.get(val) ?? "fail";
2157+
function getReason(val, reason) {
2158+
return reason ?? reasons.get(val) ?? "fail";
21852159
}
21862160
/**
21872161
* Validate a value using a predicate function.
21882162
* Throws if the predicate returns false.
21892163
* IMPORTANT: use this function only for developer errors and not user/data errors.
21902164
*/
2191-
function validate(fn, arg, name) {
2165+
function validate(fn, arg, name, reason) {
21922166
if (fn(arg)) {
21932167
return arg;
21942168
}
@@ -2199,7 +2173,7 @@
21992173
catch {
22002174
serialized = String(arg);
22012175
}
2202-
throw new TypeError(`badarg:${getReason(fn)} ${name}=${serialized}`);
2176+
throw new TypeError(`badarg:${getReason(fn, reason)} ${name}=${serialized}`);
22032177
}
22042178
function validateRequired(arg, name) {
22052179
return validate(notNullOrUndefined, arg, name);
@@ -2480,6 +2454,23 @@
24802454
};
24812455
}
24822456

2457+
/**
2458+
* A value is injectable if it is a function, class constructor, or ng1
2459+
* array-notation-style value where dependency names are strings and the final
2460+
* item is callable.
2461+
*/
2462+
function isInjectable(val) {
2463+
if (isArray(val) && val.length > 0) {
2464+
const lastIndex = val.length - 1;
2465+
for (let i = 0; i < lastIndex; i++) {
2466+
if (!isString(val[i]))
2467+
return false;
2468+
}
2469+
return isFunction(val[lastIndex]);
2470+
}
2471+
return isFunction(val);
2472+
}
2473+
24832474
let eventBusInstance;
24842475
/**
24852476
* Configurable provider for the application-wide {@link PubSub} event bus.
@@ -2721,7 +2712,7 @@
27212712
* @returns {NgModule}
27222713
*/
27232714
config(configFn) {
2724-
validate(isInjectable, configFn, "configFn");
2715+
validate(isInjectable, configFn, "configFn", "notinjectable");
27252716
this._configBlocks.push([_injector, "invoke", [configFn]]);
27262717
return this;
27272718
}
@@ -2730,7 +2721,7 @@
27302721
* @returns {NgModule}
27312722
*/
27322723
run(block) {
2733-
validate(isInjectable, block, "block");
2724+
validate(isInjectable, block, "block", "notinjectable");
27342725
this._runBlocks.push(block);
27352726
return this;
27362727
}
@@ -22372,13 +22363,13 @@
2237222363
return "undefined";
2237322364
if (isNull(item))
2237422365
return "null";
22375-
if (isPromise(item))
22366+
if (isPromiseLike(item))
2237622367
return "[Promise]";
2237722368
if (isRejection(item))
2237822369
return String(item._transitionRejection);
2237922370
if (hasToString(item))
2238022371
return String(callFunction(item.toString, item));
22381-
if (isInjectable(item))
22372+
if (isFunction(item))
2238222373
return functionToString(item);
2238322374
return item;
2238422375
}
@@ -25990,7 +25981,7 @@
2599025981
static _invokeHooks(hooks, doneCallback) {
2599125982
for (let idx = 0; idx < hooks.length; idx++) {
2599225983
const hookResult = hooks[idx]._invokeHook();
25993-
if (isPromise(hookResult)) {
25984+
if (isPromiseLike(hookResult)) {
2599425985
return TransitionHook._chainThenDone(hooks, idx + 1, Promise.resolve(hookResult), doneCallback);
2599525986
}
2599625987
}
@@ -26013,7 +26004,7 @@
2601326004
}
2601426005
/** @internal */
2601526006
static _logRejectedResult(hook, result) {
26016-
if (isPromise(result)) {
26007+
if (isPromiseLike(result)) {
2601726008
Promise.resolve(result).catch((err) => {
2601826009
hook._logError(Rejection.normalize(err));
2601926010
});
@@ -26098,7 +26089,7 @@
2609826089
return notCurrent;
2609926090
try {
2610026091
const result = this._invokeCallback(hook);
26101-
if (!this._type._synchronous && isPromise(result)) {
26092+
if (!this._type._synchronous && isPromiseLike(result)) {
2610226093
return this._handleAsyncResult(result);
2610326094
}
2610426095
return this._handleResult(result);
@@ -26119,7 +26110,7 @@
2611926110
const notCurrent = this._getNotCurrentRejection();
2612026111
if (notCurrent)
2612126112
return notCurrent;
26122-
if (isPromise(result)) {
26113+
if (isPromiseLike(result)) {
2612326114
return this._handleAsyncHookResult(Promise.resolve(result));
2612426115
}
2612526116
if (result === false) {

dist/angular-ts.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-ts.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core/di/injectable.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { isArray, isString, isFunction } from '../../shared/utils.js';
2+
3+
/**
4+
* A value is injectable if it is a function, class constructor, or ng1
5+
* array-notation-style value where dependency names are strings and the final
6+
* item is callable.
7+
*/
8+
function isInjectable(val) {
9+
if (isArray(val) && val.length > 0) {
10+
const lastIndex = val.length - 1;
11+
for (let i = 0; i < lastIndex; i++) {
12+
if (!isString(val[i]))
13+
return false;
14+
}
15+
return isFunction(val[lastIndex]);
16+
}
17+
return isFunction(val);
18+
}
19+
20+
export { isInjectable };

dist/core/di/ng-module/ng-module.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { isString, isArray, isDefined, isFunction, isObject } from '../../../shared/utils.js';
22
import { _provide, _injector, _compileProvider, _animateProvider, _filterProvider, _controllerProvider, _stateProvider, _wasm, _worker, _rest, _sse, _websocket, _webTransport, _webComponent, _eventBus } from '../../../injection-tokens.js';
3-
import { isInjectable } from '../../../shared/predicates.js';
3+
import { isInjectable } from '../injectable.js';
44
import { validate, validateRequired } from '../../../shared/validate.js';
55
import { createTopicService } from '../../../services/pubsub/pubsub.js';
66

@@ -56,7 +56,7 @@ class NgModule {
5656
* @returns {NgModule}
5757
*/
5858
config(configFn) {
59-
validate(isInjectable, configFn, "configFn");
59+
validate(isInjectable, configFn, "configFn", "notinjectable");
6060
this._configBlocks.push([_injector, "invoke", [configFn]]);
6161
return this;
6262
}
@@ -65,7 +65,7 @@ class NgModule {
6565
* @returns {NgModule}
6666
*/
6767
run(block) {
68-
validate(isInjectable, block, "block");
68+
validate(isInjectable, block, "block", "notinjectable");
6969
this._runBlocks.push(block);
7070
return this;
7171
}

dist/router/params/param.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isInjectable } from '../../shared/predicates.js';
1+
import { isInjectable } from '../../core/di/injectable.js';
22
import { isDefined, isUndefined, isString, hasOwn, assertDefined, isInstanceOf, isNullOrUndefined, isArray } from '../../shared/utils.js';
33
import { ParamType } from './param-type.js';
44

0 commit comments

Comments
 (0)