Comparing version 1.0.1 to 1.1.0
10
index.js
@@ -10,2 +10,6 @@ const Escaped = { '<': '<', '>': '>', '&': '&' }; | ||
function isFormattedLike(object) { | ||
return object && 'text' in other && 'entities' in other && Array.isArray(entities); | ||
} | ||
class FormattedString { | ||
@@ -32,4 +36,4 @@ constructor(...vals) { | ||
} else | ||
if (other instanceof FormattedString) { | ||
// Merge entities | ||
if (isFormattedLike(other)) { | ||
// FormattedString or something similar; merge entities | ||
const len = this.text.length; | ||
@@ -117,3 +121,3 @@ this.text += other.text; | ||
builder.append(expr[j++]); | ||
} while (expr[j] instanceof FormattedString || Array.isArray(expr[j])); | ||
} while (isFormattedLike(expr[j]) || Array.isArray(expr[j])); | ||
const length = builder.text.length - offset; | ||
@@ -120,0 +124,0 @@ for (; length && j < expr.length; j++, k++) { |
{ | ||
"name": "tg-format", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A tiny Node.JS helper for sending formatted text messages using Telegram Bot API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -81,9 +81,9 @@ # tg-format | ||
```js | ||
const formatted = fmt`Участники:\n${ | ||
users.map(user => fmt`\n${[ | ||
const formatted = fmt`Участники:\n\n${ | ||
FormattedString.join(users.map(user => fmt`${[ | ||
fmt`${[user.firstName, 'bold']} ${user.lastName}`, | ||
{ type: 'text_link', url: user.website } | ||
]}`) | ||
]}`), '\n') | ||
}`; | ||
``` | ||
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
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
14927
140