Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

wrap-words

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wrap-words - npm Package Compare versions

Comparing version
0.0.4
to
0.0.5
+2
-0
dist/index.js

@@ -113,2 +113,4 @@ 'use strict';

target *= opts.widthMultiplier || 2;
DEBUG && console.log({ str: str, target: target, charCount: charCount, longestWordLength: longestWordLength }, words);

@@ -115,0 +117,0 @@

+3
-1

@@ -110,3 +110,3 @@ <!DOCTYPE html>

const target = Math.max(
let target = Math.max(
opts.longWordForcesRect ? longestWordLength : 0,

@@ -116,2 +116,4 @@ Math.ceil(Math.sqrt(charCount)) // chances are an extra line will be needed, so round up to columns

target *= opts.widthMultiplier || 2;
DEBUG &amp;&amp; console.log({str, target, charCount, longestWordLength}, words);

@@ -118,0 +120,0 @@

@@ -9,5 +9,38 @@ <!DOCTYPE html>

document.addEventListener('DOMContentLoaded', function() {
//
var input = document.getElementById('input');
input.addEventListener('input', changed);
var width = document.getElementById('width');
width.addEventListener('input', changed);
changed();
function changed() {
var wrapped = WrapWords.wrap(input.value, {width: width.value});
var squared = WrapWords.square(input.value);
document.getElementById('wrapped').textContent = wrapped;
document.getElementById('square').textContent = squared;
stats(wrapped, 'wrap-stats');
stats(squared, 'square-stats');
}
function stats(txt, id) {
var lines = txt.split('\n');
var h = lines.length;
var w = lines.reduce((max, line) => Math.max(max, line.length), 0);
document.getElementById(id).textContent = w + ' × ' + h;
}
});
</script>
<style>
textarea {
display: block;
width: 100%;
max-width: 50em;
height: 10em;
}
</style>
</head>

@@ -18,4 +51,18 @@ <body>

<!---->
Width: <input id="width" type="number" value="80">
<textarea id="input">
It is of great use to the sailor to know the length of his line, though he cannot with it fathom all the depths of the ocean. It is well he knows that it is long enough to reach the bottom at such places as are necessary to direct his voyage, and caution him against running upon shoals that may ruin him. Our business here is not to know all things, but those which concern our conduct. If we can find out those measures whereby a rational creature, put in that state in which man is in this world, may; and ought to govern his opinions, and actions depending thereon, we need not to be troubled that some other things escape our knowledge. ~ John Locke
</textarea>
<h2>Wrapped:</h2>
<pre id="wrapped"></pre>
<span id="wrap-stats"></span>
<h2>Square:</h2>
<pre id="square"></pre>
<span id="square-stats"></span>
<br>
<br>
<div>

@@ -22,0 +69,0 @@ <a href="./api/">API Docs</a>

{
"name": "wrap-words",
"version": "0.0.4",
"version": "0.0.5",
"description": "Word wrap.",

@@ -5,0 +5,0 @@ "main": "dist/",

Sorry, the diff of this file is too big to display