Socket
Socket
Sign inDemoInstall

mol-proto

Package Overview
Dependencies
0
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.5 to 0.1.6

2

bower.json
{
"name": "proto",
"version": "0.1.5",
"version": "0.1.6",
"homepage": "https://github.com/MailOnline/proto",

@@ -5,0 +5,0 @@ "authors": [

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

* - [makeSubclass](#makeSubclass)
* - [newApply](#newApply)
*

@@ -14,3 +15,4 @@ * These methods can be [chained](proto.js.html#Proto)

createSubclass: createSubclass,
makeSubclass: makeSubclass
makeSubclass: makeSubclass,
newApply: newApply
};

@@ -115,1 +117,16 @@

}
/**
* Calls constructor `this` with arguments passed as array
*
* @param {Function} thisClass A class constructor that will be called
* @return {Array|Array-like} args Array of arguments that will be passed to constructor
*/
function newApply(args) {
if (! Array.isArray(args))
args = Array.prototype.slice.call(args);
// "null" is context to pass to class constructor, first parameter of bind
var args = [null].concat(args);
return new (Function.prototype.bind.apply(this, args));
}

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

* - [hashCode](#hashCode)
* - [unPrefix](#unPrefix)
*/

@@ -28,3 +29,4 @@ var stringMethods = module.exports = {

jsonParse: jsonParse,
hashCode: hashCode
hashCode: hashCode,
unPrefix: unPrefix
};

@@ -159,3 +161,3 @@

/**
* Dan bernstein's algorythm to create hash from string
* Dan Bernstein's algorythm to create hash from string
*

@@ -165,3 +167,3 @@ * @param {String} self string to convert to hash

*/
function hashCode(){
function hashCode() {
var hash = 5381

@@ -176,1 +178,13 @@ , str = this

}
/**
* Removes given prefix from the string. If string does not begin from the prefix, returns undefined
*
* @param {String} self
* @return {String}
*/
function unPrefix(str) {
if (this.indexOf(str) == 0)
return this.replace(str, '');
}

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

* - [makeSubclass](proto_prototype.js.html#makeSubclass)
* - [newApply](proto_prototype.js.html#newApply)
*/

@@ -97,2 +98,3 @@ var prototypeMethods = require('./proto_prototype');

* - [hashCode](proto_string.js.html#hashCode)
* - [unPrefix](proto_string.js.html#unPrefix)
*/

@@ -99,0 +101,0 @@ var stringMethods = require('./proto_string');

{
"name": "mol-proto",
"version": "0.1.5",
"version": "0.1.6",
"description": "ES5 object manipulation library for node and modern browsers",

@@ -5,0 +5,0 @@ "main": "lib/proto.js",

@@ -57,2 +57,3 @@ proto

* [makeSubclass](http://mailonline.github.io/proto/proto_prototype.js.html#makeSubclass)
* [newApply](http://mailonline.github.io/proto/proto_prototype.js.html#newApply)

@@ -123,2 +124,3 @@

* [hashCode](http://mailonline.github.io/proto/proto_string.js.html#hashCode)
* [unPrefix](http://mailonline.github.io/proto/proto_string.js.html#unPrefix)

@@ -125,0 +127,0 @@ * [__Number functions__](http://mailonline.github.io/proto/proto_number.js.html)

@@ -111,2 +111,24 @@ 'use strict';

});
it('should define newApply method', function() {
function MyClass(a, b, c) {
this.a = a;
this.b = b;
this.c = c;
}
var obj1 = new MyClass(1, 2, 3);
var obj2 = _.newApply(MyClass, [1, 2, 3]);
assert.deepEqual(obj1, obj2);
function createMyClass() {
return _.newApply(MyClass, arguments);
}
var obj3 = createMyClass(1, 2, 3);
assert.deepEqual(obj1, obj3);
});
});

@@ -96,3 +96,9 @@ 'use strict';

assert(result1 != result2);
})
});
it('should define unPrefix function', function() {
assert.equal(_.unPrefix('root_string', 'root_'), 'string');
assert.equal(_.unPrefix('other_string', 'root_'), undefined);
});
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc