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

@serverless/utils

Package Overview
Dependencies
Maintainers
2
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serverless/utils - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

dist/common/index.js

42

dist/data/defn.js

@@ -19,10 +19,39 @@ 'use strict';

var _nAry = require('./nAry');
var _nArySpread = require('./nArySpread');
var _nAry2 = _interopRequireDefault(_nAry);
var _nArySpread2 = _interopRequireDefault(_nArySpread);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const defn = (name, defaultFn, arity = defaultFn.length) => {
let override = function override(...args) {
/**
* Defines a function that will invoke the named function if it exists on the
* last arg. If the method does not, all args are passed through to the default
* function.
*
* @func
* @since v0.1.0
* @category data
* @sig defn(
* name: string,
* defaultFn: (*) => any
* ): (...args: any[], last: any) => last[name] ? last[name](...args) : defaultFn(...args)
* @param {string} name The name of the method to call if it exists
* @param {Function} defaultFn The default function to execute if the named one does not exist on the last arg
* @returns {Function} The wrapped function
* @example
*
* const get = defn('get', (prop, value) => value[prop])
* get('a', { a: 'foo' }) //=> 'foo'
*
* const obj = {
* props: {
* a: 'bar'
* }
* get: (prop) => obj.props[prop]
* }
* get('a', obj) //=> 'bar'
*/
const defn = (name, defaultFn) => {
const arity = defaultFn.length;
const override = function override(...args) {
if (args.length === 0) {

@@ -37,6 +66,3 @@ return defaultFn.apply(this);

};
if (arity) {
override = (0, _nAry2.default)(arity, override);
}
return override;
return (0, _nArySpread2.default)(arity, override);
};

@@ -43,0 +69,0 @@

@@ -151,2 +151,11 @@ 'use strict';

var _curryN = require('./curryN');
Object.defineProperty(exports, 'curryN', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_curryN).default;
}
});
var _deferredPromise = require('./deferredPromise');

@@ -179,2 +188,11 @@

var _equals = require('./equals');
Object.defineProperty(exports, 'equals', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_equals).default;
}
});
var _find = require('./find');

@@ -648,2 +666,11 @@

var _nArySpread = require('./nArySpread');
Object.defineProperty(exports, 'nArySpread', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_nArySpread).default;
}
});
var _nodeTypes = require('./nodeTypes');

@@ -757,3 +784,30 @@

var _walk = require('./walk');
Object.defineProperty(exports, 'walk', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_walk).default;
}
});
var _walkReduce = require('./walkReduce');
Object.defineProperty(exports, 'walkReduce', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_walkReduce).default;
}
});
var _walkReduceDepthFirst = require('./walkReduceDepthFirst');
Object.defineProperty(exports, 'walkReduceDepthFirst', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_walkReduceDepthFirst).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

@@ -7,10 +7,38 @@ 'use strict';

var _ramda = require('ramda');
var _curry = require('./curry');
Object.defineProperty(exports, 'default', {
enumerable: true,
get: function get() {
return _ramda.is;
}
});
var _curry2 = _interopRequireDefault(_curry);
var _defn = require('./defn');
var _defn2 = _interopRequireDefault(_defn);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* See if an object (`val`) is an instance of the supplied constructor. This function will check up the inheritance chain, if any.
*
* @func
* @since v0.0.3
* @category data
* @sig (* -> {*}) -> a -> boolean
* @param {Object} constructor A constructor
* @param {*} value The value to test
* @return {boolean}
* @example
*
* is(Object, {}); //=> true
* is(Number, 1); //=> true
* is(Object, 1); //=> false
* is(String, 's'); //=> true
* is(String, new String('')); //=> true
* is(Object, new String('')); //=> true
* is(Object, 's'); //=> false
* is(Number, {}); //=> false
*/
const is = (0, _curry2.default)((0, _defn2.default)('is', (construtor, value) => {
return value != null && value.constructor === construtor || value instanceof construtor;
}));
exports.default = is;
//# sourceMappingURL=is.js.map

@@ -7,10 +7,44 @@ 'use strict';

var _ramda = require('ramda');
var _curry = require('./curry');
Object.defineProperty(exports, 'default', {
enumerable: true,
get: function get() {
return _ramda.nAry;
var _curry2 = _interopRequireDefault(_curry);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Wraps a function of any arity (including nullary) in a function that accepts exactly `n` parameters. Any extraneous parameters will not be passed to the supplied function.
*
* @func
* @since v0.0.3
* @category data
* @sig Number -> (* -> a) -> (* -> a)
* @param {Number} n The desired arity of the new function.
* @param {Function} fn The function to wrap.
* @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of arity `n`.
* @example
*
* const takesTwoArgs = (a, b) => [a, b]
*
* takesTwoArgs.length //=> 2
* takesTwoArgs(1, 2) //=> [1, 2]
*
* const takesOneArg = nAry(1, takesTwoArgs)
* takesOneArg.length //=> 1
* // Only `n` arguments are passed to the wrapped function
* takesOneArg(1, 2) //=> [1, undefined]
*/
const nAry = (0, _curry2.default)((n, fn) => {
let idx = 0;
const argNames = [];
while (idx < n) {
argNames.push(`a${idx}`);
idx += 1;
}
const func = new Function('fn', 'n', `return function(${argNames.join(', ')}) {
return fn.apply(this, Array.prototype.slice.call(arguments, 0, n));
}`);
return func(fn, n);
});
exports.default = nAry;
//# sourceMappingURL=nAry.js.map

3

dist/data/reduce.js

@@ -93,4 +93,3 @@ 'use strict';

* @sig ((a, b) -> a) -> a -> [b] -> a
* @param {Function} fn The iterator function. Receives two values, the accumulator and the
* current element from the array.
* @param {Function} fn The iterator function. Receives two values, the accumulator and the current element from the array.
* @param {*} acc The accumulator value.

@@ -97,0 +96,0 @@ * @param {Array} list The list to iterate over.

@@ -11,2 +11,4 @@ 'use strict';

var _ramda = require('ramda');
var _isJsonPath = require('./isJsonPath');

@@ -22,7 +24,7 @@

const parseFile = (filePath, contents) => {
const parseFile = (filePath, contents, options) => {
if ((0, _isJsonPath2.default)(filePath)) {
return JSON.parse(contents);
} else if ((0, _isYamlPath2.default)(filePath)) {
return _jsYaml2.default.load(contents.toString(), { filename: filePath });
return _jsYaml2.default.load(contents.toString(), (0, _ramda.merge)(options, { filename: filePath }));
} else if (filePath.endsWith('.slsignore')) {

@@ -29,0 +31,0 @@ return contents.toString().split('\n');

@@ -20,8 +20,8 @@ 'use strict';

const readFile = (() => {
var _ref = _asyncToGenerator(function* (filePath) {
var _ref = _asyncToGenerator(function* (filePath, options) {
const contents = yield _fsExtra2.default.readFile(filePath, 'utf8');
return (0, _parseFile2.default)(filePath, contents);
return (0, _parseFile2.default)(filePath, contents, options);
});
return function readFile(_x) {
return function readFile(_x, _x2) {
return _ref.apply(this, arguments);

@@ -28,0 +28,0 @@ };

@@ -20,5 +20,5 @@ 'use strict';

const readFileIfExists = (() => {
var _ref = _asyncToGenerator(function* (filePath) {
var _ref = _asyncToGenerator(function* (filePath, options) {
if (yield (0, _fileExists2.default)(filePath)) {
return (0, _readFile2.default)(filePath);
return (0, _readFile2.default)(filePath, options);
}

@@ -28,3 +28,3 @@ return false;

return function readFileIfExists(_x) {
return function readFileIfExists(_x, _x2) {
return _ref.apply(this, arguments);

@@ -31,0 +31,0 @@ };

@@ -31,3 +31,3 @@ 'use strict';

const formatContents = (filePath, contents) => {
const formatContents = (filePath, contents, options) => {
if ((0, _isJsonPath2.default)(filePath) && typeof contents !== 'string') {

@@ -37,3 +37,3 @@ return JSON.stringify(contents, null, 2);

if ((0, _isYamlPath2.default)(filePath) && typeof contents !== 'string') {
return _jsYaml2.default.dump(contents);
return _jsYaml2.default.dump(contents, options);
}

@@ -44,5 +44,5 @@ return contents;

const writeFile = (() => {
var _ref = _asyncToGenerator(function* (filePath, contents = '') {
var _ref = _asyncToGenerator(function* (filePath, contents = '', options = {}) {
yield _fsExtra2.default.mkdirs(_path2.default.dirname(filePath));
return _fsExtra2.default.writeFile(filePath, formatContents(filePath, contents));
return _fsExtra2.default.writeFile(filePath, formatContents(filePath, contents, options));
});

@@ -49,0 +49,0 @@

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

const common = require('./common');
const config = require('./config');

@@ -19,3 +20,3 @@ const data = require('./data');

module.exports = Object.assign({}, config, data, error, fs, lang, path);
module.exports = Object.assign({}, common, config, data, error, fs, lang, path);
//# sourceMappingURL=index.js.map
{
"name": "@serverless/utils",
"version": "0.0.3",
"version": "0.0.4",
"description": "General serverless utilities",

@@ -26,3 +26,6 @@ "author": "Serverless, Inc.",

"lint:staged": "./scripts/lint-staged.sh",
"setup": "./scripts/setup.sh",
"setup:ci": "./scripts/setup-ci.sh",
"test": "./scripts/test.sh",
"test:ci": "./scripts/test-ci.sh",
"watch": "./scripts/watch.sh"

@@ -29,0 +32,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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