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

fun-model

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fun-model - npm Package Compare versions

Comparing version 1.1.4 to 1.2.0

typings/es6-promise/es6-promise.d.ts

12

CHANGELOG.md
CHANGELOG
===
1.2.0
--
New Features
-
Switched js compilation from es6 to commonjs es5.
1.1.0

@@ -10,4 +18,2 @@ --

Creating a queue for action calls.
Now you can call other actions in specific action or you can create "controller" actions which can wrap your complex logic.
Throwing in actions is not supported!!! If you manage to throw exception in handler of your action then action will be still in queue and processing of handling never will be closed. Queue can be deleted only by bootstrap function.
State lock in action handling. Now you can call other actions in action or you can create controller actions which wraps your more specific actions.

@@ -1,11 +0,17 @@

import * as s from './src/store';
import * as af from './src/actionFactory';
import * as d from './src/debug';
export * from './src/store';
export * from './src/actionFactory';
export * from './src/helpers';
export let bootstrap = (defaultState, renderCallback, debugCallback = undefined, subStateSeparator = '.') => {
debugCallback && d.bootstrap((m, p) => debugCallback(`fun-model -> ${m}`, p));
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var s = require('./src/store');
var af = require('./src/actionFactory');
var d = require('./src/debug');
__export(require('./src/store'));
__export(require('./src/actionFactory'));
__export(require('./src/helpers'));
exports.bootstrap = function (defaultState, renderCallback, debugCallback, subStateSeparator) {
if (debugCallback === void 0) { debugCallback = undefined; }
if (subStateSeparator === void 0) { subStateSeparator = '.'; }
debugCallback && d.bootstrap(function (m, p) { return debugCallback("fun-model -> " + m, p); });
s.bootstrap(defaultState, subStateSeparator);
af.bootstrap(renderCallback);
};
{
"name": "fun-model",
"version": "1.1.4",
"version": "1.2.0",
"description": "fun-model is pure functional implementation of FLUX architecture.",

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

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"tsconfig": "tsconfig ."
},

@@ -31,5 +31,6 @@ "devDependencies": {

"jasmine-core": "2.4.1",
"systemjs": "0.19.6"
"systemjs": "0.19.6",
"tsconfig-glob": "^0.4.3"
},
"license": "MIT"
}

@@ -6,5 +6,2 @@ import * as s from './store';

}
export interface IAsyncAction<T, TState> {
(param?: T): Promise<TState>;
}
export declare let createAction: <TState extends s.IState, TParams>(cursor: s.ICursor<TState> | s.ICursorFactory<TState, TParams>, handler: (state: TState, t?: TParams) => TState) => IAction<TParams>;

@@ -16,2 +13,1 @@ export interface IPair<TState extends s.IState, TParam> {

export declare let createActions: <TState extends s.IState, TParams>(...pairs: IPair<TState, TParams>[]) => IAction<TParams>;
export declare let createAsyncAction: <TState extends s.IState, TParams>(cursor: s.ICursor<TState> | s.ICursorFactory<TState, TParams>, handler: (state: TState, t?: TParams) => TState) => IAsyncAction<TParams, TState>;

@@ -1,5 +0,6 @@

import * as s from './store';
import * as d from './debug';
let render = null;
export let bootstrap = (renderCallback) => {
"use strict";
var s = require('./store');
var d = require('./debug');
var render = null;
exports.bootstrap = function (renderCallback) {
render = renderCallback;

@@ -9,4 +10,4 @@ queueOfHandlers = [];

};
export let createAction = (cursor, handler) => {
return ((params) => {
exports.createAction = function (cursor, handler) {
return (function (params) {
validateRenderCallback();

@@ -22,9 +23,13 @@ if (changeStateWithQueue(unifyCursor(cursor, params), handler, params)) {

}
export let createActions = (...pairs) => {
return ((params) => {
exports.createActions = function () {
var pairs = [];
for (var _i = 0; _i < arguments.length; _i++) {
pairs[_i - 0] = arguments[_i];
}
return (function (params) {
validateRenderCallback();
let changed = false;
var changed = false;
for (var i in pairs)
if (pairs.hasOwnProperty(i)) {
let pair = pairs[i];
var pair = pairs[i];
if (changeStateWithQueue(pair.cursor, pair.handler, params))

@@ -36,8 +41,8 @@ changed = true;

};
export let createAsyncAction = (cursor, handler) => {
return ((params) => {
return new Promise((f, r) => {
setTimeout(() => {
exports.createAsyncAction = function (cursor, handler) {
return (function (params) {
return new Promise(function (f, r) {
setTimeout(function () {
validateRenderCallback();
let c = unifyCursor(cursor, params);
var c = unifyCursor(cursor, params);
if (changeStateWithQueue(c, handler, params)) {

@@ -56,10 +61,10 @@ render();

}
let queueOfHandlers = [];
var queueOfHandlers = [];
function changeStateWithQueue(cursor, handler, params) {
queueOfHandlers.push({ cursor, handler, params });
queueOfHandlers.push({ cursor: cursor, handler: handler, params: params });
if (queueOfHandlers.length > 1)
return;
let isStateChanged = false;
var isStateChanged = false;
while (queueOfHandlers.length > 0) {
let n = queueOfHandlers[0];
var n = queueOfHandlers[0];
isStateChanged = changeState(n.cursor, n.handler, n.params) || isStateChanged;

@@ -72,4 +77,4 @@ queueOfHandlers.shift();

function changeState(cursor, handler, params) {
let oldState = s.getState(cursor);
let newState = handler(oldState, params);
var oldState = s.getState(cursor);
var newState = handler(oldState, params);
if (oldState === newState)

@@ -76,0 +81,0 @@ return false;

@@ -1,7 +0,9 @@

let debug = undefined;
export let bootstrap = (debugCallback) => {
"use strict";
var debug = undefined;
exports.bootstrap = function (debugCallback) {
debug = debugCallback;
};
export function log(message, params) {
function log(message, params) {
debug && debug(message, params);
}
exports.log = log;

@@ -1,9 +0,12 @@

export function shallowCopy(source, callback = (t) => { }) {
let target = {};
"use strict";
function shallowCopy(source, callback) {
if (callback === void 0) { callback = function (t) { }; }
var target = {};
for (var property in source)
if (source.hasOwnProperty(property))
target[property] = source[property];
let result = callback(target);
var result = callback(target);
return result || target;
}
exports.shallowCopy = shallowCopy;
;

@@ -1,20 +0,22 @@

import * as h from './helpers';
import * as d from './debug';
let state = null;
let stateSeparator = '.';
let rootStateKey = '';
export let rootCursor = {
"use strict";
var h = require('./helpers');
var d = require('./debug');
var state = null;
var stateSeparator = '.';
var rootStateKey = '';
exports.rootCursor = {
key: rootStateKey
};
export let bootstrap = (defaultState, subStateSeparator = '.') => {
exports.bootstrap = function (defaultState, subStateSeparator) {
if (subStateSeparator === void 0) { subStateSeparator = '.'; }
stateSeparator = subStateSeparator;
state = defaultState;
};
export let getState = (cursor) => {
let getInnerState = (innerState, path) => {
exports.getState = function (cursor) {
var getInnerState = function (innerState, path) {
if (path.length === 0)
return innerState;
let subPath = path.shift();
var subPath = path.shift();
checkSubstate(innerState, subPath, cursor.key);
let prop = innerState[subPath];
var prop = innerState[subPath];
return Array.isArray(prop) && path.length > 0

@@ -29,14 +31,14 @@ ? getInnerState(prop[Number(path.shift())], path)

};
export let setState = (cursor, updatedState) => {
let setInnerState = (innerState, path) => {
exports.setState = function (cursor, updatedState) {
var setInnerState = function (innerState, path) {
if (path.length === 0)
return updatedState;
let subPath = path.shift();
var subPath = path.shift();
checkSubstate(innerState, subPath, cursor.key);
let prop = innerState[subPath];
let newSubState = null;
var prop = innerState[subPath];
var newSubState = null;
if (Array.isArray(prop) && path.length > 0) {
let index = Number(path.shift());
var index = Number(path.shift());
prop[index] = setInnerState(prop[index], path);
newSubState = [...prop];
newSubState = prop.slice();
}

@@ -47,3 +49,3 @@ else

return innerState;
let newState = h.shallowCopy(innerState);
var newState = h.shallowCopy(innerState);
newState[subPath] = newSubState;

@@ -61,3 +63,3 @@ return newState;

if (s[subPath] === undefined)
throw `State for cursor key (${cursorKey}) does not exist.`;
throw "State for cursor key (" + cursorKey + ") does not exist.";
}

@@ -64,0 +66,0 @@ function checkDefaultStateAndCursor(cursor) {

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