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

brink

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brink - npm Package Compare versions

Comparing version 0.0.10 to 0.1.0

src/brink/browser/ready.js

2

package.json
{
"name": "brink",
"version": "0.0.10",
"version": "0.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "./src/brink/brink.js",

@@ -7,2 +7,3 @@ 'use strict';

IS_NODE,
IS_BROWSER,
EMPTY_FN;

@@ -12,2 +13,3 @@

IS_NODE = typeof exports !== 'undefined' && this.exports !== exports;
IS_BROWSER = !IS_NODE;
/*jshint ignore : end */

@@ -18,2 +20,5 @@

CONFIG.IS_NODE = IS_NODE;
CONFIG.IS_BROWSER = IS_BROWSER;
EMPTY_FN = function () {};

@@ -135,6 +140,17 @@

'brink/core/Dictionary',
'brink/core/ObjectProxy',
'brink/core/InstanceManager',
'brink/dom/Attr',
'brink/dom/DOMObject',
'brink/dom/Element',
'brink/dom/Template',
'brink/dom/Tag',
'brink/dom/Text',
'brink/dom/tags/if',
'brink/dom/tags/for',
'brink/browser/ajax',
'brink/browser/ready',
'brink/browser/ReactMixin',

@@ -141,0 +157,0 @@

@@ -24,4 +24,14 @@ $b(

getChanges : function () {
return {
added : [],
removed : [],
moved : []
};
},
init : function (content) {
content = content || [];
this.set('content', content);

@@ -28,0 +38,0 @@ this.set('oldContent', content.concat());

@@ -84,3 +84,3 @@ $b(

has : function (o) {
return !~this.keys.indexOf(o);
return !!~this.keys.indexOf(o);
},

@@ -87,0 +87,0 @@

@@ -208,6 +208,2 @@ $b(

}
if (d.watch && d.watch.length) {
this.watch(d.watch, d.didChange);
}
},

@@ -217,4 +213,22 @@

var p;
var b,
p,
i,
meta,
bindings;
meta = this.__meta;
bindings = meta.externalBindings || {};
// Cleanup external bindings
for (p in bindings) {
for (i = 0; i < bindings[p].length; i ++) {
b = bindings[p][i];
if (!b.obj.isDestroyed) {
b.obj.unwatch(b.localProp.didChange);
}
}
}
for (p in this.__meta.properties) {

@@ -261,2 +275,104 @@ delete this[p];

__hasReference : function (obj) {
this.__meta.references = this.__meta.references || $b.Dictionary.create();
return this.__meta.references.has(obj);
},
__addReference : function (obj, key) {
this.__meta.references = this.__meta.references || $b.Dictionary.create();
this.__meta.references.add(obj, key);
},
__removeReference : function (obj) {
this.__meta.references = this.__meta.references || $b.Dictionary.create();
this.__meta.references.remove(obj);
},
__propertiesDidChange : function (props, skipReference) {
var i,
j,
p,
tmp,
meta,
bindings,
changedProps;
if ($b.instanceManager && props.length) {
meta = this.__meta;
changedProps = meta.changedProps || [];
bindings = meta.bindings;
if (props.length) {
for (i = 0; i < props.length; i ++) {
p = props[i];
if (changedProps.indexOf(p) > -1) {
props.splice(i, 1);
i --;
}
else if (bindings[p] && bindings[p].length) {
props = props.concat(bindings[p]);
}
else if (changedProps.length) {
for (j = 0; j < changedProps.length; j ++) {
if (new RegExp(changedProps[j] + '\.').test(p)) {
props.splice(i, 1);
i --;
}
}
}
}
}
if (props.length) {
for (i = 0; i < props.length; i ++) {
p = props[i].split('.');
tmp = p[p.length - 1];
if (p.length > 2) {
p = p.splice(0, p.length - 1).join('.');
if (bindings[p] && bindings[p].length) {
for (j = 0; j < bindings[p].length; j ++) {
props.push(bindings[p][j] + '.' + tmp);
}
}
}
}
$b.instanceManager.propertyDidChange(this, props);
if (meta.references) {
meta.references.forEach(function (key, instance) {
var subProps = [];
if (instance.isDestroyed) {
this.__removeReference(instance);
return;
}
for (i = 0; i < props.length; i ++) {
p = (key ? key + '.' : '') + props[i];
if (skipReference !== instance && get(instance, p) !== this) {
subProps.push(p);
}
}
instance.__propertiesDidChange(subProps, this);
}, this);
}
}
}
},
/***********************************************************************

@@ -271,11 +387,5 @@ Invalidate one or more properties. This will trigger any bound and computed properties

************************************************************************/
propertyDidChange : function () {
var props;
propertyDidChange : function (props) {
props = flatten([].slice.call(arguments, 0, arguments.length));
if ($b.instanceManager) {
$b.instanceManager.propertyDidChange(this, props);
}
return this.__propertiesDidChange(props);
},

@@ -336,11 +446,18 @@

var obj;
var a,
i,
obj,
meta;
obj = getObjKeyPair(this, key);
key = obj[1];
obj = obj[0];
obj = obj[0] || this;
if (typeof obj.__meta.properties[key] !== 'undefined') {
meta = obj.__meta;
meta.bindings = meta.bindings || {};
meta.externalBindings = meta.externalBindings || {};
if (typeof meta.properties[key] !== 'undefined') {
if (typeof val === 'undefined') {
return obj.__meta.properties[key];
return meta.properties[key];
}

@@ -358,7 +475,14 @@ }

val = obj.__meta.properties[key] = defineProperty(obj, key, val);
val = meta.properties[key] = defineProperty(obj, key, val);
val.key = key;
if (val.watch && val.watch.length) {
for (i = 0; i < val.watch.length; i ++) {
a = meta.bindings[val.watch[i]] = meta.bindings[val.watch[i]] || [];
a.push(key);
}
}
val.bindTo = bindFunction(function (o, p) {
o.prop(p, bindTo(obj, key, true));
this.prop(p, bindTo(o, p));
}, obj);

@@ -370,3 +494,13 @@

if (obj.__meta.isInitialized) {
if (val.boundTo) {
a = meta.externalBindings[key] = meta.externalBindings[key] || [];
a.push({
obj : val.boundTo[0],
key : val.boundTo[1],
localProp : val
});
val.boundTo[0].watch(val.boundTo[1], val.didChange);
}
if (meta.isInitialized) {
obj.__defineProperty(key, val);

@@ -562,3 +696,2 @@ }

destroy : function () {
this.unwatchAll();

@@ -572,2 +705,3 @@ this.__undefineProperties();

this.__meta = null;
this.isDestroyed = true;
}

@@ -574,0 +708,0 @@ });

@@ -23,3 +23,3 @@ (function () {

_loadedFiles = {},
_modules = {},
_modules = $b.__registry = {},
_metas = {},

@@ -26,0 +26,0 @@ _head,

@@ -52,2 +52,4 @@ $b(

boundTo : [a, prop],
get : function () {

@@ -58,14 +60,5 @@ return a.get(prop);

set : function (val) {
val = val;
return a.set(prop, val);
},
__didChange : function () {
return b.didChange();
},
value : a.get(prop)
}
});
a.watch(prop, b.__didChange);
}

@@ -72,0 +65,0 @@

@@ -37,4 +37,3 @@ $b(

typeof descriptor.defaultValue !== 'undefined' ?
descriptor.defaultValue :
descriptor.value
descriptor.defaultValue : descriptor.value
);

@@ -41,0 +40,0 @@

@@ -10,4 +10,11 @@ $b(

return function (a, b, i, j, p, n, s) {
return function (a, skipRoot) {
var b,
i,
j,
p,
n,
s;
a = [].concat(a);

@@ -21,3 +28,3 @@

if (~p.indexOf('.')) {
if (!skipRoot && ~p.indexOf('.')) {

@@ -24,0 +31,0 @@ b = p.split('.');

@@ -51,2 +51,6 @@ $b(

if (obj.isDestroyed) {
return null;
}
if (obj.__meta.getters[k]) {

@@ -53,0 +57,0 @@ obj = obj.__meta.getters[k].call(obj, k);

@@ -51,3 +51,5 @@ $b(

var i;
var i,
old,
isDiff;

@@ -59,9 +61,30 @@ if (typeof key === 'string') {

obj = obj[0];
old = get(obj, key);
if (skipCompare || get(obj, key) !== val) {
isDiff = old !== val;
if (skipCompare || isDiff) {
if (obj instanceof $b.Object) {
if (isDiff) {
if (old instanceof $b.Object) {
old.__removeReference(obj);
}
if (val instanceof $b.Object) {
val.__addReference(
obj,
(
key === 'proxy' &&
val instanceof $b.ObjectProxy ?
'' :
key
)
);
}
}
if (obj.__meta.setters[key]) {
val = obj.__meta.setters[key].call(obj, val, key);
obj.__meta.setters[key].call(obj, val, key);
}

@@ -68,0 +91,0 @@

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

var packageJSON = require('../package.json');
require('require-main')();

@@ -6,3 +8,3 @@

file : '../dist/brink-prod.js',
minifiedFile : '../dist/brink-prod.min.js',
minifiedFile : '../dist/' + packageJSON.version + '/brink-prod.min.js',
exclude : ['brink/node/**', 'brink/dev/**'],

@@ -15,5 +17,5 @@ minify : false

cwd : __dirname,
file : '../dist/brink-dev.js',
file : '../dist/' + packageJSON.version + '/brink-dev.js',
exclude : ['brink/node/**'],
minify : false
});
var cp,
jscs,
chalk,
jshint;
cp = require('child_process');
chalk = require('chalk'),
console.log('');
console.log('------------------------------------------------');
console.log('');
console.log(chalk.gray('Running jscs check....\n'));
jscs = cp.fork('./node_modules/jscs/bin/jscs', ['src/brink']);

@@ -15,3 +21,4 @@

console.log('');
console.log('------------------------------------------------');
console.log(chalk.gray('Running jshint check....'));
jshint = cp.fork('./node_modules/jshint/bin/jshint', ['--reporter', './tasks/lint-reporter.js', 'src/brink']);

@@ -24,3 +31,2 @@

}
});

@@ -33,3 +33,3 @@ describe('mutations', function () {

a.watch(function () {
a.watch('@each', function () {
expect(a.getChanges().added.length).to.equal(3);

@@ -36,0 +36,0 @@ done();

@@ -44,4 +44,4 @@ describe('bindings', function () {

expect(a.test).to.equal(1);
expect(b.test).to.equal(1);
expect(a.test).to.equal(2);
expect(b.test).to.equal(2);

@@ -60,26 +60,4 @@ a.test = 5;

it('should be able to add watchers to $b.Object instances', function (done) {
it('should be able to bind to nested properties', function (done) {
var a;
a = $b.Object.create({
test : 1
});
a.watch('test', function () {
expect(a.test).to.equal(10);
a.test = 20;
a.destroy();
done();
});
expect(a.test).to.equal(1);
a.test = 10;
expect(a.test).to.equal(10);
});
it('should be able to add watchers to bound properties', function (done) {
var a,

@@ -94,25 +72,19 @@ b,

b = $b.Object.create({
test2 : $b.bindTo(a, 'test1')
a : a
});
c = $b.Object.create({
test3 : $b.bindTo(b, 'test2')
b : b,
test3 : $b.bindTo('b.a.test1')
});
c.watch('test3', function () {
expect(a.test1).to.equal(1);
expect(c.test3).to.equal(a.test1);
a.test1 = 10;
expect(a.test1).to.equal(10);
expect(c.test3).to.equal(a.test1);
expect(a.test1).to.equal(b.test2);
expect(c.test3).to.equal(b.test2);
expect(c.test3).to.equal(10);
done();
a.destroy();
b.destroy();
c.destroy();
done();
});
a.test1 = 10;
});
});

@@ -22,2 +22,3 @@ describe("$b.Object", function () {

require("./bindings");
require("./watchers");
require("./computed");

@@ -24,0 +25,0 @@

@@ -5,3 +5,4 @@ var p,

chai,
mocha;
mocha,
timeout;

@@ -22,2 +23,6 @@ require('require-main')();

var done = function (failures) {
process.exit(failures);
};
function addTests(folder, p) {

@@ -40,6 +45,16 @@

module.exports = function (cb) {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
mocha.run(cb);
};
addTests(path.join(__dirname, 'brink'));
mocha.run(function(failures) {
process.exit(failures);
});
timeout = setTimeout(function () {
mocha.run(done);
}, 0);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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