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

pjs

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pjs - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

.gitignore

8

build/p.commonjs.js

@@ -27,3 +27,3 @@ // pass

// and in particular to initialize objects with variable arguments, which
// is impossible with tne `new` keyword. Note that in this case,
// is impossible with the `new` keyword. Note that in this case,
// !(this instanceof C) springs the return trap at the beginning, and

@@ -80,2 +80,8 @@ // C is called with the `new` keyword and one argument, which is the

// if there's no init, we assume we're inheriting a non-pjs class, so
// we default to applying the superclass's constructor.
if (!isFunction(proto.init)) {
proto.init = function() { _superclass.apply(this, arguments); };
}
return C;

@@ -82,0 +88,0 @@ }

2

package.json
{
"name": "pjs",
"version": "0.1.3",
"version": "0.2.0",
"description": "A lightweight class system. It's just prototypes!",

@@ -5,0 +5,0 @@ "keywords": ["class", "pjs", "P", "inheritance", "super"],

@@ -26,3 +26,3 @@ var P = (function(prototype, hasOwnProperty, undefined) {

// and in particular to initialize objects with variable arguments, which
// is impossible with tne `new` keyword. Note that in this case,
// is impossible with the `new` keyword. Note that in this case,
// !(this instanceof C) springs the return trap at the beginning, and

@@ -79,2 +79,8 @@ // C is called with the `new` keyword and one argument, which is the

// if there's no init, we assume we're inheriting a non-pjs class, so
// we default to applying the superclass's constructor.
if (!isFunction(proto.init)) {
proto.init = function() { _superclass.apply(this, arguments); };
}
return C;

@@ -81,0 +87,0 @@ }

@@ -75,2 +75,48 @@ var assert = require('assert')

describe('inheriting builtins', function() {
describe('Error', function() {
var MyError = P(Error, {});
try {
throw MyError('o noes');
} catch(e) {
assert.ok(e instanceof MyError);
}
});
describe('RegExp', function() {
var MyRegExp = P(RegExp, {})
, re = MyRegExp('a(b+)c')
;
assert.ok(re instanceof RegExp);
// pending: doesn't work yet
// assert.ok(MyRegExp('a(b+)c').test('abbbbc'))
});
describe('String', function() {
var MyString = P(String, {})
, str = MyString('foo')
;
assert.ok(str instanceof String);
// pending: doesn't work yet
// assert.equal('foo', str.toString());
});
describe('Array', function() {
var MyArray = P(Array, {})
, ary = MyArray(1,2,3)
;
assert.ok(ary instanceof Array);
// apparently the Array constructor isn't destructive :(
// when you `apply` it to an instance of Array, it just creates
// a new one for you. Bah.
// assert.equal(3, ary.length);
// assert.equal(1, ary[0]);
});
});
describe('definition', function() {

@@ -77,0 +123,0 @@ it('passes the prototype as the first arg', function() {

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