@cfcs/core
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.5 | ||
version: 0.0.6 | ||
*/ | ||
@@ -175,3 +175,3 @@ 'use strict'; | ||
function isObserver(val) { | ||
return val && "current" in val && "subscribe" in val && "unsubscribe" in val; | ||
return val && isObject(val) && "current" in val && "subscribe" in val && "unsubscribe" in val; | ||
} | ||
@@ -178,0 +178,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.5 | ||
version: 0.0.6 | ||
*/ | ||
@@ -173,3 +173,3 @@ import Component from '@egjs/component'; | ||
function isObserver(val) { | ||
return val && "current" in val && "subscribe" in val && "unsubscribe" in val; | ||
return val && isObject(val) && "current" in val && "subscribe" in val && "unsubscribe" in val; | ||
} | ||
@@ -176,0 +176,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.5 | ||
version: 0.0.6 | ||
*/ | ||
@@ -638,3 +638,3 @@ (function (global, factory) { | ||
function isObserver(val) { | ||
return val && "current" in val && "subscribe" in val && "unsubscribe" in val; | ||
return val && isObject(val) && "current" in val && "subscribe" in val && "unsubscribe" in val; | ||
} | ||
@@ -641,0 +641,0 @@ |
@@ -7,5 +7,5 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.5 | ||
version: 0.0.6 | ||
*/ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).cfcs=t()}(this,function(){"use strict";function u(n){return Object.keys(n)}function e(n){return"string"==typeof n}function t(n){return"function"==typeof n}var r="__observers__";function s(n){var t="function"==typeof Symbol&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&"number"==typeof n.length)return{next:function(){return{value:(n=n&&r>=n.length?void 0:n)&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(function(n,t){var e="function"==typeof Symbol&&n[Symbol.iterator];if(!e)return n;var r,i,o=e.call(n),u=[];try{for(;(void 0===t||0<t--)&&!(r=o.next()).done;)u.push(r.value)}catch(n){i={error:n}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}return u}(arguments[t]));return n}function l(n){return void 0===n}var i=function(){function n(n,t){var e,r;if(this._canceled=!1,t)try{for(var i=s(Object.keys(t)),o=i.next();!o.done;o=i.next()){var u=o.value;this[u]=t[u]}}catch(n){e={error:n}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}this.eventType=n}var t=n.prototype;return t.stop=function(){this._canceled=!0},t.isCanceled=function(){return this._canceled},n}(),o=function(){function n(){this._eventHandler={}}var t=n.prototype;return t.trigger=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=t instanceof i?t.eventType:t,r=c(this._eventHandler[r]||[]);return r.length<=0||(t instanceof i?(t.currentTarget=this,r.forEach(function(n){n(t)})):r.forEach(function(n){n.apply(void 0,c(e))})),this},t.once=function(e,r){var i,o=this;if("object"==typeof e&&l(r)){var n,t=e;for(n in t)this.once(n,t[n])}else"string"==typeof e&&"function"==typeof r&&(i=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];r.apply(void 0,c(n)),o.off(e,i)},this.on(e,i));return this},t.hasOn=function(n){return!!this._eventHandler[n]},t.on=function(n,t){if("object"==typeof n&&l(t)){var e,r=n;for(e in r)this.on(e,r[e])}else{var i;"string"==typeof n&&"function"==typeof t&&(i=this._eventHandler[n],l(i)&&(this._eventHandler[n]=[],i=this._eventHandler[n]),i.push(t))}return this},t.off=function(n,t){var e,r;if(l(n))return this._eventHandler={},this;if(l(t)){if("string"==typeof n)return delete this._eventHandler[n],this;var i,o=n;for(i in o)this.off(i,o[i])}else{var u=this._eventHandler[n];if(u){var c=0;try{for(var f=s(u),a=f.next();!a.done;a=f.next()){if(a.value===t){u.splice(c,1),u.length<=0&&delete this._eventHandler[n];break}c++}}catch(n){e={error:n}}finally{try{a&&!a.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}}}return this},n.VERSION="3.0.2",n}(),f=function(){function n(n){this._emitter=new o,this._current=n}var t=n.prototype;return Object.defineProperty(t,"current",{get:function(){return this._current},set:function(n){var t=n!==this._current;this._current=n,t&&this._emitter.trigger("update",n)},enumerable:!1,configurable:!0}),t.subscribe=function(n){this._emitter.on("update",n)},t.unsubscribe=function(n){this._emitter.off("update",n)},n}();function a(i,n){var t={};return n&&n.forEach(function(r){t[r]=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=i.current||i.value;return e[r].apply(e,n)}}),t}function v(n){return new f(n)}function h(n){var t={};return Object.defineProperty(n,r,{get:function(){return t}}),t}function d(n){return n[r]||h(n),n[r]}function y(n,t,e){n=d(n);return n[t]||(n[t]=v(e)),n[t]}function b(n,t,e){d(n)[t]=e}function p(n){return n&&"current"in n&&"subscribe"in n&&"unsubscribe"in n}function g(r){return function(n,t){var e=r||t;Object.defineProperty(n,t,{get:function(){return y(this,e).current},set:function(n){y(this,e,n).current=n}}),e!==t&&Object.defineProperty(n,e,{get:function(){return y(this,e).current}})}}function _(n){n.subscribe=function(n,t){y(this,n).subscribe(t)},n.unsubscribe=function(n,t){var e=this;n?n in this&&y(this,n).unsubscribe(t):u(d(this)).forEach(function(n){e.unsubscribe(n)})}}return{__proto__:null,keys:u,camelize:function(n){return n.replace(/[\s-_]([a-z])/g,function(n,t){return t.toUpperCase()})},isString:e,isObject:function(n){return"object"==typeof n},isFunction:t,findTarget:function(n){var t;return n?(e(n)?t=document.querySelector(n):n instanceof Element?t=n:("value"in n||"current"in n)&&(t=n.value||n.current),t):null},withClassMethods:function(t){return function(n,i){t.forEach(function(r){r in n||(n[r]=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=(e=this[i])[r].apply(e,n);return e===this[i]?this:e})})}},withReactiveMethods:a,observe:v,defineObservers:h,getObservers:d,getObserver:y,setObserver:b,isObserver:p,Observer:f,reactive:function(n){var e=t(n)?n():n,r={};return h(r),u(e).forEach(function(n){var t=e[n];p(t)?(b(r,n,t),g(n)(r,n)):r[n]=t}),_(r),r},Reactive:g,injectReactiveSubscribe:_,ReactiveSubscribe:function(n){_(n.prototype)},adaptReactive:function(r){var n;function t(){var n;return null!=(n=null==(n=r.data)?void 0:n.call(r))?n:{}}var i={current:(null==(n=r.created)?void 0:n.call(r,t()))||null},o=null;return{state:function(){var e,n=i.current;return o||(r.state?o=r.state:n&&(e=d(n),o=u(e).reduce(function(n,t){return n[t]=e[t].current,n},{})),o||{})},instance:function(){return i.current},mounted:function(){var n;i.current=(null==(n=r.mounted)?void 0:n.call(r,t()))||i.current},init:function(){var n;null!=(n=r.init)&&n.call(r,i.current,t())},destroy:function(){var n;null!=(n=r.destroy)&&n.call(r,i.current,t())},methods:function(){return a(i,r.methods)},on:function(n,t){var e;null!=(e=r.on)&&e.call(r,i.current,n,t)},off:function(n,t){var e;null!=(e=r.off)&&e.call(r,i.current,n,t)}}}}}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).cfcs=t()}(this,function(){"use strict";function u(n){return Object.keys(n)}function e(n){return"string"==typeof n}function t(n){return"object"==typeof n}function i(n){return"function"==typeof n}var r="__observers__";function s(n){var t="function"==typeof Symbol&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&"number"==typeof n.length)return{next:function(){return{value:(n=n&&r>=n.length?void 0:n)&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(function(n,t){var e="function"==typeof Symbol&&n[Symbol.iterator];if(!e)return n;var r,i,o=e.call(n),u=[];try{for(;(void 0===t||0<t--)&&!(r=o.next()).done;)u.push(r.value)}catch(n){i={error:n}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}return u}(arguments[t]));return n}function l(n){return void 0===n}var o=function(){function n(n,t){var e,r;if(this._canceled=!1,t)try{for(var i=s(Object.keys(t)),o=i.next();!o.done;o=i.next()){var u=o.value;this[u]=t[u]}}catch(n){e={error:n}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}this.eventType=n}var t=n.prototype;return t.stop=function(){this._canceled=!0},t.isCanceled=function(){return this._canceled},n}(),f=function(){function n(){this._eventHandler={}}var t=n.prototype;return t.trigger=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=t instanceof o?t.eventType:t,r=c(this._eventHandler[r]||[]);return r.length<=0||(t instanceof o?(t.currentTarget=this,r.forEach(function(n){n(t)})):r.forEach(function(n){n.apply(void 0,c(e))})),this},t.once=function(e,r){var i,o=this;if("object"==typeof e&&l(r)){var n,t=e;for(n in t)this.once(n,t[n])}else"string"==typeof e&&"function"==typeof r&&(i=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];r.apply(void 0,c(n)),o.off(e,i)},this.on(e,i));return this},t.hasOn=function(n){return!!this._eventHandler[n]},t.on=function(n,t){if("object"==typeof n&&l(t)){var e,r=n;for(e in r)this.on(e,r[e])}else{var i;"string"==typeof n&&"function"==typeof t&&(i=this._eventHandler[n],l(i)&&(this._eventHandler[n]=[],i=this._eventHandler[n]),i.push(t))}return this},t.off=function(n,t){var e,r;if(l(n))return this._eventHandler={},this;if(l(t)){if("string"==typeof n)return delete this._eventHandler[n],this;var i,o=n;for(i in o)this.off(i,o[i])}else{var u=this._eventHandler[n];if(u){var c=0;try{for(var f=s(u),a=f.next();!a.done;a=f.next()){if(a.value===t){u.splice(c,1),u.length<=0&&delete this._eventHandler[n];break}c++}}catch(n){e={error:n}}finally{try{a&&!a.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}}}return this},n.VERSION="3.0.2",n}(),a=function(){function n(n){this._emitter=new f,this._current=n}var t=n.prototype;return Object.defineProperty(t,"current",{get:function(){return this._current},set:function(n){var t=n!==this._current;this._current=n,t&&this._emitter.trigger("update",n)},enumerable:!1,configurable:!0}),t.subscribe=function(n){this._emitter.on("update",n)},t.unsubscribe=function(n){this._emitter.off("update",n)},n}();function v(i,n){var t={};return n&&n.forEach(function(r){t[r]=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=i.current||i.value;return e[r].apply(e,n)}}),t}function h(n){return new a(n)}function d(n){var t={};return Object.defineProperty(n,r,{get:function(){return t}}),t}function y(n){return n[r]||d(n),n[r]}function b(n,t,e){n=y(n);return n[t]||(n[t]=h(e)),n[t]}function p(n,t,e){y(n)[t]=e}function g(n){return n&&t(n)&&"current"in n&&"subscribe"in n&&"unsubscribe"in n}function _(r){return function(n,t){var e=r||t;Object.defineProperty(n,t,{get:function(){return b(this,e).current},set:function(n){b(this,e,n).current=n}}),e!==t&&Object.defineProperty(n,e,{get:function(){return b(this,e).current}})}}function m(n){n.subscribe=function(n,t){b(this,n).subscribe(t)},n.unsubscribe=function(n,t){var e=this;n?n in this&&b(this,n).unsubscribe(t):u(y(this)).forEach(function(n){e.unsubscribe(n)})}}return{__proto__:null,keys:u,camelize:function(n){return n.replace(/[\s-_]([a-z])/g,function(n,t){return t.toUpperCase()})},isString:e,isObject:t,isFunction:i,findTarget:function(n){var t;return n?(e(n)?t=document.querySelector(n):n instanceof Element?t=n:("value"in n||"current"in n)&&(t=n.value||n.current),t):null},withClassMethods:function(t){return function(n,i){t.forEach(function(r){r in n||(n[r]=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=(e=this[i])[r].apply(e,n);return e===this[i]?this:e})})}},withReactiveMethods:v,observe:h,defineObservers:d,getObservers:y,getObserver:b,setObserver:p,isObserver:g,Observer:a,reactive:function(n){var e=i(n)?n():n,r={};return d(r),u(e).forEach(function(n){var t=e[n];g(t)?(p(r,n,t),_(n)(r,n)):r[n]=t}),m(r),r},Reactive:_,injectReactiveSubscribe:m,ReactiveSubscribe:function(n){m(n.prototype)},adaptReactive:function(r){var n;function t(){var n;return null!=(n=null==(n=r.data)?void 0:n.call(r))?n:{}}var i={current:(null==(n=r.created)?void 0:n.call(r,t()))||null},o=null;return{state:function(){var e,n=i.current;return o||(r.state?o=r.state:n&&(e=y(n),o=u(e).reduce(function(n,t){return n[t]=e[t].current,n},{})),o||{})},instance:function(){return i.current},mounted:function(){var n;i.current=(null==(n=r.mounted)?void 0:n.call(r,t()))||i.current},init:function(){var n;null!=(n=r.init)&&n.call(r,i.current,t())},destroy:function(){var n;null!=(n=r.destroy)&&n.call(r,i.current,t())},methods:function(){return v(i,r.methods)},on:function(n,t){var e;null!=(e=r.on)&&e.call(r,i.current,n,t)},off:function(n,t){var e;null!=(e=r.off)&&e.call(r,i.current,n,t)}}}}}); | ||
//# sourceMappingURL=cfcs.min.js.map |
{ | ||
"name": "@cfcs/core", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/cfcs.cjs.js", |
import { OBSERVERS_PATH } from "./const"; | ||
import { Observer } from "./Observer"; | ||
import { GetReactiveValue, ReactiveMethods } from "./types"; | ||
import { Ref } from "../core"; | ||
import { isObject, Ref } from "../core"; | ||
@@ -68,3 +68,3 @@ | ||
export function isObserver(val: any): val is Observer { | ||
return val && ("current" in val && "subscribe" in val && "unsubscribe" in val); | ||
return val && isObject(val) && ("current" in val && "subscribe" in val && "unsubscribe" in val); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
147794