Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slack-message-parser

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slack-message-parser - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0

docs/api.md

82

package.json
{
"module": "./esm/mod.js",
"main": "./script/mod.js",
"types": "./types/mod.d.ts",
"name": "slack-message-parser",
"version": "2.0.2",
"version": "3.0.0",
"description": "Parser for Slack message",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc",
"test": "jest",
"lint": "tslint -c tslint.json 'src/**/*.ts'",
"prepublishOnly": "npm run build",
"docs": "vuepress dev docs",
"docs:build": "vuepress build docs"
},
"files": [
"lib",
"docs/**/*.md"
],
"repository": {

@@ -32,52 +21,23 @@ "type": "git",

"homepage": "https://github.com/pocka/slack-message-parser#readme",
"devDependencies": {
"@types/jest": "^23.3.2",
"husky": "^1.0.0-rc.14",
"jest": "^23.6.0",
"lint-staged": "^7.2.2",
"prettier": "^1.14.2",
"ts-jest": "^23.1.4",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"typescript": "^4.2.4",
"vuepress": "^1.2.0",
"yarn": "^1.9.4"
},
"sideEffects": false,
"husky": {
"hooks": {
"pre-commit": "lint-staged"
"exports": {
".": {
"import": {
"default": "./esm/mod.js",
"types": "./types/mod.d.ts"
},
"require": {
"default": "./script/mod.js",
"types": "./types/mod.d.ts"
}
}
},
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
"src/**/*.ts",
"!node_modules/**"
],
"coverageReporters": [
"lcov",
"text"
],
"transform": {
"^.+\\.ts?$": "ts-jest"
},
"testRegex": "/tests/.*\\.spec\\.ts$",
"moduleFileExtensions": [
"ts",
"js",
"json",
"node"
]
"scripts": {
"test": "node test_runner.js"
},
"lint-staged": {
"*.{ts,md}": [
"prettier --write",
"git add"
]
},
"prettier": {
"semi": false,
"singleQuote": true
"devDependencies": {
"@types/node": "16.11.37",
"chalk": "4.1.2",
"@deno/shim-deno": "~0.10.0"
}
}
}
# slack-message-parser
[![npm](https://img.shields.io/github/package-json/v/pocka/slack-message-parser)](https://www.npmjs.com/package/slack-message-parser)
[![npm](https://img.shields.io/npm/v/slack-message-parser)](https://www.npmjs.com/package/slack-message-parser)
[![Lint Workflow Status](https://img.shields.io/github/workflow/status/pocka/slack-message-parser/Lint%20files?label=lint)](https://github.com/pocka/slack-message-parser/actions/workflows/lint.yml)

@@ -15,2 +15,4 @@ [![Test Workflow Status](https://img.shields.io/github/workflow/status/pocka/slack-message-parser/Test%20and%20collect%20coverage?label=test)](https://github.com/pocka/slack-message-parser/actions/workflows/test.yml)

Requires Node.js >=v16.
```sh

@@ -26,5 +28,5 @@ npm i --save slack-message-parser

```ts
import slackMessageParser, { Node, NodeType } from 'slack-message-parser'
import slackMessageParser, { Node, NodeType } from "slack-message-parser";
const tree = slackMessageParser('Slack *message* ~to~ _parse_')
const tree = slackMessageParser("Slack *message* ~to~ _parse_");

@@ -59,18 +61,18 @@ // tree is:

case NodeType.Root:
return `<p>${node.children.map(toHTML).join('')}</p>`
return `<p>${node.children.map(toHTML).join("")}</p>`;
case NodeType.Text:
return node.text
return node.text;
case NodeType.Bold:
return `<strong>${node.children.map(toHTML).join('')}</strong>`
return `<strong>${node.children.map(toHTML).join("")}</strong>`;
case NodeType.Italic:
return `<i>${node.children.map(toHTML).join('')}</i>`
return `<i>${node.children.map(toHTML).join("")}</i>`;
case NodeType.Strike:
return `<del>${node.children.map(toHTML).join('')}</del>`
return `<del>${node.children.map(toHTML).join("")}</del>`;
default:
// You can use `source` property, which every nodes have, to serialize unknown nodes as-is
return node.source
return node.source;
}
}
};
console.log(toHTML(tree))
console.log(toHTML(tree));

@@ -77,0 +79,0 @@ // Output:

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