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

@yoctol/kurator

Package Overview
Dependencies
Maintainers
6
Versions
703
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yoctol/kurator - npm Package Compare versions

Comparing version 0.4.15 to 0.4.16

2

package.json
{
"name": "@yoctol/kurator",
"license": "UNLICENSED",
"version": "0.4.15",
"version": "0.4.16",
"main": "src/index.js",

@@ -6,0 +6,0 @@ "files": [

const nock = require('nock');
const B = require('bottender-compose');

@@ -96,2 +97,31 @@ const Kurator = require('../Kurator');

describe('#registerAction', () => {
it('should support local action', async () => {
const { kurator } = await setup();
const context = {
sendText: jest.fn(),
};
kurator.registerAction('不要騙我', B.sendText('不要騙我'));
const action = kurator.getAction('不要騙我');
await action(context);
expect(context.sendText).toBeCalledWith('不要騙我');
});
it('should have displayName', async () => {
const { kurator } = await setup();
kurator.registerAction('不要騙我', B.sendText('不要騙我'));
expect(kurator.getAction('不要騙我')).toHaveProperty(
'displayName',
'不要騙我'
);
});
});
describe('#createBottenderMiddleware', () => {

@@ -98,0 +128,0 @@ it('should support id link', async () => {

@@ -79,13 +79,42 @@ const B = require('bottender-compose');

registerAction(name, fn) {
// eslint-disable-next-line no-param-reassign
fn.displayName = name;
this._localActions[name] = fn;
registerAction(actionId, fn) {
if (!fn.displayName) {
fn.displayName = actionId; // eslint-disable-line no-param-reassign
}
this._localActions[actionId] = fn;
}
getAction(actionId) {
// TODO: fallback or warning
getRemoteAction(actionId) {
return this._remoteActions[actionId];
}
getLocalAction(actionId) {
return this._localActions[actionId];
}
getActionFromAnyWhere(actionId) {
return (
this.getRemoteAction(actionId) ||
this.getLocalAction(actionId) ||
B.warn(`Action ID: ${actionId} is not yet implemented`)
);
}
getAction(actionId) {
const wrappedAction = (context, ...otherArgs) => {
const action = this.getActionFromAnyWhere(actionId);
wrappedAction.displayName = action.displayName;
return action(context, ...otherArgs);
};
const action = this.getActionFromAnyWhere(actionId);
if (action) {
wrappedAction.displayName = action.displayName;
}
return wrappedAction;
}
createBottenderMiddleware() {

@@ -92,0 +121,0 @@ return async (context, next) => {

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