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

@coorpacademy/progression-engine

Package Overview
Dependencies
Maintainers
14
Versions
371
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coorpacademy/progression-engine - npm Package Compare versions

Comparing version 5.4.0 to 5.5.0-alpha.137c29a1

es/util.js

47

es/compute-next-step.js

@@ -0,23 +1,23 @@

import map from 'lodash/fp/map';
import sample from 'lodash/fp/sample';
import pipe from 'lodash/fp/pipe';
import without from 'lodash/fp/without';
import map from 'lodash/fp/map';
import './types';
import updateState from './update-state';
import { hasFinished, isAlive } from './util';
var getNextSlide = function getNextSlide(state, slides) {
return pipe(map('_id'), without(state.slides), sample)(slides);
var defaultState = {
lives: 4,
slides: [],
nextContent: {
ref: '',
type: ''
}
};
export default function computeNextStep(state, action, slidePool) {
// compute next state according to the action
var nextState = updateState(state, [action]);
var _nextState$lives = nextState.lives,
lives = _nextState$lives === undefined ? 0 : _nextState$lives,
_nextState$slides = nextState.slides,
slides = _nextState$slides === undefined ? [] : _nextState$slides;
export default function computeNextStep(slidePool) {
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultState;
var _state$slides = state.slides,
slides = _state$slides === undefined ? [] : _state$slides;
// if no more lives, return failure endpoint
// if no more lives, return endpoint content
if (lives < 0) {
if (isAlive(state)) {
return {

@@ -29,4 +29,4 @@ ref: 'failExitNode',

// if all slides answered and still alive
if (slides.length === 4 && lives >= 0) {
// if all slides answered and still alive return success endpoint
if (hasFinished(4, state)) {
return {

@@ -38,16 +38,11 @@ ref: 'successExitNode',

// if still alive, get next slide
var nextSlideId = getNextSlide(nextState, slidePool);
var remainingSlides = without(slides, map('_id', slidePool));
var nextSlide = sample(remainingSlides);
// with next slide return content object
if (nextSlideId) return {
ref: nextSlideId,
return {
ref: nextSlide,
type: 'slide'
};
return {
ref: 'successExitNode',
type: 'success'
};
}
//# sourceMappingURL=compute-next-step.js.map

@@ -6,2 +6,6 @@ 'use strict';

var _map = require('lodash/fp/map');
var _map2 = _interopRequireDefault(_map);
var _sample = require('lodash/fp/sample');

@@ -11,6 +15,2 @@

var _pipe = require('lodash/fp/pipe');
var _pipe2 = _interopRequireDefault(_pipe);
var _without = require('lodash/fp/without');

@@ -20,29 +20,23 @@

var _map = require('lodash/fp/map');
var _map2 = _interopRequireDefault(_map);
require('./types');
var _updateState = require('./update-state');
var _util = require('./util');
var _updateState2 = _interopRequireDefault(_updateState);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getNextSlide = function getNextSlide(state, slides) {
return (0, _pipe2.default)((0, _map2.default)('_id'), (0, _without2.default)(state.slides), _sample2.default)(slides);
var defaultState = {
lives: 4,
slides: [],
nextContent: {
ref: '',
type: ''
}
};
function computeNextStep(slidePool) {
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultState;
var _state$slides = state.slides,
slides = _state$slides === undefined ? [] : _state$slides;
// if no more lives, return failure endpoint
function computeNextStep(state, action, slidePool) {
// compute next state according to the action
var nextState = (0, _updateState2.default)(state, [action]);
var _nextState$lives = nextState.lives,
lives = _nextState$lives === undefined ? 0 : _nextState$lives,
_nextState$slides = nextState.slides,
slides = _nextState$slides === undefined ? [] : _nextState$slides;
// if no more lives, return endpoint content
if (lives < 0) {
if ((0, _util.isAlive)(state)) {
return {

@@ -54,4 +48,4 @@ ref: 'failExitNode',

// if all slides answered and still alive
if (slides.length === 4 && lives >= 0) {
// if all slides answered and still alive return success endpoint
if ((0, _util.hasFinished)(4, state)) {
return {

@@ -63,16 +57,11 @@ ref: 'successExitNode',

// if still alive, get next slide
var nextSlideId = getNextSlide(nextState, slidePool);
var remainingSlides = (0, _without2.default)(slides, (0, _map2.default)('_id', slidePool));
var nextSlide = (0, _sample2.default)(remainingSlides);
// with next slide return content object
if (nextSlideId) return {
ref: nextSlideId,
return {
ref: nextSlide,
type: 'slide'
};
return {
ref: 'successExitNode',
type: 'success'
};
}
//# sourceMappingURL=compute-next-step.js.map
{
"name": "@coorpacademy/progression-engine",
"version": "5.4.0",
"version": "5.5.0-alpha.137c29a1",
"description": "",

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

Sorry, the diff of this file is not supported yet

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