Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

riot-observable

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

riot-observable - npm Package Compare versions

Comparing version 2.3.0-beta to 2.3.0-beta.2

29

dist/observable.js

@@ -15,3 +15,11 @@ ;(function(window, undefined) {var observable = function(el) {

var callbacks = {},
onEachEvent = function(e, fn) { e.replace(/\S+/g, fn) }
onEachEvent = function(e, fn) { e.replace(/\S+/g, fn) },
defineProperty = function (key, value) {
Object.defineProperty(el, key, {
value: value,
enumerable: false,
writable: false,
configurable: false
})
}

@@ -25,3 +33,3 @@ /**

el.on = function(events, fn) {
defineProperty('on', function(events, fn) {
if (typeof fn != 'function') return el

@@ -35,3 +43,3 @@

return el
}
})

@@ -45,3 +53,3 @@ /**

el.off = function(events, fn) {
defineProperty('off', function(events, fn) {
if (events == '*') callbacks = {}

@@ -59,3 +67,3 @@ else {

return el
}
})

@@ -69,3 +77,3 @@ /**

el.one = function(events, fn) {
defineProperty('one', function(events, fn) {
function on() {

@@ -76,3 +84,3 @@ el.off(events, on)

return el.on(events, on)
}
})

@@ -85,3 +93,3 @@ /**

el.trigger = function(events) {
defineProperty('trigger', function(events) {
var args = [].slice.call(arguments, 1)

@@ -110,7 +118,8 @@

return el
}
})
return el
} /* istanbul ignore next */
}
/* istanbul ignore next */
// support CommonJS, AMD & browser

@@ -117,0 +126,0 @@ if (typeof exports === 'object')

@@ -15,3 +15,11 @@ riot.observable = function(el) {

var callbacks = {},
onEachEvent = function(e, fn) { e.replace(/\S+/g, fn) }
onEachEvent = function(e, fn) { e.replace(/\S+/g, fn) },
defineProperty = function (key, value) {
Object.defineProperty(el, key, {
value: value,
enumerable: false,
writable: false,
configurable: false
})
}

@@ -25,3 +33,3 @@ /**

el.on = function(events, fn) {
defineProperty('on', function(events, fn) {
if (typeof fn != 'function') return el

@@ -35,3 +43,3 @@

return el
}
})

@@ -45,3 +53,3 @@ /**

el.off = function(events, fn) {
defineProperty('off', function(events, fn) {
if (events == '*') callbacks = {}

@@ -59,3 +67,3 @@ else {

return el
}
})

@@ -69,3 +77,3 @@ /**

el.one = function(events, fn) {
defineProperty('one', function(events, fn) {
function on() {

@@ -76,3 +84,3 @@ el.off(events, on)

return el.on(events, on)
}
})

@@ -85,3 +93,3 @@ /**

el.trigger = function(events) {
defineProperty('trigger', function(events) {
var args = [].slice.call(arguments, 1)

@@ -110,3 +118,3 @@

return el
}
})

@@ -113,0 +121,0 @@ return el

@@ -15,3 +15,11 @@ var observable = function(el) {

var callbacks = {},
onEachEvent = function(e, fn) { e.replace(/\S+/g, fn) }
onEachEvent = function(e, fn) { e.replace(/\S+/g, fn) },
defineProperty = function (key, value) {
Object.defineProperty(el, key, {
value: value,
enumerable: false,
writable: false,
configurable: false
})
}

@@ -25,3 +33,3 @@ /**

el.on = function(events, fn) {
defineProperty('on', function(events, fn) {
if (typeof fn != 'function') return el

@@ -35,3 +43,3 @@

return el
}
})

@@ -45,3 +53,3 @@ /**

el.off = function(events, fn) {
defineProperty('off', function(events, fn) {
if (events == '*') callbacks = {}

@@ -59,3 +67,3 @@ else {

return el
}
})

@@ -69,3 +77,3 @@ /**

el.one = function(events, fn) {
defineProperty('one', function(events, fn) {
function on() {

@@ -76,3 +84,3 @@ el.off(events, on)

return el.on(events, on)
}
})

@@ -85,3 +93,3 @@ /**

el.trigger = function(events) {
defineProperty('trigger', function(events) {
var args = [].slice.call(arguments, 1)

@@ -110,6 +118,6 @@

return el
}
})
return el
}
}
{
"name": "riot-observable",
"version": "2.3.0-beta",
"version": "2.3.0-beta.2",
"description": "Simple script to send and receive events",

@@ -28,3 +28,5 @@ "main": "dist/observable.js",

"karma-mocha": "^0.2.0",
"karma-phantomjs-launcher": "^0.2.1"
"karma-phantomjs-launcher": "^0.2.1",
"mocha": "^2.3.3",
"phantomjs": "^1.9.18"
},

@@ -31,0 +33,0 @@ "author": "Muut, Inc. and other contributors",

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

/*
* Equivalent to Object.propertyIsEnumerable
*/
function hasEnumerableProperty(object, key) {
for (var k in object) {
if (key === k) {
return true
}
}
return false
}
describe('Core specs', function() {

@@ -13,2 +25,38 @@ var el = observable(),

it('public methods should not be enumerable', function () {
expect(hasEnumerableProperty(el, 'on')).to.be(false)
expect(hasEnumerableProperty(el, 'one')).to.be(false)
expect(hasEnumerableProperty(el, 'trigger')).to.be(false)
expect(hasEnumerableProperty(el, 'off')).to.be(false)
})
it('public methods can not be configurable', function () {
delete el.on
expect(el.on).to.not.be(undefined)
delete el.one
expect(el.one).to.not.be(undefined)
delete el.trigger
expect(el.trigger).to.not.be(undefined)
delete el.off
expect(el.off).to.not.be(undefined)
})
it('public methods can not be overriden', function () {
el.on = 'foo'
expect(el.on).to.not.be('foo')
el.one = 'foo'
expect(el.one).to.not.be('foo')
el.trigger = 'foo'
expect(el.trigger).to.not.be('foo')
el.off = 'foo'
expect(el.off).to.not.be('foo')
})
it('single listener', function() {

@@ -15,0 +63,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