![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/effect/dist/esm/ |
/**
* @since 2.0.0
*/
import * as Equal from "./Equal.js";
import * as Dual from "./Function.js";
import { format, NodeInspectSymbol, toJSON } from "./Inspectable.js";
import { pipeArguments } from "./Pipeable.js";
const TypeId = /*#__PURE__*/Symbol.for("effect/MutableRef");
const MutableRefProto = {
[TypeId]: TypeId,
toString() {
return format(this.toJSON());
},
toJSON() {
return {
_id: "MutableRef",
current: toJSON(this.current)
};
},
[NodeInspectSymbol]() {
return this.toJSON();
},
pipe() {
return pipeArguments(this, arguments);
}
};
/**
* @since 2.0.0
* @category constructors
*/
export const make = value => {
const ref = Object.create(MutableRefProto);
ref.current = value;
return ref;
};
/**
* @since 2.0.0
* @category general
*/
export const compareAndSet = /*#__PURE__*/Dual.dual(3, (self, oldValue, newValue) => {
if (Equal.equals(oldValue, self.current)) {
self.current = newValue;
return true;
}
return false;
});
/**
* @since 2.0.0
* @category numeric
*/
export const decrement = self => update(self, n => n - 1);
/**
* @since 2.0.0
* @category numeric
*/
export const decrementAndGet = self => updateAndGet(self, n => n - 1);
/**
* @since 2.0.0
* @category general
*/
export const get = self => self.current;
/**
* @since 2.0.0
* @category numeric
*/
export const getAndDecrement = self => getAndUpdate(self, n => n - 1);
/**
* @since 2.0.0
* @category numeric
*/
export const getAndIncrement = self => getAndUpdate(self, n => n + 1);
/**
* @since 2.0.0
* @category general
*/
export const getAndSet = /*#__PURE__*/Dual.dual(2, (self, value) => {
const ret = self.current;
self.current = value;
return ret;
});
/**
* @since 2.0.0
* @category general
*/
export const getAndUpdate = /*#__PURE__*/Dual.dual(2, (self, f) => getAndSet(self, f(get(self))));
/**
* @since 2.0.0
* @category numeric
*/
export const increment = self => update(self, n => n + 1);
/**
* @since 2.0.0
* @category numeric
*/
export const incrementAndGet = self => updateAndGet(self, n => n + 1);
/**
* @since 2.0.0
* @category general
*/
export const set = /*#__PURE__*/Dual.dual(2, (self, value) => {
self.current = value;
return self;
});
/**
* @since 2.0.0
* @category general
*/
export const setAndGet = /*#__PURE__*/Dual.dual(2, (self, value) => {
self.current = value;
return self.current;
});
/**
* @since 2.0.0
* @category general
*/
export const update = /*#__PURE__*/Dual.dual(2, (self, f) => set(self, f(get(self))));
/**
* @since 2.0.0
* @category general
*/
export const updateAndGet = /*#__PURE__*/Dual.dual(2, (self, f) => setAndGet(self, f(get(self))));
/**
* @since 2.0.0
* @category boolean
*/
export const toggle = self => update(self, _ => !_);
//# sourceMappingURL=MutableRef.js.map