Socket
Socket
Sign inDemoInstall

feynman

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feynman - npm Package Compare versions

Comparing version 0.0.21 to 0.0.22

21

lib/feynman/core.js

@@ -108,9 +108,23 @@ 'use strict'

}
const Task = (id, params = {}) =>
const NoLog = () => {}
const Task = (id, params = {}, description = Description()) =>
Object.assign(
({ actor, perspective }) =>
actor.attemptsTo(perspective.handlerFor({ id, params })),
({ actor, perspective, log = NoLog }) => {
log(description.toString())
return actor.attemptsTo(perspective.handlerFor({ id, params }))
},
{ id }
)
const Interaction = (fn, description) => ({
actor,
log = NoLog,
...abilities
}) => {
log(description.toString())
return fn({ actor, log, ...abilities })
}
module.exports = {

@@ -120,4 +134,5 @@ Actor,

Task,
Interaction,
Description,
Id,
}

@@ -5,3 +5,3 @@ 'use strict'

const sinon = require('sinon')
const { Perspective, Actor, Task } = require('./core')
const { Perspective, Actor, Task, Description, Interaction } = require('./core')

@@ -146,2 +146,21 @@ describe('feynman core objects', () => {

})
describe('logging', () => {
it('logs when a task is attempted', async () => {
const log = sinon.spy()
const doSomething = Task('doSomething', {}, Description('Do something!'))
const perspective = Perspective('Perspective', handle => {
handle({ id: 'doSomething' }, () => () => {})
})
await Actor({ log }, perspective).attemptsTo(doSomething)
sinon.assert.calledWith(log, 'Do something!')
})
it('logs when an interaction is attempted', async () => {
const log = sinon.spy()
const doSomething = Interaction(() => {}, Description('Do something!'))
await Actor({ log }, Perspective()).attemptsTo(doSomething)
sinon.assert.calledWith(log, 'Do something!')
})
})
})

13

lib/feynman/definitions.js
'use strict'
const { Description, Id, Task } = require('./core')
const { Description, Id, Task, Interaction } = require('./core')
const Interaction = (fn, description = Description()) => {
const DefineInteraction = (fn, description = Description()) => {
if (typeof fn !== 'function') throw new Error('An action must be a function')
const handler = (...args) => fn(...args)
return Object.assign(handler, {
return Object.assign(Interaction(fn, description), {
description,
withContext: ({ description }) => Interaction(fn, description),
withContext: ({ description }) => DefineInteraction(fn, description),
})

@@ -16,3 +15,3 @@ }

return Object.assign(
Task(context.id, context.params),
Task(context.id, context.params, context.description),
{

@@ -80,3 +79,3 @@ withContext: context => DefineTask(definition, context),

task: (paramName, subTasks) => MakeTask(paramName, subTasks),
action: Interaction,
action: DefineInteraction,
}
{
"name": "feynman",
"version": "0.0.21",
"version": "0.0.22",
"description": "A screenplay pattern library for javascript",

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

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