Socket
Socket
Sign inDemoInstall

dry-underscore

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dry-underscore - npm Package Compare versions

Comparing version 0.22.2 to 0.23.0

15

lib/common.js

@@ -188,2 +188,6 @@ "use strict";

// TODO: var match_user_or_admin = _.prop_eq("type", ["user, "admin"]);
// this is getting pretty crazy, like to the limit of my understanding, I think we should simplify
// and if I want _.code to be super complicated, just make it a one off, this is too generic, i have to look at the source to figure out what it does
_.propEq = _.prop_eq = _.property_eq = _.propertyEq = _.property_compare(_.eq);

@@ -231,6 +235,2 @@ _.propNe = _.prop_ne = _.property_ne = _.propertyNe = _.property_compare(_.ne);

_.lc = function(s){
return(s.toLowerCase());
};
_.isoDate = _.iso_date = function(d, tz){

@@ -379,2 +379,3 @@ if(d === undefined){ d = _.date(); }

if(hours > 12){ hours -= 12; }
if(hours === 0){ hours = 12; }

@@ -952,3 +953,4 @@ return(hours + ":" + minutes + " " + am_pm);

if(insensitive){
return(_.any(col, function(a){ return(a.toLowerCase() === target.toLowerCase()); }));
target = _.lc(target);
return(_.any(col, function(a){ return(_.lc(a) === target); }));
}else{

@@ -992,2 +994,5 @@ return(_.any(col, function(a){ return(a === target); }));

_.lc = function(s){ return(s.toLowerCase()); };
_.lct = _.compose(_.lc, _.trim);
_.getter = function(hash_name, variable_name){

@@ -994,0 +999,0 @@ if(hash_name !== undefined && variable_name !== undefined){

@@ -1012,2 +1012,4 @@ "use strict";

eq(_.minutes.time_string(10), "12:10 AM");
eq(_.minutes.time_string(10, true), "0:10");
eq(_.minutes.time_string(60), "1:00 AM");

@@ -1403,1 +1405,48 @@ eq(_.minutes.time_string((60 * 24) + 60), "1:00 AM");

test("trim", function(){
eq(_.trim(" \n\taB cD \n\t"), "aB cD");
eq(_.trim("\n\t AB CD\t\n "), "AB CD");
});
test("lc", function(){
eq(_.lc("aBcD"), "abcd");
eq(_.lc("ABCD"), "abcd");
});
test("lct", function(){
eq(_.lct(" \n\taBcD \n\t"), "abcd");
eq(_.lct(" \n\taBc D \n\t"), "abc d");
eq(_.lct("\n\t ABC D\t\n "), "abc d");
});
test("unionize", function(){
var o = { x : 0 };
function a(b){ b.x++; }
function b(b){ b.x++; }
function c(b){ b.x++; }
_.unionize(a, b, c)(o);
eq(o.x, 3);
});
test("unionize complex", function(){
var o = { x : 0 };
var count = 0;
function a(b){ b.a = count++; }
function b(b){ b.b = count++; }
function c(b){ b.c = count++; }
var f = _.noop;
f = _.unionize(f, a);
f = _.unionize(f, b);
f = _.unionize(f, c);
f(o);
eq(o, { x: 0, a: 0, b: 1, c: 2});
});

@@ -9,9 +9,18 @@ "use strict";

f.hook_parent = _.rw("_hook_parent");
f.hook = function(event, callback, is_error_handler){
var self = this;
if(!event || !callback){ _.fatal("You must provide an event name and a function."); }
event = event.toLowerCase();
if(self._hooks === undefined){ self._hooks = {}; }
// this is unconventional, but I want to pollute the host object as little as possible.
if(_.isObject(event) && _.isFunction(event.hooks)){
self._hooks["__parent"] = event;
return;
}
if(!_.isString(event) || !_.isFunction(callback)){ _.fatal("You must provide an event name and a function."); }
event = _.lct(event);
if(event === "__parent"){ _.fatal('You can\'t use "__parent" as an event name'); }
if(self._hooks[event] === undefined){ self._hooks[event] = []; }

@@ -22,9 +31,13 @@

f.hook_parent = _.removed("hook_parent");
f.hooks = function(event){
var self = this;
var hooks = [];
var parent = this.hook_parent();
var parent = self._hooks && self._hooks["__parent"];
if(parent){ hooks = parent.hooks(event); }
if(this._hooks && this._hooks[event]){
hooks = _.concat(hooks, this._hooks[event]);
if(self._hooks && self._hooks[event]){
hooks = _.concat(hooks, self._hooks[event]);
}

@@ -40,4 +53,4 @@

if(!event || !callback){ _.fatal("You must provide an event name and a function."); }
event = event.toLowerCase();
if(!_.isString(event) || !_.isFunction(callback)){ _.fatal("You must provide an event name and a function."); }
event = _.lct(event);

@@ -61,6 +74,4 @@ if(self._hooks && self._hooks[event]){

if(!_.isString(event) || !_.isFunction(callback)){
_.fatal("You must provide an event name and a function.");
}
event = event.toLowerCase();
if(!_.isString(event) || !_.isFunction(callback)){ _.fatal("You must provide an event name and a function."); }
event = _.lct(event);

@@ -67,0 +78,0 @@ var hooks = self.hooks(event);

@@ -226,3 +226,3 @@ "use strict";

child.hook_parent(h);
child.hook(h);

@@ -336,3 +336,3 @@ child.bite("push_index", [[],[]], function(err, a, b){

parent.hook_parent(grand_parent);
parent.hook(grand_parent);

@@ -353,3 +353,3 @@ parent.hook("append", function(next, a, b){

child.hook_parent(parent);
child.hook(parent);

@@ -356,0 +356,0 @@ child.hook("append", function(next, a, b){

{
"name": "dry-underscore",
"version": "0.22.2",
"version": "0.23.0",
"dependencies": {

@@ -5,0 +5,0 @@ "deep-diff": {

{
"name": "dry-underscore",
"version": "0.22.2",
"version": "0.23.0",
"main": "./index/node.index.js",

@@ -5,0 +5,0 @@ "description": "The DRY Underscore Library",

@@ -29,14 +29,2 @@ var fs = require('fs');

exports.testUnionize = function(){
var o = { x : 0 };
function a(b){ b.x++; }
function b(b){ b.x++; }
function c(b){ b.x++; }
_.unionize(a, b, c)(o);
assert.eql(o.x, 3);
};
exports.testIsObject = function(){

@@ -43,0 +31,0 @@

Sorry, the diff of this file is too big to display

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