CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
vanilla.development.js64 linesDownload Raw Back to umd
1(function (global, factory) {2  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :3  typeof define === 'function' && define.amd ? define(['exports'], factory) :4  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.zustandVanilla = {}));5})(this, (function (exports) { 'use strict';6 7  var createStoreImpl = function createStoreImpl(createState) {8    var state;9    var listeners = new Set();10    var setState = function setState(partial, replace) {11      var nextState = typeof partial === 'function' ? partial(state) : partial;12      if (!Object.is(nextState, state)) {13        var _previousState = state;14        state = (replace != null ? replace : typeof nextState !== 'object' || nextState === null) ? nextState : Object.assign({}, state, nextState);15        listeners.forEach(function (listener) {16          return listener(state, _previousState);17        });18      }19    };20    var getState = function getState() {21      return state;22    };23    var getInitialState = function getInitialState() {24      return initialState;25    };26    var subscribe = function subscribe(listener) {27      listeners.add(listener);28      return function () {29        return listeners.delete(listener);30      };31    };32    var destroy = function destroy() {33      {34        console.warn('[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected.');35      }36      listeners.clear();37    };38    var api = {39      setState: setState,40      getState: getState,41      getInitialState: getInitialState,42      subscribe: subscribe,43      destroy: destroy44    };45    var initialState = state = createState(setState, getState, api);46    return api;47  };48  var createStore = function createStore(createState) {49    return createState ? createStoreImpl(createState) : createStoreImpl;50  };51  var vanilla = (function (createState) {52    {53      console.warn("[DEPRECATED] Default export is deprecated. Instead use import { createStore } from 'zustand/vanilla'.");54    }55    return createStore(createState);56  });57 58  exports.createStore = createStore;59  exports.default = vanilla;60 61  Object.defineProperty(exports, '__esModule', { value: true });62 63}));64