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

prague

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prague - npm Package Compare versions

Comparing version 0.24.0 to 0.24.1

2

docs/1.testable_bots.md

@@ -118,3 +118,3 @@ # Creating Testable Bots by Separating Concerns

Our test code can separately test the result of `bot`, and the action that it should take. And our running code would simply execute both steps.
Our test code can separately test the first function, and the action that it should take. And our running code would simply execute both steps.

@@ -121,0 +121,0 @@ Let's create a class representing "an action to take":

@@ -340,3 +340,3 @@ # Combining Functions with *Prague*

const bot = (req, res) => pipe(
botLogic(req),
() => botLogic(req),
actions.doAction(res)

@@ -350,5 +350,5 @@ ).subscribe()

const bot = (req, res) => actions.run(
botLogic(req),
botLogic,
res
).subscribe()
)(req).subscribe()
```

@@ -384,10 +384,7 @@

If we get a little more verbose in the first place, we can isolate the implementation of the pattern matching:
This is easy for `re` which has an optional second "which capture group" parameter:
```ts
match(
pipe(
re(/is my (.*) cured/i),
matches => matches[1]
),
re(/is my (.*) cured/i, 1),
condition => actions.reference.healthStatus(condition)

@@ -409,9 +406,5 @@ },

With this in mind, let's use `pipe` to whip up a couple of helpers to make our code more future-proof:
With this in mind, let's use `pipe` to whip up a helper to make our code more future-proof:
```ts
const reGroup = (regexp, group) => pipe(
re(regexp),
matches => matches[group]
);

@@ -425,3 +418,3 @@ const nlp = (service, intentName, entityName) => text => pipe(

match(
reGroup(/delete (.*)/i, 1),
re(/delete (.*)/i, 1),
matches => actions.reference.delete(matches[1]),

@@ -435,3 +428,3 @@ () => actions.reference.delete_fail(r[1])

match(
reGroup(/is my (.*) cured/i, 1), // or replace with nlp(healthService, 'status', 'condition')
re(/is my (.*) cured/i, 1), // or replace with nlp(healthService, 'status', 'condition')
condition => actions.reference.healthStatus(condition)

@@ -438,0 +431,0 @@ },

@@ -62,3 +62,3 @@ # Scoring

match(
reGroup(/My name is (.*)/i, 1),
re(/My name is (.*)/i, 1),
name => Scored.from(name),

@@ -65,0 +65,0 @@ ),

@@ -1,2 +0,4 @@

export declare const re: (regexp: RegExp) => (text: string) => RegExpExecArray | null;
import { Transform } from "./prague";
export declare function re(regexp: RegExp): Transform<[string], RegExpExecArray | null>;
export declare function re(regexp: RegExp, group: number): Transform<[string], string | null>;
export declare const getFetchJson: (error: string | ((body: string) => string)) => (r: Response) => Promise<any>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.re = (regexp) => (text) => regexp.exec(text);
const prague_1 = require("./prague");
function re(regexp, group) {
return prague_1.match((text) => regexp.exec(text), groups => group ? groups[group] : groups);
}
exports.re = re;
exports.getFetchJson = (error) => (r) => {

@@ -5,0 +9,0 @@ if (!r.ok) {

{
"name": "prague",
"version": "0.24.0",
"version": "0.24.1",
"description": "EDSL for rules",

@@ -5,0 +5,0 @@ "main": "lib/src/prague.js",

@@ -21,3 +21,3 @@ # *Prague*

The *Prague* tutorial starts [here](./1.tutorial.md).
The *Prague* tutorial starts [here](./docs/1.testable_bots.md).

@@ -24,0 +24,0 @@ ## Samples

Sorry, the diff of this file is not supported yet

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