Comparing version 1.0.12 to 1.1.0
{ | ||
"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" | ||
} | ||
] | ||
] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41277
404
2