MCPcopy Create free account
hub / github.com/microsoft/SandDance / count

Function count

docs/app/js/sanddance-app.js:87783–87790  ·  view source on GitHub ↗
(container)

Source from the content-addressed store, hash-verified

87781var ERR_NOT_OBJECT = "count(): argument not an object";
87782var ERR_NOT_CONTAINER = "count(): argument not a container";
87783function count(container) {
87784 if (!isObject(container)) throw new Error(ERR_NOT_OBJECT);
87785 if (typeof container.count === "function") return container.count();
87786 if (Number.isFinite(container.size)) return container.size;
87787 if (Number.isFinite(container.length)) return container.length;
87788 if (isPlainObject(container)) return Object.keys(container).length;
87789 throw new Error(ERR_NOT_CONTAINER);
87790}
87791function isPlainObject(value) {
87792 return value !== null && (0, _typeofDefault.default)(value) === "object" && value.constructor === Object;
87793}

Callers 1

newIntervalFunction · 0.70

Calls 2

isObjectFunction · 0.70
isPlainObjectFunction · 0.70

Tested by

no test coverage detected