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

boxen

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boxen - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

45

index.js

@@ -9,2 +9,22 @@ 'use strict';

var getObject = function (detail) {
var obj;
if (typeof detail === 'number') {
obj = {
top: detail,
right: detail * 3,
bottom: detail,
left: detail * 3
};
} else {
obj = objectAssign({
top: 0,
right: 0,
bottom: 0,
left: 0
}, detail);
}
return obj;
};
module.exports = function (text, opts) {

@@ -19,20 +39,5 @@ opts = objectAssign({

var padding = opts.padding;
var padding = getObject(opts.padding);
var margin = getObject(opts.margin);
if (typeof padding === 'number') {
padding = {
top: padding,
right: padding * 3,
bottom: padding,
left: padding * 3
};
} else {
padding = objectAssign({
top: 0,
right: 0,
bottom: 0,
left: 0
}, padding);
}
var colorizeBorder = function (x) {

@@ -54,4 +59,4 @@ return opts.borderColor ? chalk[opts.borderColor](x) : x;

var horizontal = repeating('─', contentWidth);
var top = colorizeBorder('┌' + horizontal + '┐');
var bottom = colorizeBorder('└' + horizontal + '┘');
var top = colorizeBorder(repeating('\n', margin.top) + repeating(' ', margin.left) + '┌' + horizontal + '┐');
var bottom = colorizeBorder(repeating(' ', margin.left) + '└' + horizontal + '┘' + repeating('\n', margin.bottom));
var side = colorizeBorder('│');

@@ -63,3 +68,3 @@

return side + paddingLeft + line + paddingRight + side;
return repeating(' ', margin.left) + side + paddingLeft + line + paddingRight + side;
}).join('\n');

@@ -66,0 +71,0 @@

{
"name": "boxen",
"version": "0.1.0",
"version": "0.2.0",
"description": "Create boxes in the terminal",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -28,2 +28,13 @@ # ![boxen](screenshot.png)

*/
console.log(boxen('unicorn', {padding: 1, margin: 1}));
/*
┌─────────────┐
│ │
│ unicorn │
│ │
└─────────────┘
*/
```

@@ -60,5 +71,14 @@

##### margin
Type: `number`, `object`
Default: `0`
Space around the box.
Accepts a number or an object with any of the `top`, `right`, `bottom`, `left` properties. When a number is specified, the left/right margin is 3 times the top/bottom to make it look nice.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
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