New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

util-array-object-or-both

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

util-array-object-or-both - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

.eslintrc

5

changelog.md

@@ -7,2 +7,6 @@ # Change Log

## [1.2.0] - 2017-09-20
### Changed
- Dropped JS Standard and switched to raw ESLint on `airbnb-base` preset. Of course, with overrides to ban semicolons and allow plus-plus in loops.
## [1.1.0] - 2017-08-09

@@ -17,2 +21,3 @@ ### Removed

[1.2.0]: https://github.com/codsen/util-array-object-or-both/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/codsen/util-array-object-or-both/compare/v1.0.0...v1.1.0

29

index.js

@@ -1,3 +0,1 @@

'use strict'
const includes = require('lodash.includes')

@@ -7,4 +5,4 @@ const checkTypes = require('check-types-mini')

function validate (str, opts) {
function existy (x) { return x != null }
function validate(str, originalOpts) {
function existy(x) { return x != null }
if (!existy(str)) {

@@ -16,4 +14,4 @@ throw new Error(`util-array-object-or-both/validate(): [THROW_ID_01] Please provide a string to work on. Currently it's equal to ${JSON.stringify(str, null, 4)}`)

}
if (existy(opts) && !isObj(opts)) {
throw new Error(`util-array-object-or-both/validate(): [THROW_ID_03] Second argument, options object, must be, well, object! Currenlty it's: ${typeof opts}, equal to: ${JSON.stringify(opts, null, 4)}`)
if (existy(originalOpts) && !isObj(originalOpts)) {
throw new Error(`util-array-object-or-both/validate(): [THROW_ID_03] Second argument, options object, must be, well, object! Currenlty it's: ${typeof originalOpts}, equal to: ${JSON.stringify(originalOpts, null, 4)}`)
}

@@ -25,7 +23,7 @@

var defaults = {
const defaults = {
msg: '',
optsVarName: 'given variable'
optsVarName: 'given variable',
}
opts = Object.assign({}, defaults, opts)
const opts = Object.assign({}, defaults, originalOpts)
checkTypes(

@@ -39,11 +37,11 @@ opts,

msg: ['string', null],
optsVarName: ['string', null]
}
}
optsVarName: ['string', null],
},
},
)
if (existy(opts.msg) && opts.msg.length > 0) {
opts.msg = opts.msg.trim() + ' '
opts.msg = `${opts.msg.trim()} `
}
if (opts.optsVarName !== 'given variable') {
opts.optsVarName = 'variable "' + opts.optsVarName + '"'
opts.optsVarName = `variable "${opts.optsVarName}"`
}

@@ -57,7 +55,6 @@

return 'any'
} else {
throw new TypeError(`${opts.msg}The ${opts.optsVarName} was customised to an unrecognised value: ${str}. Please check it against the API documentation.`)
}
throw new TypeError(`${opts.msg}The ${opts.optsVarName} was customised to an unrecognised value: ${str}. Please check it against the API documentation.`)
}
module.exports = validate
{
"name": "util-array-object-or-both",
"version": "1.1.2",
"version": "1.2.0",
"description": "Validate and normalise user choice: array, object or both?",
"main": "index.js",
"main": "index-es5.js",
"scripts": {
"build": "babel index.js --presets babel-preset-es2015 --out-file index-es5.js",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"precommit": "npm test",
"test": "clear && standard && nyc --reporter=html --reporter=text ava",
"prepare": "npm run build",
"test": "clear && ./node_modules/.bin/eslint index.js test.js && nyc --reporter=html --reporter=text ava && npm run build",
"watch": "nodemon --quiet --watch . --exec npm run test"

@@ -35,3 +37,3 @@ },

"dependencies": {
"check-types-mini": "^2.4.0",
"check-types-mini": "^2.6.0",
"lodash.includes": "*",

@@ -42,8 +44,12 @@ "lodash.isplainobject": "*"

"ava": "*",
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"clear-cli": "*",
"coveralls": "*",
"eslint": "^4.7.1",
"eslint-config-airbnb-base": "^12.0.0",
"eslint-plugin-import": "^2.7.0",
"husky": "*",
"nodemon": "^1.11.0",
"nyc": "*",
"standard": "^10.0.3"
"nodemon": "*",
"nyc": "*"
},

@@ -50,0 +56,0 @@ "ava": {

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