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

interface

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interface - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

.eslintignore

15

index.js

@@ -12,3 +12,2 @@ function createInterface () {

} else {
// assert that each of the functions are defined on the prototype
var prototype = Object.getPrototypeOf(this)

@@ -31,2 +30,16 @@ var unimplemented = []

// expose valiate function
Interface.isImplementedBy = function (object) {
var prototype = Object.getPrototypeOf(object)
var length = functionNames.length
while (length--) {
if (typeof prototype[functionNames[length]] !== 'function') {
return false
}
}
return true
}
return Interface

@@ -33,0 +46,0 @@ }

5

package.json
{
"name": "interface",
"version": "1.1.1",
"version": "1.2.0",
"description": "Enforce an interface on classes",

@@ -10,3 +10,3 @@ "main": "index.js",

"coveralls": "^2.11.16",
"eslint": "^3.15.0",
"eslint": "^4.3.0",
"eslint-config-standard": "^6.2.1",

@@ -19,2 +19,3 @@ "eslint-plugin-promise": "^3.4.2",

"scripts": {
"pretest": "npm run lint",
"test": "nyc --reporter=lcov mocha",

@@ -21,0 +22,0 @@ "lint": "eslint .",

@@ -83,3 +83,2 @@ var expect = require('chai').expect

function MySubSubClass () {

@@ -117,2 +116,22 @@ MyClass.call(this)

})
describe('validate implementation without being a child of interface', function () {
var MyInterface = new Interface('methodA')
it('should return false for bad child', function () {
class BadChild {}
expect(MyInterface.isImplementedBy(new BadChild())).to.be.false
})
it('should return true for good child', function () {
class GoodChild extends MyInterface {
methodA () {
return true
}
}
expect(MyInterface.isImplementedBy(new GoodChild())).to.be.true
})
})
})

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