feat(store): add reactive state primitives (#311)

This commit is contained in:
rahim
2026-01-20 00:59:14 +11:00
committed by GitHub
parent eea4c512dd
commit beb8615c1c
56 changed files with 1073 additions and 2896 deletions
@@ -8,6 +8,7 @@ import {
isNull,
isNumber,
isObject,
isPlainObject,
isPromise,
isString,
isUndefined,
@@ -175,6 +176,44 @@ describe('predicate', () => {
});
});
describe('isPlainObject', () => {
it('returns true for plain objects', () => {
expect(isPlainObject({})).toBe(true);
expect(isPlainObject({ a: 1 })).toBe(true);
expect(isPlainObject(Object.create(null))).toBe(true);
expect(isPlainObject(new Object())).toBe(true);
});
it('returns false for arrays', () => {
expect(isPlainObject([])).toBe(false);
expect(isPlainObject([1, 2, 3])).toBe(false);
});
it('returns false for class instances', () => {
class Foo {}
expect(isPlainObject(new Foo())).toBe(false);
expect(isPlainObject(new Date())).toBe(false);
expect(isPlainObject(new Map())).toBe(false);
expect(isPlainObject(new Set())).toBe(false);
expect(isPlainObject(/regex/)).toBe(false);
});
it('returns false for primitives', () => {
expect(isPlainObject(null)).toBe(false);
expect(isPlainObject(undefined)).toBe(false);
expect(isPlainObject('string')).toBe(false);
expect(isPlainObject(123)).toBe(false);
expect(isPlainObject(true)).toBe(false);
// eslint-disable-next-line symbol-description
expect(isPlainObject(Symbol())).toBe(false);
});
it('returns false for functions', () => {
expect(isPlainObject(() => {})).toBe(false);
expect(isPlainObject(() => {})).toBe(false);
});
});
describe('isAbortError', () => {
it('returns true for AbortError', () => {
const error = new DOMException('Aborted', 'AbortError');