You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

break-styled-lines

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 to 1.3.0

dist/break-styled-lines.cjs

54

package.json
{
"version": "1.2.2",
"name": "break-styled-lines",
"version": "1.3.0",
"description": "Add newlines to a string of text given a font style and width",

@@ -7,4 +8,15 @@ "author": "Sam Gwilym <gwilym@me.com>",

"repository": "https://github.com/sgwilym/break-styled-lines",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "./dist/break-styled-lines.cjs",
"module": "./dist/break-styled-lines.js",
"types": "./dist/break-styled-lines.d.ts",
"exports": {
".": {
"types": "./dist/break-styled-lines.d.ts",
"node": {
"require": "./dist/break-styled-lines.cjs",
"import": "./dist/break-styled-lines.mjs"
},
"default": "./dist/break-styled-lines.js"
}
},
"files": [

@@ -18,18 +30,7 @@ "dist",

"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint",
"prepare": "tsdx build",
"size": "size-limit",
"analyze": "size-limit --why"
"prepare": "yarn build-types && yarn build",
"build-types": "dts-bundle-generator -o ./dist/break-styled-lines.d.ts src/index.ts",
"build": "node ./scripts/build.mjs && yarn build-types",
"test": "jest"
},
"peerDependencies": {},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
},
"name": "break-styled-lines",
"module": "dist/break-styled-lines.esm.js",
"size-limit": [

@@ -48,9 +49,14 @@ {

"canvas": "^2.6.1",
"husky": "^5.0.9",
"size-limit": "^4.9.2",
"ts-jest": "^26.5.1",
"tsdx": "^0.14.1",
"tslib": "^2.1.0",
"dts-bundle-generator": "^5.9.0",
"esbuild": "^0.12.1",
"jest": "^27.0.4",
"ts-jest": "^27.0.3",
"typescript": "^4.1.5"
}
},
"keywords": [
"line",
"break",
"styled",
"canvas"
]
}
type TextDescriptor = { text: string; font?: string };
function checkFontForBlinkMacSystemFont(font: string): void {
if (font.includes("BlinkMacSystemFont")) {
console.warn(
"break-styled-lines: Using BlinkMacSystemFont can cause Chrome to crash in certain environments!"
);
}
}
function isStringArray(

@@ -58,3 +66,3 @@ text: string | string[] | TextDescriptor[]

lastLineWidth: completeTextWidth,
lines: [...result.lines.slice(0, -1), appendedLine]
lines: [...result.lines.slice(0, -1), appendedLine],
};

@@ -70,3 +78,3 @@ }

lastLineWidth: elementWidth,
lines: [...result.lines.slice(0, -1), element]
lines: [...result.lines.slice(0, -1), element],
};

@@ -80,3 +88,3 @@ }

...result.lines.slice(0, -1),
previousLine.trimEnd()
previousLine.trimEnd(),
];

@@ -89,3 +97,3 @@

lastLineWidth: 0,
lines: [...precedingLines, ""]
lines: [...precedingLines, ""],
};

@@ -97,3 +105,3 @@ }

lastLineWidth: elementWidth,
lines: [...precedingLines, element]
lines: [...precedingLines, element],
};

@@ -136,3 +144,3 @@ },

lastLineWidth,
lines: [...result.lines, text]
lines: [...result.lines, text],
};

@@ -155,3 +163,3 @@ },

text: stripNewlines(text),
font: font || defaultFont
font: font || defaultFont,
}));

@@ -161,5 +169,5 @@ }

if (isStringArray(text)) {
return text.map(member => ({
return text.map((member) => ({
text: stripNewlines(member),
font: defaultFont
font: defaultFont,
}));

@@ -197,2 +205,4 @@ }

): string | string[] {
checkFontForBlinkMacSystemFont(font);
const descriptors = toTextDescriptors(text, font);

@@ -199,0 +209,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc