MCPcopy Index your code
hub / github.com/angular/angular / lengthOrSize

Function lengthOrSize

packages/forms/src/validators.ts:38–49  ·  view source on GitHub ↗

* Extract the length property in case it's an array or a string. * Extract the size property in case it's a set. * Return null else. * @param value Either an array, set or undefined.

(value: unknown)

Source from the content-addressed store, hash-verified

36 * @param value Either an array, set or undefined.
37 */
38function lengthOrSize(value: unknown): number | null {
39 // non-strict comparison is intentional, to check for both `null` and `undefined` values
40 if (value == null) {
41 return null;
42 } else if (Array.isArray(value) || typeof value === 'string') {
43 return value.length;
44 } else if (value instanceof Set) {
45 return value.size;
46 }
47
48 return null;
49}
50
51/**
52 * @description

Callers 3

isEmptyInputValueFunction · 0.85
minLengthValidatorFunction · 0.85
maxLengthValidatorFunction · 0.85

Calls 1

isArrayMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…