New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

karet

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karet - npm Package Compare versions

Comparing version 1.1.7 to 1.1.8

.nyc_output/0d1e19b38d182c8b8230c07a1c101848.json

170

dist/karet.cjs.js

@@ -87,23 +87,46 @@ 'use strict';

function forEach(props, extra, fn) {
for (var key in props) {
var val = props[key];
if (isObs(val)) {
fn(extra, val);
} else if (CHILDREN === key) {
if (infestines.isArray(val)) {
for (var i = 0, n = val.length; i < n; ++i) {
var valI = val[i];
if (isObs(valI)) fn(extra, valI);
}
function renderChildren(children, at, values) {
if (isObs(children)) {
return values[++at[0]];
} else if (infestines.isArray(children)) {
var newChildren = children;
for (var i = 0, n = children.length; i < n; ++i) {
var childI = children[i];
var newChildI = childI;
if (isObs(childI)) {
newChildI = values[++at[0]];
} else if (infestines.isArray(childI)) {
newChildI = renderChildren(childI, at, values);
}
} else if (STYLE === key) {
for (var k in val) {
var valK = val[k];
if (isObs(valK)) fn(extra, valK);
if (newChildI !== childI) {
if (newChildren === children) newChildren = children.slice(0);
newChildren[i] = newChildI;
}
}
return newChildren;
} else {
return children;
}
}
function renderStyle(style, at, values) {
var newStyle = undefined;
for (var i in style) {
var styleI = style[i];
if (isObs(styleI)) {
if (!newStyle) {
newStyle = {};
for (var j in style) {
if (j === i) break;
newStyle[j] = style[j];
}
}
newStyle[i] = values[++at[0]];
} else if (newStyle) {
newStyle[i] = styleI;
}
}
return newStyle || style;
}
function _render(props, values) {

@@ -114,3 +137,3 @@ var type = null;

var k = -1;
var at = [-1];

@@ -120,21 +143,3 @@ for (var key in props) {

if (CHILDREN === key) {
if (isObs(val)) {
newChildren = values[++k];
} else if (infestines.isArray(val)) {
for (var i = 0, n = val.length; i < n; ++i) {
var valI = val[i];
if (isObs(valI)) {
if (!newChildren) {
newChildren = Array(n);
for (var j = 0; j < i; ++j) {
newChildren[j] = val[j];
}
}
newChildren[i] = values[++k];
} else if (newChildren) newChildren[i] = valI;
}
if (!newChildren) newChildren = val;
} else {
newChildren = val;
}
newChildren = renderChildren(val, at, values);
} else if ("$$type" === key) {

@@ -144,25 +149,9 @@ type = props[key];

newProps = newProps || {};
newProps.ref = isObs(val) ? values[++k] : val;
newProps.ref = isObs(val) ? values[++at[0]] : val;
} else if (isObs(val)) {
newProps = newProps || {};
newProps[key] = values[++k];
newProps[key] = values[++at[0]];
} else if (STYLE === key) {
var newStyle = void 0;
for (var _i in val) {
var _valI = val[_i];
if (isObs(_valI)) {
if (!newStyle) {
newStyle = {};
for (var _j in val) {
if (_j === _i) break;
newStyle[_j] = val[_j];
}
}
newStyle[_i] = values[++k];
} else if (newStyle) {
newStyle[_i] = _valI;
}
}
newProps = newProps || {};
newProps.style = newStyle || val;
newProps.style = renderStyle(val, at, values) || val;
} else {

@@ -179,2 +168,27 @@ newProps = newProps || {};

function forEachInChildrenArray(children, extra, fn) {
for (var i = 0, n = children.length; i < n; ++i) {
var childI = children[i];
if (isObs(childI)) fn(extra, childI);else if (infestines.isArray(childI)) forEachInChildrenArray(childI, extra, fn);
}
}
function forEachInProps(props, extra, fn) {
for (var key in props) {
var val = props[key];
if (isObs(val)) {
fn(extra, val);
} else if (CHILDREN === key) {
if (infestines.isArray(val)) forEachInChildrenArray(val, extra, fn);
} else if (STYLE === key) {
for (var k in val) {
var valK = val[k];
if (isObs(valK)) fn(extra, valK);
}
}
}
}
//
function incValues(self) {

@@ -235,5 +249,5 @@ self.values += 1;

if (handlers instanceof Function) {
forEach(this.props, handlers, offAny1);
forEachInProps(this.props, handlers, offAny1);
} else if (handlers) {
forEach(this.props, handlers.reverse(), offAny);
forEachInProps(this.props, handlers.reverse(), offAny);
}

@@ -245,3 +259,3 @@ },

this.values = 0;
forEach(props, this, incValues);
forEachInProps(props, this, incValues);
var n = this.values;

@@ -277,3 +291,3 @@

this.handlers = handlers;
forEach(props, handlers, onAny1);
forEachInProps(props, handlers, onAny1);
break;

@@ -284,3 +298,3 @@ }

this.handlers = [];
forEach(props, this, onAny);
forEachInProps(props, this, onAny);
}

@@ -304,2 +318,10 @@ },

function hasObsInChildrenArray(i, children) {
for (var n = children.length; i < n; ++i) {
var child = children[i];
if (isObs(child) || infestines.isArray(child) && hasObsInChildrenArray(0, child)) return true;
}
return false;
}
function hasObsInProps(props) {

@@ -311,5 +333,3 @@ for (var key in props) {

} else if (CHILDREN === key) {
if (infestines.isArray(val)) for (var i = 0, n = val.length; i < n; ++i) {
if (isObs(val[i])) return true;
}
if (infestines.isArray(val) && hasObsInChildrenArray(0, val)) return true;
} else if (STYLE === key) {

@@ -324,15 +344,3 @@ for (var k in val) {

function hasObsInArgs(args) {
for (var i = 2, n = args.length; i < n; ++i) {
var arg = args[i];
if (infestines.isArray(arg)) {
for (var j = 0, m = arg.length; j < m; ++j) {
if (isObs(arg[j])) return true;
}
} else if (isObs(arg)) {
return true;
}
}
return hasObsInProps(args[1]);
}
//

@@ -348,6 +356,2 @@ function filterProps(type, props) {

function hasLift(props) {
return props && props[KARET_LIFT] === true;
}
function createElement$1() {

@@ -359,8 +363,8 @@ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {

var type = args[0];
var props = args[1];
if (infestines.isString(type) || hasLift(props)) {
if (hasObsInArgs(args)) {
var props = args[1] || infestines.object0;
if (infestines.isString(type) || props[KARET_LIFT]) {
if (hasObsInChildrenArray(2, args) || hasObsInProps(props)) {
args[1] = filterProps(type, props);
args[0] = FromClass;
} else if (hasLift(props)) {
} else if (props[KARET_LIFT]) {
args[1] = infestines.dissocPartialU(KARET_LIFT, props) || infestines.object0;

@@ -367,0 +371,0 @@ }

@@ -84,23 +84,46 @@ import { Component, createElement } from 'react';

function forEach(props, extra, fn) {
for (var key in props) {
var val = props[key];
if (isObs(val)) {
fn(extra, val);
} else if (CHILDREN === key) {
if (isArray(val)) {
for (var i = 0, n = val.length; i < n; ++i) {
var valI = val[i];
if (isObs(valI)) fn(extra, valI);
}
function renderChildren(children, at, values) {
if (isObs(children)) {
return values[++at[0]];
} else if (isArray(children)) {
var newChildren = children;
for (var i = 0, n = children.length; i < n; ++i) {
var childI = children[i];
var newChildI = childI;
if (isObs(childI)) {
newChildI = values[++at[0]];
} else if (isArray(childI)) {
newChildI = renderChildren(childI, at, values);
}
} else if (STYLE === key) {
for (var k in val) {
var valK = val[k];
if (isObs(valK)) fn(extra, valK);
if (newChildI !== childI) {
if (newChildren === children) newChildren = children.slice(0);
newChildren[i] = newChildI;
}
}
return newChildren;
} else {
return children;
}
}
function renderStyle(style, at, values) {
var newStyle = undefined;
for (var i in style) {
var styleI = style[i];
if (isObs(styleI)) {
if (!newStyle) {
newStyle = {};
for (var j in style) {
if (j === i) break;
newStyle[j] = style[j];
}
}
newStyle[i] = values[++at[0]];
} else if (newStyle) {
newStyle[i] = styleI;
}
}
return newStyle || style;
}
function _render(props, values) {

@@ -111,3 +134,3 @@ var type = null;

var k = -1;
var at = [-1];

@@ -117,21 +140,3 @@ for (var key in props) {

if (CHILDREN === key) {
if (isObs(val)) {
newChildren = values[++k];
} else if (isArray(val)) {
for (var i = 0, n = val.length; i < n; ++i) {
var valI = val[i];
if (isObs(valI)) {
if (!newChildren) {
newChildren = Array(n);
for (var j = 0; j < i; ++j) {
newChildren[j] = val[j];
}
}
newChildren[i] = values[++k];
} else if (newChildren) newChildren[i] = valI;
}
if (!newChildren) newChildren = val;
} else {
newChildren = val;
}
newChildren = renderChildren(val, at, values);
} else if ("$$type" === key) {

@@ -141,25 +146,9 @@ type = props[key];

newProps = newProps || {};
newProps.ref = isObs(val) ? values[++k] : val;
newProps.ref = isObs(val) ? values[++at[0]] : val;
} else if (isObs(val)) {
newProps = newProps || {};
newProps[key] = values[++k];
newProps[key] = values[++at[0]];
} else if (STYLE === key) {
var newStyle = void 0;
for (var _i in val) {
var _valI = val[_i];
if (isObs(_valI)) {
if (!newStyle) {
newStyle = {};
for (var _j in val) {
if (_j === _i) break;
newStyle[_j] = val[_j];
}
}
newStyle[_i] = values[++k];
} else if (newStyle) {
newStyle[_i] = _valI;
}
}
newProps = newProps || {};
newProps.style = newStyle || val;
newProps.style = renderStyle(val, at, values) || val;
} else {

@@ -176,2 +165,27 @@ newProps = newProps || {};

function forEachInChildrenArray(children, extra, fn) {
for (var i = 0, n = children.length; i < n; ++i) {
var childI = children[i];
if (isObs(childI)) fn(extra, childI);else if (isArray(childI)) forEachInChildrenArray(childI, extra, fn);
}
}
function forEachInProps(props, extra, fn) {
for (var key in props) {
var val = props[key];
if (isObs(val)) {
fn(extra, val);
} else if (CHILDREN === key) {
if (isArray(val)) forEachInChildrenArray(val, extra, fn);
} else if (STYLE === key) {
for (var k in val) {
var valK = val[k];
if (isObs(valK)) fn(extra, valK);
}
}
}
}
//
function incValues(self) {

@@ -232,5 +246,5 @@ self.values += 1;

if (handlers instanceof Function) {
forEach(this.props, handlers, offAny1);
forEachInProps(this.props, handlers, offAny1);
} else if (handlers) {
forEach(this.props, handlers.reverse(), offAny);
forEachInProps(this.props, handlers.reverse(), offAny);
}

@@ -242,3 +256,3 @@ },

this.values = 0;
forEach(props, this, incValues);
forEachInProps(props, this, incValues);
var n = this.values;

@@ -274,3 +288,3 @@

this.handlers = handlers;
forEach(props, handlers, onAny1);
forEachInProps(props, handlers, onAny1);
break;

@@ -281,3 +295,3 @@ }

this.handlers = [];
forEach(props, this, onAny);
forEachInProps(props, this, onAny);
}

@@ -301,2 +315,10 @@ },

function hasObsInChildrenArray(i, children) {
for (var n = children.length; i < n; ++i) {
var child = children[i];
if (isObs(child) || isArray(child) && hasObsInChildrenArray(0, child)) return true;
}
return false;
}
function hasObsInProps(props) {

@@ -308,5 +330,3 @@ for (var key in props) {

} else if (CHILDREN === key) {
if (isArray(val)) for (var i = 0, n = val.length; i < n; ++i) {
if (isObs(val[i])) return true;
}
if (isArray(val) && hasObsInChildrenArray(0, val)) return true;
} else if (STYLE === key) {

@@ -321,15 +341,3 @@ for (var k in val) {

function hasObsInArgs(args) {
for (var i = 2, n = args.length; i < n; ++i) {
var arg = args[i];
if (isArray(arg)) {
for (var j = 0, m = arg.length; j < m; ++j) {
if (isObs(arg[j])) return true;
}
} else if (isObs(arg)) {
return true;
}
}
return hasObsInProps(args[1]);
}
//

@@ -345,6 +353,2 @@ function filterProps(type, props) {

function hasLift(props) {
return props && props[KARET_LIFT] === true;
}
function createElement$1() {

@@ -356,8 +360,8 @@ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {

var type = args[0];
var props = args[1];
if (isString(type) || hasLift(props)) {
if (hasObsInArgs(args)) {
var props = args[1] || object0;
if (isString(type) || props[KARET_LIFT]) {
if (hasObsInChildrenArray(2, args) || hasObsInProps(props)) {
args[1] = filterProps(type, props);
args[0] = FromClass;
} else if (hasLift(props)) {
} else if (props[KARET_LIFT]) {
args[1] = dissocPartialU(KARET_LIFT, props) || object0;

@@ -364,0 +368,0 @@ }

@@ -85,23 +85,46 @@ (function (global, factory) {

function forEach(props, extra, fn) {
for (var key in props) {
var val = props[key];
if (isObs(val)) {
fn(extra, val);
} else if (CHILDREN === key) {
if (infestines.isArray(val)) {
for (var i = 0, n = val.length; i < n; ++i) {
var valI = val[i];
if (isObs(valI)) fn(extra, valI);
}
function renderChildren(children, at, values) {
if (isObs(children)) {
return values[++at[0]];
} else if (infestines.isArray(children)) {
var newChildren = children;
for (var i = 0, n = children.length; i < n; ++i) {
var childI = children[i];
var newChildI = childI;
if (isObs(childI)) {
newChildI = values[++at[0]];
} else if (infestines.isArray(childI)) {
newChildI = renderChildren(childI, at, values);
}
} else if (STYLE === key) {
for (var k in val) {
var valK = val[k];
if (isObs(valK)) fn(extra, valK);
if (newChildI !== childI) {
if (newChildren === children) newChildren = children.slice(0);
newChildren[i] = newChildI;
}
}
return newChildren;
} else {
return children;
}
}
function renderStyle(style, at, values) {
var newStyle = undefined;
for (var i in style) {
var styleI = style[i];
if (isObs(styleI)) {
if (!newStyle) {
newStyle = {};
for (var j in style) {
if (j === i) break;
newStyle[j] = style[j];
}
}
newStyle[i] = values[++at[0]];
} else if (newStyle) {
newStyle[i] = styleI;
}
}
return newStyle || style;
}
function _render(props, values) {

@@ -112,3 +135,3 @@ var type = null;

var k = -1;
var at = [-1];

@@ -118,21 +141,3 @@ for (var key in props) {

if (CHILDREN === key) {
if (isObs(val)) {
newChildren = values[++k];
} else if (infestines.isArray(val)) {
for (var i = 0, n = val.length; i < n; ++i) {
var valI = val[i];
if (isObs(valI)) {
if (!newChildren) {
newChildren = Array(n);
for (var j = 0; j < i; ++j) {
newChildren[j] = val[j];
}
}
newChildren[i] = values[++k];
} else if (newChildren) newChildren[i] = valI;
}
if (!newChildren) newChildren = val;
} else {
newChildren = val;
}
newChildren = renderChildren(val, at, values);
} else if ("$$type" === key) {

@@ -142,25 +147,9 @@ type = props[key];

newProps = newProps || {};
newProps.ref = isObs(val) ? values[++k] : val;
newProps.ref = isObs(val) ? values[++at[0]] : val;
} else if (isObs(val)) {
newProps = newProps || {};
newProps[key] = values[++k];
newProps[key] = values[++at[0]];
} else if (STYLE === key) {
var newStyle = void 0;
for (var _i in val) {
var _valI = val[_i];
if (isObs(_valI)) {
if (!newStyle) {
newStyle = {};
for (var _j in val) {
if (_j === _i) break;
newStyle[_j] = val[_j];
}
}
newStyle[_i] = values[++k];
} else if (newStyle) {
newStyle[_i] = _valI;
}
}
newProps = newProps || {};
newProps.style = newStyle || val;
newProps.style = renderStyle(val, at, values) || val;
} else {

@@ -177,2 +166,27 @@ newProps = newProps || {};

function forEachInChildrenArray(children, extra, fn) {
for (var i = 0, n = children.length; i < n; ++i) {
var childI = children[i];
if (isObs(childI)) fn(extra, childI);else if (infestines.isArray(childI)) forEachInChildrenArray(childI, extra, fn);
}
}
function forEachInProps(props, extra, fn) {
for (var key in props) {
var val = props[key];
if (isObs(val)) {
fn(extra, val);
} else if (CHILDREN === key) {
if (infestines.isArray(val)) forEachInChildrenArray(val, extra, fn);
} else if (STYLE === key) {
for (var k in val) {
var valK = val[k];
if (isObs(valK)) fn(extra, valK);
}
}
}
}
//
function incValues(self) {

@@ -233,5 +247,5 @@ self.values += 1;

if (handlers instanceof Function) {
forEach(this.props, handlers, offAny1);
forEachInProps(this.props, handlers, offAny1);
} else if (handlers) {
forEach(this.props, handlers.reverse(), offAny);
forEachInProps(this.props, handlers.reverse(), offAny);
}

@@ -243,3 +257,3 @@ },

this.values = 0;
forEach(props, this, incValues);
forEachInProps(props, this, incValues);
var n = this.values;

@@ -275,3 +289,3 @@

this.handlers = handlers;
forEach(props, handlers, onAny1);
forEachInProps(props, handlers, onAny1);
break;

@@ -282,3 +296,3 @@ }

this.handlers = [];
forEach(props, this, onAny);
forEachInProps(props, this, onAny);
}

@@ -302,2 +316,10 @@ },

function hasObsInChildrenArray(i, children) {
for (var n = children.length; i < n; ++i) {
var child = children[i];
if (isObs(child) || infestines.isArray(child) && hasObsInChildrenArray(0, child)) return true;
}
return false;
}
function hasObsInProps(props) {

@@ -309,5 +331,3 @@ for (var key in props) {

} else if (CHILDREN === key) {
if (infestines.isArray(val)) for (var i = 0, n = val.length; i < n; ++i) {
if (isObs(val[i])) return true;
}
if (infestines.isArray(val) && hasObsInChildrenArray(0, val)) return true;
} else if (STYLE === key) {

@@ -322,15 +342,3 @@ for (var k in val) {

function hasObsInArgs(args) {
for (var i = 2, n = args.length; i < n; ++i) {
var arg = args[i];
if (infestines.isArray(arg)) {
for (var j = 0, m = arg.length; j < m; ++j) {
if (isObs(arg[j])) return true;
}
} else if (isObs(arg)) {
return true;
}
}
return hasObsInProps(args[1]);
}
//

@@ -346,6 +354,2 @@ function filterProps(type, props) {

function hasLift(props) {
return props && props[KARET_LIFT] === true;
}
function createElement$1() {

@@ -357,8 +361,8 @@ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {

var type = args[0];
var props = args[1];
if (infestines.isString(type) || hasLift(props)) {
if (hasObsInArgs(args)) {
var props = args[1] || infestines.object0;
if (infestines.isString(type) || props[KARET_LIFT]) {
if (hasObsInChildrenArray(2, args) || hasObsInProps(props)) {
args[1] = filterProps(type, props);
args[0] = FromClass;
} else if (hasLift(props)) {
} else if (props[KARET_LIFT]) {
args[1] = infestines.dissocPartialU(KARET_LIFT, props) || infestines.object0;

@@ -365,0 +369,0 @@ }

@@ -1,1 +0,1 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("kefir"),require("infestines")):"function"==typeof define&&define.amd?define(["exports","react","kefir","infestines"],r):r(e.karet=e.karet||{},e.React,e.Kefir,e.I)}(this,function(e,r,n,t){"use strict";function i(e,r,n){for(var i in e){var a=e[i];if($(a))n(r,a);else if(m===i){if(t.isArray(a))for(var s=0,l=a.length;s<l;++s){var f=a[s];$(f)&&n(r,f)}}else if(k===i)for(var o in a){var u=a[o];$(u)&&n(r,u)}}}function a(e,r){var n=null,i=null,a=null,s=-1;for(var l in e){var f=e[l];if(m===l)if($(f))a=r[++s];else if(t.isArray(f)){for(var o=0,u=f.length;o<u;++o){var c=f[o];if($(c)){if(!a){a=Array(u);for(var v=0;v<o;++v)a[v]=f[v]}a[o]=r[++s]}else a&&(a[o]=c)}a||(a=f)}else a=f;else if("$$type"===l)n=e[l];else if(g===l)i=i||{},i.ref=$(f)?r[++s]:f;else if($(f))i=i||{},i[l]=r[++s];else if(k===l){var h=void 0;for(var d in f){var p=f[d];if($(p)){if(!h){h={};for(var b in f){if(b===d)break;h[b]=f[b]}}h[d]=r[++s]}else h&&(h[d]=p)}i=i||{},i.style=h||f}else i=i||{},i[l]=f}return a instanceof Array?U.apply(null,[n,i].concat(a)):a?U(n,i,a):U(n,i)}function s(e){e.values+=1}function l(e,r){r.offAny(e)}function f(e,r){var n=e.pop();n&&r.offAny(n)}function o(e,r){r.onAny(e)}function u(e,r){var n=function r(n){for(var t=e.handlers,i=0;t[i]!==r;)++i;switch(n.type){case b:var a=n.value,s=e.values;s[i]!==a&&(s[i]=a,e.forceUpdate());break;case y:throw n.value;default:t[i]=null;var l=t.length;if(l!==e.values.length)return;for(var f=0;f<l;++f)if(t[f])return;e.handlers=null}};e.handlers.push(n),r.onAny(n)}function c(e){for(var r in e){var n=e[r];if($(n))return!0;if(m===r){if(t.isArray(n))for(var i=0,a=n.length;i<a;++i)if($(n[i]))return!0}else if(k===r)for(var s in n)if($(n[s]))return!0}return!1}function v(e){for(var r=2,n=e.length;r<n;++r){var i=e[r];if(t.isArray(i)){for(var a=0,s=i.length;a<s;++a)if($(i[a]))return!0}else if($(i))return!0}return c(e[1])}function h(e,r){var n={$$type:e};for(var t in r){var i=r[t];"ref"===t?n[g]=i:A!==t&&(n[t]=i)}return n}function d(e){return e&&!0===e[A]}function p(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=r[0],a=r[1];return(t.isString(i)||d(a))&&(v(r)?(r[1]=h(i,a),r[0]=j):d(a)&&(r[1]=t.dissocPartialU(A,a)||t.object0)),U.apply(void 0,r)}var b="value",y="error",k="style",m="children",A="karet-lift",g="$$ref",U=r.createElement,w=r.Component,$=function(e){return e instanceof n.Observable},S=t.inherit(function(e){w.call(this,e)},w,{componentWillReceiveProps:function(e){this.componentWillUnmount(),this.doSubscribe(e)},componentWillMount:function(){this.doSubscribe(this.props)}}),W=t.inherit(function(e){S.call(this,e),this.callback=this.rendered=null},S,{componentWillUnmount:function(){var e=this.callback;e&&this.props.observable.offAny(e)},doSubscribe:function(e){var r=this,n=e.observable;if($(n)){var t=function(e){switch(e.type){case b:r.rendered=e.value||null,r.forceUpdate();break;case y:throw e.value;case"end":r.callback=null}};this.callback=t,n.onAny(t)}else this.rendered=n||null},render:function(){return this.rendered}}),P=function(e){return U(W,{observable:e})},j=t.inherit(function(e){S.call(this,e),this.values=this,this.handlers=null},S,{componentWillUnmount:function(){var e=this.handlers;e instanceof Function?i(this.props,e,l):e&&i(this.props,e.reverse(),f)},doSubscribe:function(e){var r=this;this.values=0,i(e,this,s);var n=this.values;switch(n){case 0:this.values=t.array0;break;case 1:this.values=this;var a=function(e){switch(e.type){case b:var n=e.value;r.values!==n&&(r.values=n,r.forceUpdate());break;case y:throw e.value;default:r.values=[r.values],r.handlers=null}};this.handlers=a,i(e,a,o);break;default:this.values=Array(n).fill(this),this.handlers=[],i(e,this,u)}},render:function(){if(this.handlers instanceof Function){var e=this.values;return e===this?null:a(this.props,[e])}for(var r=this.values,n=0,t=r.length;n<t;++n)if(r[n]===this)return null;return a(this.props,r)}}),q=t.assocPartialU("createElement",p,r),x=function(e){return function(r){return U(j,h(e,r))}};e.fromKefir=P,e.default=q,e.fromClass=x,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("kefir"),require("infestines")):"function"==typeof define&&define.amd?define(["exports","react","kefir","infestines"],r):r(e.karet=e.karet||{},e.React,e.Kefir,e.I)}(this,function(e,r,n,t){"use strict";function i(e,r,n){if(W(e))return n[++r[0]];if(t.isArray(e)){for(var a=e,s=0,l=e.length;s<l;++s){var o=e[s],u=o;W(o)?u=n[++r[0]]:t.isArray(o)&&(u=i(o,r,n)),u!==o&&(a===e&&(a=e.slice(0)),a[s]=u)}return a}return e}function a(e,r,n){var t=void 0;for(var i in e){var a=e[i];if(W(a)){if(!t){t={};for(var s in e){if(s===i)break;t[s]=e[s]}}t[i]=n[++r[0]]}else t&&(t[i]=a)}return t||e}function s(e,r){var n=null,t=null,s=null,l=[-1];for(var o in e){var u=e[o];g===o?s=i(u,l,r):"$$type"===o?n=e[o]:w===o?(t=t||{},t.ref=W(u)?r[++l[0]]:u):W(u)?(t=t||{},t[o]=r[++l[0]]):A===o?(t=t||{},t.style=a(u,l,r)||u):(t=t||{},t[o]=u)}return s instanceof Array?$.apply(null,[n,t].concat(s)):s?$(n,t,s):$(n,t)}function l(e,r,n){for(var i=0,a=e.length;i<a;++i){var s=e[i];W(s)?n(r,s):t.isArray(s)&&l(s,r,n)}}function o(e,r,n){for(var i in e){var a=e[i];if(W(a))n(r,a);else if(g===i)t.isArray(a)&&l(a,r,n);else if(A===i)for(var s in a){var o=a[s];W(o)&&n(r,o)}}}function u(e){e.values+=1}function f(e,r){r.offAny(e)}function c(e,r){var n=e.pop();n&&r.offAny(n)}function v(e,r){r.onAny(e)}function h(e,r){var n=function r(n){for(var t=e.handlers,i=0;t[i]!==r;)++i;switch(n.type){case k:var a=n.value,s=e.values;s[i]!==a&&(s[i]=a,e.forceUpdate());break;case m:throw n.value;default:t[i]=null;var l=t.length;if(l!==e.values.length)return;for(var o=0;o<l;++o)if(t[o])return;e.handlers=null}};e.handlers.push(n),r.onAny(n)}function d(e,r){for(var n=r.length;e<n;++e){var i=r[e];if(W(i)||t.isArray(i)&&d(0,i))return!0}return!1}function p(e){for(var r in e){var n=e[r];if(W(n))return!0;if(g===r){if(t.isArray(n)&&d(0,n))return!0}else if(A===r)for(var i in n)if(W(n[i]))return!0}return!1}function b(e,r){var n={$$type:e};for(var t in r){var i=r[t];"ref"===t?n[w]=i:U!==t&&(n[t]=i)}return n}function y(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=r[0],a=r[1]||t.object0;return(t.isString(i)||a[U])&&(d(2,r)||p(a)?(r[1]=b(i,a),r[0]=x):a[U]&&(r[1]=t.dissocPartialU(U,a)||t.object0)),$.apply(void 0,r)}var k="value",m="error",A="style",g="children",U="karet-lift",w="$$ref",$=r.createElement,S=r.Component,W=function(e){return e instanceof n.Observable},j=t.inherit(function(e){S.call(this,e)},S,{componentWillReceiveProps:function(e){this.componentWillUnmount(),this.doSubscribe(e)},componentWillMount:function(){this.doSubscribe(this.props)}}),P=t.inherit(function(e){j.call(this,e),this.callback=this.rendered=null},j,{componentWillUnmount:function(){var e=this.callback;e&&this.props.observable.offAny(e)},doSubscribe:function(e){var r=this,n=e.observable;if(W(n)){var t=function(e){switch(e.type){case k:r.rendered=e.value||null,r.forceUpdate();break;case m:throw e.value;case"end":r.callback=null}};this.callback=t,n.onAny(t)}else this.rendered=n||null},render:function(){return this.rendered}}),q=function(e){return $(P,{observable:e})},x=t.inherit(function(e){j.call(this,e),this.values=this,this.handlers=null},j,{componentWillUnmount:function(){var e=this.handlers;e instanceof Function?o(this.props,e,f):e&&o(this.props,e.reverse(),c)},doSubscribe:function(e){var r=this;this.values=0,o(e,this,u);var n=this.values;switch(n){case 0:this.values=t.array0;break;case 1:this.values=this;var i=function(e){switch(e.type){case k:var n=e.value;r.values!==n&&(r.values=n,r.forceUpdate());break;case m:throw e.value;default:r.values=[r.values],r.handlers=null}};this.handlers=i,o(e,i,v);break;default:this.values=Array(n).fill(this),this.handlers=[],o(e,this,h)}},render:function(){if(this.handlers instanceof Function){var e=this.values;return e===this?null:s(this.props,[e])}for(var r=this.values,n=0,t=r.length;n<t;++n)if(r[n]===this)return null;return s(this.props,r)}}),C=t.assocPartialU("createElement",y,r),E=function(e){return function(r){return $(x,b(e,r))}};e.fromKefir=q,e.default=C,e.fromClass=E,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "karet",
"version": "1.1.7",
"version": "1.1.8",
"description": "Karet is a library that allows you to embed Kefir observables into React VDOM",

@@ -5,0 +5,0 @@ "module": "dist/karet.es.js",

@@ -85,25 +85,48 @@ import * as React from "react"

function forEach(props, extra, fn) {
for (const key in props) {
const val = props[key]
if (isObs(val)) {
fn(extra, val)
} else if (CHILDREN === key) {
if (isArray(val)) {
for (let i=0, n=val.length; i<n; ++i) {
const valI = val[i]
if (isObs(valI))
fn(extra, valI)
}
function renderChildren(children, at, values) {
if (isObs(children)) {
return values[++at[0]]
} else if (isArray(children)) {
let newChildren = children
for (let i=0, n=children.length; i<n; ++i) {
const childI = children[i]
let newChildI = childI
if (isObs(childI)) {
newChildI = values[++at[0]]
} else if (isArray(childI)) {
newChildI = renderChildren(childI, at, values)
}
} else if (STYLE === key) {
for (const k in val) {
const valK = val[k]
if (isObs(valK))
fn(extra, valK)
if (newChildI !== childI) {
if (newChildren === children)
newChildren = children.slice(0)
newChildren[i] = newChildI
}
}
return newChildren
} else {
return children
}
}
function renderStyle(style, at, values) {
let newStyle = undefined
for (const i in style) {
const styleI = style[i]
if (isObs(styleI)) {
if (!newStyle) {
newStyle = {}
for (const j in style) {
if (j === i)
break
newStyle[j] = style[j]
}
}
newStyle[i] = values[++at[0]]
} else if (newStyle) {
newStyle[i] = styleI
}
}
return newStyle || style
}
function render(props, values) {

@@ -114,3 +137,3 @@ let type = null

let k = -1
const at = [-1]

@@ -120,22 +143,3 @@ for (const key in props) {

if (CHILDREN === key) {
if (isObs(val)) {
newChildren = values[++k]
} else if (isArray(val)) {
for (let i=0, n=val.length; i<n; ++i) {
const valI = val[i]
if (isObs(valI)) {
if (!newChildren) {
newChildren = Array(n)
for (let j=0; j<i; ++j)
newChildren[j] = val[j]
}
newChildren[i] = values[++k]
} else if (newChildren)
newChildren[i] = valI
}
if (!newChildren)
newChildren = val
} else {
newChildren = val
}
newChildren = renderChildren(val, at, values)
} else if ("$$type" === key) {

@@ -145,26 +149,9 @@ type = props[key]

newProps = newProps || {}
newProps.ref = isObs(val) ? values[++k] : val
newProps.ref = isObs(val) ? values[++at[0]] : val
} else if (isObs(val)) {
newProps = newProps || {}
newProps[key] = values[++k]
newProps[key] = values[++at[0]]
} else if (STYLE === key) {
let newStyle
for (const i in val) {
const valI = val[i]
if (isObs(valI)) {
if (!newStyle) {
newStyle = {}
for (const j in val) {
if (j === i)
break
newStyle[j] = val[j]
}
}
newStyle[i] = values[++k]
} else if (newStyle) {
newStyle[i] = valI
}
}
newProps = newProps || {}
newProps.style = newStyle || val
newProps.style = renderStyle(val, at, values) || val
} else {

@@ -185,2 +172,32 @@ newProps = newProps || {}

function forEachInChildrenArray(children, extra, fn) {
for (let i=0, n=children.length; i<n; ++i) {
const childI = children[i]
if (isObs(childI))
fn(extra, childI)
else if (isArray(childI))
forEachInChildrenArray(childI, extra, fn)
}
}
function forEachInProps(props, extra, fn) {
for (const key in props) {
const val = props[key]
if (isObs(val)) {
fn(extra, val)
} else if (CHILDREN === key) {
if (isArray(val))
forEachInChildrenArray(val, extra, fn)
} else if (STYLE === key) {
for (const k in val) {
const valK = val[k]
if (isObs(valK))
fn(extra, valK)
}
}
}
}
//
function incValues(self) { self.values += 1 }

@@ -235,5 +252,5 @@ function offAny1(handlers, obs) { obs.offAny(handlers) }

if (handlers instanceof Function) {
forEach(this.props, handlers, offAny1)
forEachInProps(this.props, handlers, offAny1)
} else if (handlers) {
forEach(this.props, handlers.reverse(), offAny)
forEachInProps(this.props, handlers.reverse(), offAny)
}

@@ -243,3 +260,3 @@ },

this.values = 0
forEach(props, this, incValues)
forEachInProps(props, this, incValues)
const n = this.values

@@ -271,3 +288,3 @@

this.handlers = handlers
forEach(props, handlers, onAny1)
forEachInProps(props, handlers, onAny1)
break

@@ -278,3 +295,3 @@ }

this.handlers = []
forEach(props, this, onAny)
forEachInProps(props, this, onAny)
}

@@ -300,2 +317,11 @@ },

function hasObsInChildrenArray(i, children) {
for (const n = children.length; i < n; ++i) {
const child = children[i]
if (isObs(child) || isArray(child) && hasObsInChildrenArray(0, child))
return true
}
return false
}
function hasObsInProps(props) {

@@ -307,6 +333,4 @@ for (const key in props) {

} else if (CHILDREN === key) {
if (isArray(val))
for (let i=0, n=val.length; i<n; ++i)
if (isObs(val[i]))
return true
if (isArray(val) && hasObsInChildrenArray(0, val))
return true
} else if (STYLE === key) {

@@ -321,15 +345,3 @@ for (const k in val)

function hasObsInArgs(args) {
for (let i=2, n=args.length; i<n; ++i) {
const arg = args[i]
if (isArray(arg)) {
for (let j=0, m=arg.length; j<m; ++j)
if (isObs(arg[j]))
return true
} else if (isObs(arg)) {
return true
}
}
return hasObsInProps(args[1])
}
//

@@ -348,14 +360,10 @@ function filterProps(type, props) {

function hasLift(props) {
return props && props[KARET_LIFT] === true
}
function createElement(...args) {
const type = args[0]
const props = args[1]
if (isString(type) || hasLift(props)) {
if (hasObsInArgs(args)) {
const props = args[1] || object0
if (isString(type) || props[KARET_LIFT]) {
if (hasObsInChildrenArray(2, args) || hasObsInProps(props)) {
args[1] = filterProps(type, props)
args[0] = FromClass
} else if (hasLift(props)) {
} else if (props[KARET_LIFT]) {
args[1] = dissocPartialU(KARET_LIFT, props) || object0

@@ -362,0 +370,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc