ag-reactive
Advanced tools
Comparing version 1.0.6 to 1.0.8
@@ -0,1 +1,4 @@ | ||
import { Wrapper } from "./Wrapper"; | ||
import { Delta } from "./Types"; | ||
import { Builder } from "./Builder"; | ||
export declare const RawKey = "__raw"; | ||
@@ -5,3 +8,10 @@ export declare const ReactiveKey = "__reactive"; | ||
export declare function markRaw(value: any): any; | ||
export declare function isReactive<T>(value: T): boolean; | ||
export declare function isReactive(value: any): value is { | ||
__reactive: Wrapper; | ||
}; | ||
export declare function reactive<T>(raw: T): T; | ||
export declare function observe(obj: any, cb: (delta: Delta) => void): { | ||
id: string; | ||
stop(): void; | ||
}; | ||
export declare function rebuild<T = any>(id: string): Builder<T>; |
37
index.js
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reactive = exports.isReactive = exports.markRaw = exports.isRaw = exports.ReactiveKey = exports.RawKey = void 0; | ||
var ReactiveObject_1 = require("./ReactiveObject"); | ||
var console_1 = require("./console"); | ||
(0, console_1.override_console)(); | ||
exports.rebuild = exports.observe = exports.reactive = exports.isReactive = exports.markRaw = exports.isRaw = exports.ReactiveKey = exports.RawKey = void 0; | ||
var Wrapper_1 = require("./Wrapper"); | ||
var Observer_1 = require("./Observer"); | ||
var pretty_format_1 = __importDefault(require("pretty-format")); | ||
var Builder_1 = require("./Builder"); | ||
exports.RawKey = '__raw'; | ||
@@ -16,3 +20,4 @@ exports.ReactiveKey = '__reactive'; | ||
|| value instanceof Date | ||
|| (value === null || value === void 0 ? void 0 : value[exports.RawKey]); | ||
|| (value === null || value === void 0 ? void 0 : value[exports.RawKey]) | ||
|| typeof value === 'function'; | ||
} | ||
@@ -40,3 +45,2 @@ exports.isRaw = isRaw; | ||
exports.isReactive = isReactive; | ||
var id = 0; | ||
function reactive(raw) { | ||
@@ -46,3 +50,3 @@ var _a, _b; | ||
return raw; | ||
var obj = new ReactiveObject_1.ReactiveObject(id++, Array.isArray(raw)); | ||
var obj = new Wrapper_1.Wrapper(Array.isArray(raw)); | ||
for (var key in raw) { | ||
@@ -55,1 +59,20 @@ var value = ((_b = (_a = Object.getOwnPropertyDescriptor(raw, key)) === null || _a === void 0 ? void 0 : _a.get) !== null && _b !== void 0 ? _b : raw[key]); | ||
exports.reactive = reactive; | ||
function observe(obj, cb) { | ||
if (!isReactive(obj)) { | ||
throw 'can only observe reactive object'; | ||
} | ||
return (0, Observer_1.observe)(obj.__reactive, cb); | ||
} | ||
exports.observe = observe; | ||
function rebuild(id) { | ||
return new Builder_1.Builder(id); | ||
} | ||
exports.rebuild = rebuild; | ||
var consoleLog = console.log; | ||
console.log = function () { | ||
var d = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
d[_i] = arguments[_i]; | ||
} | ||
consoleLog.apply(void 0, d.map(function (v) { return (0, pretty_format_1.default)(v); })); | ||
}; |
{ | ||
"name": "ag-reactive", | ||
"version": "1.0.6", | ||
"version": "1.0.8", | ||
"description": "", | ||
@@ -10,3 +10,7 @@ "author": "", | ||
}, | ||
"dependencies": { | ||
"consola": "^3.2.3", | ||
"pretty-format": "^29.7.0" | ||
}, | ||
"bin": {} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40444
23
1147
2
1
+ Addedconsola@^3.2.3
+ Addedpretty-format@^29.7.0
+ Added@jest/schemas@29.6.3(transitive)
+ Added@sinclair/typebox@0.27.8(transitive)
+ Addedansi-styles@5.2.0(transitive)
+ Addedconsola@3.3.3(transitive)
+ Addedpretty-format@29.7.0(transitive)
+ Addedreact-is@18.3.1(transitive)