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

smartwrap

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartwrap - npm Package Compare versions

Comparing version 1.0.12 to 1.1.0

2

package.json
{
"name": "smartwrap",
"version": "1.0.12",
"version": "1.1.0",
"description": "Textwrap for javascript/nodejs. Correctly handles wide characters (宽字符) and emojis (😃). Automatically breaks long words.",

@@ -5,0 +5,0 @@ "main": "src/main.js",

'use strict';
function smartWrap(text,options){
let Wcwidth = require('wcwidth');
let Breakword = require('breakword');
function smartWrap(input, options) {
//in case a template literal was passed that has newling characters,
//split string by newlines and process each resulting string
const str = input.toString()
const strArr = str.split("\n").map( string => {
return wrap(string, options)
})
return strArr.join("\n")
}
function wrap(text,options){
options = options || {};
let Wcwidth = require('wcwidth');
let Breakword = require('breakword');
let defaults = {};
defaults.calculateSpaceRemaining = function(obj,i){//i is in case someone wants to customize based on line index
defaults.calculateSpaceRemaining = function(obj,i){
//i is in case someone wants to customize based on line index
return Math.max(obj.lineLength - obj.spacesUsed - obj.paddingLeft - obj.paddingRight,0);

@@ -12,0 +25,0 @@ }; //function to set starting line length

@@ -10,4 +10,4 @@ 'use strict';

let should = chai.should();
let smartwrap = require('../src/main.js');
let filepath = 'test/tests.json';
let smartwrap = require(__dirname+'/../src/main.js');
let filepath = __dirname+'/tests.json';
let test = function(testResult,savedResult){

@@ -14,0 +14,0 @@ it('Strings should match',function(){

@@ -96,3 +96,8 @@ [

"output": "And its\ncorresponding\nlonger value"
},
{
"input": "The use of the secure-rm CLI is deprecated.\nMigrate over -> secure-rm-cli. Run:\nnpm un secure-rm -g\nnpm i secure-rm-cli -g",
"width": 50,
"output": "The use of the secure-rm CLI is deprecated.\nMigrate over -> secure-rm-cli. Run:\nnpm un secure-rm -g\nnpm i secure-rm-cli -g"
}
]
]
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