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

subtender

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subtender - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

base/common.js

119

base/index.js

@@ -7,4 +7,14 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _common = require('./common');
Object.keys(_common).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _common[key];
}
});
});
var _memoizeFixedArity = require('./memoize-fixed-arity');

@@ -22,101 +32,12 @@

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _objectZipper = require('./object-zipper');
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
/*
This module is meant to be a module that you can use without
any dependencies.
*/
// enumFromTo(x,y) = [x,x+1,x+2...y]
// only guarantee to work on increasing sequences
var enumFromTo = function enumFromTo(frm, to) {
var succ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (x) {
return x + 1;
};
var arr = [];
for (var i = frm; i <= to; i = succ(i)) {
arr.push(i);
}return arr;
};
// usage: "ignore(a,b,c)" to make eslint believe that "a", "b" and "c"
// are somehow being used,
// it serves as an explicit annotation to say that they actually aren't
var ignore = function ignore() {
return undefined;
};
var not = function not(x) {
return !x;
};
// "modifyArray(index,f)(xs)" keeps "xs" intact and returns a new array
// whose element on "index" is modified by feeding original value to "f".
// if "index" is out of range, "xs" itself is returned.
var modifyArray = function modifyArray(index, f) {
if (typeof index !== 'number') console.error('index is not a number');
if (typeof f !== 'function') console.error('modifier is not a function');
return function (xs) {
if (index < 0 || index >= xs.length) return xs;
var ys = [].concat(_toConsumableArray(xs));
var v = ys[index];
var newV = f(v);
if (v !== newV) {
ys[index] = newV;
return ys;
} else {
return xs;
Object.keys(_objectZipper).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _objectZipper[key];
}
};
};
// modifyObject(propName,f)(xs)" is like "modifyArray" for Objects.
// Additionally, if you set `removeUndefined` to true,
// you'll get back an Object without that key if you have returned `undefined`
// in your modifier.
var modifyObject = function modifyObject(propName, f) {
var removeUndefined = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (typeof f !== 'function') console.error('modifier is not a function');
return function (obj) {
var val = obj[propName];
var newVal = f(val);
if (val === newVal) return obj;
if (typeof newVal === 'undefined' && removeUndefined) {
var newObj = _extends({}, obj);
delete newObj[propName];
return newObj;
} else {
return _extends({}, obj, _defineProperty({}, propName, newVal));
}
};
};
// create a singleton object
var singObj = function singObj(propName) {
return function (v) {
return _defineProperty({}, propName, v);
};
};
var scan = function scan(xs, acc, zero) {
var ys = new Array(xs.length + 1);
ys[0] = zero;
for (var i = 0; i < xs.length; ++i) {
ys[i + 1] = acc(ys[i], xs[i]);
}
return ys;
};
exports.enumFromTo = enumFromTo;
exports.ignore = ignore;
exports.not = not;
exports.modifyArray = modifyArray;
exports.modifyObject = modifyObject;
exports.singObj = singObj;
exports.scan = scan;
});
});
{
"name": "subtender",
"version": "0.1.1",
"version": "0.2.0",
"description": "Javran's utility functions",

@@ -5,0 +5,0 @@ "main": "index.js",

# subtender
[![npm version](https://badge.fury.io/js/subtender.svg)](https://badge.fury.io/js/subtender)
subtender is a collection of utilities that I found useful during develpment.
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