@cycle-robot-drivers/action
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -10,3 +10,2 @@ export declare type GoalID = { | ||
export declare enum Status { | ||
PENDING = "PENDING", | ||
ACTIVE = "ACTIVE", | ||
@@ -13,0 +12,0 @@ PREEMPTED = "PREEMPTED", |
@@ -5,3 +5,2 @@ "use strict"; | ||
(function (Status) { | ||
Status["PENDING"] = "PENDING"; | ||
Status["ACTIVE"] = "ACTIVE"; | ||
@@ -8,0 +7,0 @@ Status["PREEMPTED"] = "PREEMPTED"; |
import { Goal, GoalID } from './types'; | ||
export declare function generateGoalID(): GoalID; | ||
export declare function initGoal(goal: any): Goal; | ||
export declare function initGoal(goal: any, isGoal?: (g: any) => boolean): Goal; | ||
export declare function isEqual(first: GoalID, second: GoalID): boolean; | ||
@@ -5,0 +5,0 @@ export declare function powerup(main: (sources: { |
@@ -20,4 +20,5 @@ "use strict"; | ||
exports.generateGoalID = generateGoalID; | ||
function initGoal(goal) { | ||
return { | ||
function initGoal(goal, isGoal) { | ||
if (isGoal === void 0) { isGoal = function (g) { return !!g.goal_id; }; } | ||
return isGoal(goal) ? goal : { | ||
goal_id: generateGoalID(), | ||
@@ -24,0 +25,0 @@ goal: goal, |
@@ -10,3 +10,2 @@ export declare type GoalID = { | ||
export declare enum Status { | ||
PENDING = "PENDING", | ||
ACTIVE = "ACTIVE", | ||
@@ -13,0 +12,0 @@ PREEMPTED = "PREEMPTED", |
export var Status; | ||
(function (Status) { | ||
Status["PENDING"] = "PENDING"; | ||
Status["ACTIVE"] = "ACTIVE"; | ||
@@ -5,0 +4,0 @@ Status["PREEMPTED"] = "PREEMPTED"; |
import { Goal, GoalID } from './types'; | ||
export declare function generateGoalID(): GoalID; | ||
export declare function initGoal(goal: any): Goal; | ||
export declare function initGoal(goal: any, isGoal?: (g: any) => boolean): Goal; | ||
export declare function isEqual(first: GoalID, second: GoalID): boolean; | ||
@@ -5,0 +5,0 @@ export declare function powerup(main: (sources: { |
@@ -17,4 +17,5 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
} | ||
export function initGoal(goal) { | ||
return { | ||
export function initGoal(goal, isGoal) { | ||
if (isGoal === void 0) { isGoal = function (g) { return !!g.goal_id; }; } | ||
return isGoal(goal) ? goal : { | ||
goal_id: generateGoalID(), | ||
@@ -21,0 +22,0 @@ goal: goal, |
{ | ||
"name": "@cycle-robot-drivers/action", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "", | ||
"repository": "", | ||
"author": "Michael Jae-Yoon Chung", | ||
"license": "MIT", | ||
"bugs": "https://github.com/mjyc/cycle-robot-drivers/issues", | ||
"repository": "https://github.com/mjyc/cycle-robot-drivers/tree/master/action", | ||
"main": "lib/cjs/index.js", | ||
@@ -14,4 +15,5 @@ "module": "lib/es6/index.js", | ||
"build:es6": "../node_modules/.bin/tsc --project tsconfig.json --module es6 --outDir lib/es6", | ||
"build:doc": "../node_modules/.bin/markdox ./src/* -o api.md && cat ../docs/readmes/${PWD##*/}.md api.md > README.md && rm api.md", | ||
"test": "../node_modules/.bin/jest --config ../jest.config.common.js --rootDir ./" | ||
} | ||
} |
@@ -0,3 +1,19 @@ | ||
<!-- This README.md is automatically generated. Edit the JSDoc comments in source code or the md files in docs/readmes/. --> | ||
# @cycle-robot-drivers/action | ||
[Type definitions](./src/types.ts) and [utility functions](./src/utils.ts) for [cycle-robot-drivers](../). | ||
<!-- Start src/index.ts --> | ||
<!-- End src/index.ts --> | ||
<!-- Start src/types.ts --> | ||
<!-- End src/types.ts --> | ||
<!-- Start src/utils.ts --> | ||
<!-- End src/utils.ts --> | ||
@@ -12,3 +12,2 @@ export type GoalID = { | ||
export enum Status { | ||
PENDING = 'PENDING', // TODO: remove after refactoring | ||
ACTIVE = 'ACTIVE', | ||
@@ -15,0 +14,0 @@ PREEMPTED = 'PREEMPTED', |
import {Goal, GoalID} from './types' | ||
export function generateGoalID(): GoalID { | ||
@@ -12,7 +11,10 @@ const now = new Date(); | ||
export function initGoal(goal: any): Goal { | ||
return { | ||
export function initGoal( | ||
goal: any, | ||
isGoal: (g: any) => boolean = g => !!g.goal_id, | ||
): Goal { | ||
return isGoal(goal) ? goal : { | ||
goal_id: generateGoalID(), | ||
goal, | ||
} | ||
}; | ||
} | ||
@@ -19,0 +21,0 @@ |
import {generateGoalID, isEqual} from '../src/utils' | ||
describe('isEqual', () => { | ||
test('returns true for two GoalIDs with the same property values', () => { | ||
it('returns true for two GoalIDs with the same property values', () => { | ||
const goalId1 = generateGoalID(); | ||
@@ -6,0 +6,0 @@ const goalId2 = {...goalId1}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
13068
20