@inglorious/store
Advanced tools
+1
-1
| { | ||
| "name": "@inglorious/store", | ||
| "version": "9.5.3", | ||
| "version": "9.6.0", | ||
| "description": "A state manager for real-time, collaborative apps, inspired by game development patterns and compatible with Redux.", | ||
@@ -5,0 +5,0 @@ "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)", |
+15
-3
@@ -22,6 +22,18 @@ export function createApi(store, extras) { | ||
| /** | ||
| * Retrieves the full entities state. | ||
| * @returns {Object} | ||
| * Retrieves entities. | ||
| * If `typeName` is omitted, returns the full entities state object. | ||
| * If `typeName` is provided, returns an array of entities of that type. | ||
| * @param {string} [typeName] | ||
| * @returns {Object|Object[]} | ||
| */ | ||
| getEntities: store.getState, | ||
| getEntities: (typeName) => { | ||
| const entities = store.getState() | ||
| if (typeName == null) { | ||
| return entities | ||
| } | ||
| return Object.values(entities).filter( | ||
| (entity) => entity.type === typeName, | ||
| ) | ||
| }, | ||
| /** | ||
@@ -28,0 +40,0 @@ * Retrieves a single entity by ID. |
+9
-2
@@ -15,2 +15,3 @@ import { create } from "mutative" | ||
| * - `getEntities()`: Returns all entities (frozen) | ||
| * - `getEntities(typeName)`: Returns entities matching that type (frozen array) | ||
| * - `getEntity(id)`: Returns a specific entity by ID (frozen) | ||
@@ -41,4 +42,10 @@ * - `select(selector)`: Runs a selector against the entities | ||
| return { | ||
| getEntities() { | ||
| return frozenEntities | ||
| getEntities(typeName) { | ||
| if (typeName == null) { | ||
| return frozenEntities | ||
| } | ||
| return Object.values(frozenEntities).filter( | ||
| (entity) => entity.type === typeName, | ||
| ) | ||
| }, | ||
@@ -45,0 +52,0 @@ getEntity(id) { |
+4
-1
@@ -20,3 +20,6 @@ import type { | ||
| setType: (typeName: string, type: EntityType<TEntity>) => void | ||
| getEntities: () => TState | ||
| getEntities: { | ||
| (): TState | ||
| (typeName: string): TEntity[] | ||
| } | ||
| getEntity: (id: string) => TEntity | undefined | ||
@@ -23,0 +26,0 @@ select: <TResult>(selector: (state: TState) => TResult) => TResult |
+4
-1
@@ -10,3 +10,6 @@ import type { BaseEntity, EntitiesState } from "./store" | ||
| > { | ||
| getEntities: () => TState | ||
| getEntities: { | ||
| (): TState | ||
| (typeName: string): TEntity[] | ||
| } | ||
| getEntity: (id: string) => TEntity | undefined | ||
@@ -13,0 +16,0 @@ select: <TResult>(selector: (state: TState) => TResult) => TResult |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
117686
0.61%2447
0.95%