New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nlcst-affix-emoticon-modifier

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nlcst-affix-emoticon-modifier - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

complex-types.d.ts

5

index.d.ts
export const affixEmoticonModifier: import('unist-util-modify-children').Modify
export type Node = import('unist').Node
export type Parent = import('unist').Parent
export type Paragraph = import('nlcst').Paragraph
export type ParagraphContent = import('nlcst').ParagraphContent
export type Emoticon = import('./complex-types').Emoticon

51

index.js
/**
* @typedef {import('unist').Node} Node
* @typedef {import('unist').Parent} Parent
* @typedef {import('nlcst').Paragraph} Paragraph
* @typedef {import('nlcst').ParagraphContent} ParagraphContent
*
* @typedef {import('./complex-types').Emoticon} Emoticon
*/

@@ -8,3 +10,6 @@

export const affixEmoticonModifier = modifyChildren(mergeAffixEmoticon)
export const affixEmoticonModifier =
/** @type {(node: Paragraph) => void} */
// @ts-expect-error: To do: make types in `unist-util-modify-children` smart.
modifyChildren(mergeAffixEmoticon)

@@ -14,29 +19,23 @@ /**

*
* @param {Node} child
* @param {ParagraphContent} node
* @param {number} index
* @param {Parent} parent
* @param {Paragraph} ancestor
*/
function mergeAffixEmoticon(child, index, parent) {
var siblings = parent.children
/** @type {Array.<Node>} */
// @ts-ignore looks like a parent.
var children = child.children
var childIndex = -1
function mergeAffixEmoticon(node, index, ancestor) {
const previous = ancestor.children[index - 1]
if (children && children.length > 0 && index) {
if (index && 'children' in previous && 'children' in node) {
const children = node.children
let childIndex = -1
while (++childIndex < children.length) {
if (children[childIndex].type === 'EmoticonNode') {
siblings[index - 1].children = [].concat(
siblings[index - 1].children,
children.slice(0, childIndex + 1)
)
child.children = children.slice(childIndex + 1)
const child = children[childIndex]
if (
children[childIndex].position &&
child.position &&
siblings[index - 1].position
) {
siblings[index - 1].position.end = children[childIndex].position.end
child.position.start = children[childIndex].position.end
if (child.type === 'EmoticonNode') {
previous.children.push(...children.slice(0, childIndex + 1))
node.children = children.slice(childIndex + 1)
if (child.position && node.position && previous.position) {
previous.position.end = child.position.end
node.position.start = child.position.end
}

@@ -48,3 +47,3 @@

if (children[childIndex].type !== 'WhiteSpaceNode') {
if (child.type !== 'WhiteSpaceNode') {
break

@@ -51,0 +50,0 @@ }

{
"name": "nlcst-affix-emoticon-modifier",
"version": "2.0.0",
"version": "2.1.0",
"description": "nlcst utility to merge affix emoticons into the previous sentence",

@@ -30,2 +30,3 @@ "license": "MIT",

"files": [
"complex-types.d.ts",
"index.d.ts",

@@ -35,2 +36,3 @@ "index.js"

"dependencies": {
"@types/nlcst": "^1.0.0",
"@types/unist": "^2.0.0",

@@ -46,5 +48,5 @@ "unist-util-modify-children": "^3.0.0"

"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"retext-english": "^3.0.0",
"remark-cli": "^10.0.0",
"remark-preset-wooorm": "^9.0.0",
"retext-english": "^4.0.0",
"rimraf": "^3.0.0",

@@ -55,9 +57,9 @@ "tape": "^5.0.0",

"typescript": "^4.0.0",
"unified": "^9.0.0",
"unified": "^10.0.0",
"unist-util-remove-position": "^4.0.0",
"xo": "^0.39.0"
"xo": "^0.44.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
"build": "rimraf \"{test/**,}*.d.ts\" && tsc && type-coverage",
"build": "rimraf \"test/**/*.d.ts\" \"index.d.ts\" && tsc && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",

@@ -77,8 +79,3 @@ "test-api": "node test/index.js",

"xo": {
"prettier": true,
"rules": {
"capitalized-comments": "off",
"no-var": "off",
"prefer-arrow-callback": "off"
}
"prettier": true
},

@@ -85,0 +82,0 @@ "remarkConfig": {

@@ -36,3 +36,3 @@ # nlcst-affix-emoticon-modifier

var english = new ParseEnglish()
const english = new ParseEnglish()

@@ -39,0 +39,0 @@ english.useFirst('tokenizeSentence', emoticonModifier)

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