All files / core/src constant.ts

100% Statements 51/51
100% Branches 0/0
100% Functions 0/0
100% Lines 51/51

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61  1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x       1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import type { AnchorSettings } from './types.js';
import { ArrayMutations, BatchMutations, Linkables, MapMutations, ObjectMutations, SetMutations } from './enum.js';
 
export const SET_MUTATIONS = [SetMutations.ADD, SetMutations.DELETE, SetMutations.CLEAR] as const;
export const MAP_MUTATIONS = [MapMutations.SET, MapMutations.DELETE, MapMutations.CLEAR] as const;
export const BATCH_MUTATIONS = [BatchMutations.ASSIGN, BatchMutations.REMOVE, BatchMutations.CLEAR] as const;
export const OBJECT_MUTATIONS = [ObjectMutations.SET, ObjectMutations.DELETE] as const;
export const ARRAY_MUTATIONS = [
  ArrayMutations.PUSH,
  ArrayMutations.COPY_WITHIN,
  ArrayMutations.FILL,
  ArrayMutations.POP,
  ArrayMutations.SHIFT,
  ArrayMutations.UNSHIFT,
  ArrayMutations.SPLICE,
  ArrayMutations.SORT,
  ArrayMutations.REVERSE,
] as const;
 
export const LINKABLE = new Set([Linkables.OBJECT, Linkables.ARRAY, Linkables.SET, Linkables.MAP]);
export const ANCHOR_SETTINGS = {
  cloned: false,
  strict: false,
  deferred: true,
  recursive: true,
  immutable: false,
  observable: true,
  production: true,
  silentInit: false,
  safeObservation: true,
  safeObservationThreshold: 100,
} satisfies AnchorSettings;
 
export const BATCH_MUTATION_KEYS = new Set(BATCH_MUTATIONS);
export const ARRAY_MUTATION_KEYS = new Set(ARRAY_MUTATIONS);
export const COLLECTION_MUTATION_KEYS = new Set([...MAP_MUTATIONS, ...SET_MUTATIONS]);
export const COLLECTION_MUTATION_PROPS = new Set(['set', 'add', 'delete', 'clear']);
 
// Define the max number of items additions to switch between using sort vs splice
// when adding an item into an ordered list.
export const HEURISTIC_THRESHOLD = 5;
 
// Dev tool keys
export const DEV_TOOL_KEYS = new Set([
  'onGet',
  'onSet',
  'onDelete',
  'onCall',
  'onInit',
  'onAssign',
  'onRemove',
  'onClear',
  'onDestroy',
  'onSubscribe',
  'onUnsubscribe',
  'onLink',
  'onUnlink',
  'onTrack',
  'onUntrack',
]);