Socket
Socket
Sign inDemoInstall

sum-up

Package Overview
Dependencies
7
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 2.0.0

21

index.js

@@ -11,6 +11,6 @@ /*!

module.exports = function sumUp(pkgData) {
module.exports = function sumUp(pkgData, options) {
if (!pkgData || Array.isArray(pkgData) || typeof pkgData !== 'object') {
throw new TypeError(
util.inspect(pkgData).replace(/\n/g, '') +
util.inspect(pkgData) +
' is not a plain object. Expected an object of package information,' +

@@ -21,5 +21,16 @@ ' for example npm\'s package.json `{name: ... version: ..., description: ..., ...}`.'

if (pkgData.color !== undefined && typeof pkgData.color !== 'boolean') {
if (options) {
if (Array.isArray(options) || typeof options !== 'object') {
throw new TypeError(
util.inspect(options) +
' is not a plain object. The second argument of sum-up must be a plain object or undefined.'
);
}
} else {
options = {};
}
if (options.color !== undefined && typeof options.color !== 'boolean') {
throw new TypeError(
util.inspect(pkgData.color).replace(/\n/g, '') +
util.inspect(options.color) +
' is neither true nor false. `color` option must be a Boolean value.'

@@ -29,3 +40,3 @@ );

var chalk = new Chalk({enabled: pkgData.color});
var chalk = new Chalk({enabled: options.color});
var lines = [];

@@ -32,0 +43,0 @@

{
"name": "sum-up",
"version": "1.0.3",
"version": "2.0.0",
"description": "Summarize package information",

@@ -9,3 +9,3 @@ "repository": "shinnn/sum-up",

"scripts": {
"pretest": "eslint --config @shinnn/node-legacy index.js test.js",
"pretest": "eslint --config @shinnn/node-legacy --rule 'complexity: [error, 15]' index.js test.js",
"test": "node --strong_mode test.js --color && node test.js --no-color",

@@ -12,0 +12,0 @@ "coverage": "node --strong_mode node_modules/.bin/istanbul cover test.js -- --color",

@@ -34,10 +34,11 @@ # sum-up

### sumUp(*options*)
### sumUp(*pkgData* [, *option*])
*options*: `Object`
*pkgData*: `Object`
*option*: `Object`
Return: `String`
It joins the `name`, `version`, `homepage` and `description` of the object (all is optional) into a string colorized with [ANSI escape code](https://github.com/sindresorhus/ansi-styles).
It joins the `name`, `version`, `homepage` and `description` properties (all is optional) of the first argument into a string colorized with [ANSI escape code](https://github.com/sindresorhus/ansi-styles).
#### options.color
#### option.color

@@ -50,3 +51,3 @@ Type: `Boolean`

```javascript
let data = {
const data = {
name: 'cli-name',

@@ -58,6 +59,3 @@ version: '0.6.11',

sumUp(data); //=> '\u001b[36mcli-name\u001b[39m \u001b[90mv0.6.11\u001b[39m\nMy CLI tool.'
data.color = false;
sumUp(data); //=> 'cli-name v0.6.11\nMy CLI tool.'
sumUp(data, {color: false}); //=> 'cli-name v0.6.11\nMy CLI tool.'
```

@@ -64,0 +62,0 @@

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