🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
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

to
1.1.0

.vscode/settings.json

@@ -10,2 +10,8 @@ # Changelog

## [1.1.0] - 2021-05-25
### Added
- Add `source` property to all node types (Issue: [#29](https://github.com/pocka/slack-message-parser/issues/29)).
## [1.0.7] - 2020-12-10

@@ -12,0 +18,0 @@

7

docs/api/README.md

@@ -27,5 +27,6 @@ # API

| Name | Type | Description |
| ---- | ---------------- | ---------------- |
| type | Number(NodeType) | Type of the node |
| Name | Type | Description |
| ------ | ---------------- | ---------------------- |
| type | Number(NodeType) | Type of the node |
| source | String | Raw string of the node |

@@ -32,0 +33,0 @@ You can test the type with `NodeType` object (which is actually TypeScript enum).

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.topOfLine = exports.explicit = exports.regexp = exports.or = void 0;
exports.or = (parsers) => {
const or = (parsers) => {
const { length } = parsers;

@@ -16,3 +16,4 @@ return (text, position, rootParser) => {

};
exports.regexp = (pattern, callback) => (text, position, parseText) => {
exports.or = or;
const regexp = (pattern, callback) => (text, position, parseText) => {
const match = text.substring(position).match(pattern);

@@ -24,3 +25,4 @@ if (!match) {

};
exports.explicit = (parser) => (text, position, parseText) => {
exports.regexp = regexp;
const explicit = (parser) => (text, position, parseText) => {
const prevChar = text.charAt(position - 1);

@@ -32,3 +34,4 @@ if (prevChar && !prevChar.match(/[\s.,([{!?\-=]/)) {

};
exports.topOfLine = (parser) => (text, position, parseText) => {
exports.explicit = explicit;
const topOfLine = (parser) => (text, position, parseText) => {
if (position > 0 && text.charAt(position - 1) !== '\n') {

@@ -39,2 +42,3 @@ return null;

};
exports.topOfLine = topOfLine;
//# sourceMappingURL=combinator.js.map

@@ -10,3 +10,3 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -26,3 +26,4 @@ Object.defineProperty(exports, "__esModule", { value: true });

type: Node_1.NodeType.Text,
text: textBuffer
text: textBuffer,
source: textBuffer
});

@@ -48,10 +49,12 @@ textBuffer = '';

};
exports.parse = (message) => {
const parse = (message) => {
return {
type: Node_1.NodeType.Root,
children: parseText(message)
children: parseText(message),
source: message
};
};
exports.parse = parse;
exports.default = exports.parse;
__exportStar(require("./types/Node"), exports);
//# sourceMappingURL=index.js.map

@@ -10,3 +10,4 @@ "use strict";

type: Node_1.NodeType.Bold,
children: parseText(content)
children: parseText(content),
source: matchedText
},

@@ -21,3 +22,4 @@ position + matchedText.length

type: Node_1.NodeType.Code,
text: content
text: content,
source: matchedText
},

@@ -32,3 +34,4 @@ position + matchedText.length

type: Node_1.NodeType.PreText,
text: content
text: content,
source: matchedText
},

@@ -43,3 +46,4 @@ position + matchedText.length

type: Node_1.NodeType.Italic,
children: parseText(content)
children: parseText(content),
source: matchedText
},

@@ -54,3 +58,4 @@ position + matchedText.length

type: Node_1.NodeType.Strike,
children: parseText(content)
children: parseText(content),
source: matchedText
},

@@ -70,7 +75,9 @@ position + matchedText.length

type: Node_1.NodeType.Text,
text: repeatedGt[1]
text: repeatedGt[1],
source: repeatedGt[1]
},
...parseText(repeatedGt[3])
]
: parseText(content)
: parseText(content),
source: matchedText
},

@@ -85,3 +92,4 @@ position + matchedText.length

type: Node_1.NodeType.Quote,
children: parseText(content)
children: parseText(content),
source: matchedText
},

@@ -97,3 +105,4 @@ position + matchedText.length

name,
variation
variation,
source: matchedText
},

@@ -113,3 +122,4 @@ position + matchedText.length

userID: link.slice(1),
label: labelNodes
label: labelNodes,
source: matchedText
},

@@ -123,3 +133,4 @@ nextPosition

channelID: link.slice(1),
label: labelNodes
label: labelNodes,
source: matchedText
},

@@ -135,3 +146,4 @@ nextPosition

arguments: args,
label: labelNodes
label: labelNodes,
source: matchedText
},

@@ -145,3 +157,4 @@ nextPosition

url: link,
label: labelNodes
label: labelNodes,
source: matchedText
},

@@ -148,0 +161,0 @@ nextPosition

@@ -19,2 +19,3 @@ export declare enum NodeType {

type: NodeType;
source: string;
}

@@ -21,0 +22,0 @@ export interface Text extends NodeBase {

{
"name": "slack-message-parser",
"version": "1.0.7",
"version": "1.1.0",
"description": "Parser for Slack message",

@@ -37,3 +37,3 @@ "main": "lib/index.js",

"tslint-config-prettier": "^1.15.0",
"typescript": "^3.0.3",
"typescript": "^4.2.4",
"vuepress": "^1.2.0",

@@ -40,0 +40,0 @@ "yarn": "^1.9.4"

@@ -35,3 +35,4 @@ # slack-message-parser

// type: NodeType.Text,
// text: "Slack "
// text: "Slack ",
// . source: "Slack "
// },

@@ -45,6 +46,8 @@ // {

// }
// ]
// ],
// . source: "*message*"
// },
// ...
// ]
// ],
// source: "Slack *message* ~to~ _parse_"
// }

@@ -66,3 +69,4 @@

default:
return ''
// You can use `source` property, which every nodes have, to serialize unknown nodes as-is
return node.source
}

@@ -69,0 +73,0 @@ }

@@ -17,3 +17,4 @@ import { Node, NodeType } from './types/Node'

type: NodeType.Text,
text: textBuffer
text: textBuffer,
source: textBuffer
})

@@ -51,3 +52,4 @@

type: NodeType.Root,
children: parseText(message)
children: parseText(message),
source: message
}

@@ -54,0 +56,0 @@ }

@@ -14,3 +14,4 @@ import { NodeType } from './types/Node'

type: NodeType.Bold,
children: parseText(content)
children: parseText(content),
source: matchedText
},

@@ -30,3 +31,4 @@ position + matchedText.length

type: NodeType.Code,
text: content
text: content,
source: matchedText
},

@@ -47,3 +49,4 @@ position + matchedText.length

type: NodeType.PreText,
text: content
text: content,
source: matchedText
},

@@ -65,3 +68,4 @@ position + matchedText.length

type: NodeType.Italic,
children: parseText(content)
children: parseText(content),
source: matchedText
},

@@ -83,3 +87,4 @@ position + matchedText.length

type: NodeType.Strike,
children: parseText(content)
children: parseText(content),
source: matchedText
},

@@ -105,7 +110,9 @@ position + matchedText.length

type: NodeType.Text,
text: repeatedGt[1]
text: repeatedGt[1],
source: repeatedGt[1]
},
...parseText(repeatedGt[3])
]
: parseText(content)
: parseText(content),
source: matchedText
},

@@ -124,3 +131,4 @@ position + matchedText.length

type: NodeType.Quote,
children: parseText(content)
children: parseText(content),
source: matchedText
},

@@ -141,3 +149,4 @@ position + matchedText.length

name,
variation
variation,
source: matchedText
},

@@ -162,3 +171,4 @@ position + matchedText.length

userID: link.slice(1),
label: labelNodes
label: labelNodes,
source: matchedText
},

@@ -172,3 +182,4 @@ nextPosition

channelID: link.slice(1),
label: labelNodes
label: labelNodes,
source: matchedText
},

@@ -185,3 +196,4 @@ nextPosition

arguments: args,
label: labelNodes
label: labelNodes,
source: matchedText
},

@@ -195,3 +207,4 @@ nextPosition

url: link,
label: labelNodes
label: labelNodes,
source: matchedText
},

@@ -198,0 +211,0 @@ nextPosition

@@ -34,2 +34,7 @@ export enum NodeType {

type: NodeType
/**
* Raw node text.
*/
source: string
}

@@ -36,0 +41,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet