tweak(xod-project): clarify utils for getting pins for built-in patches

This commit is contained in:
Evgeny Kochetkov
2017-05-16 12:47:29 +03:00
parent 61bb0c16df
commit 69bb2dcdb7
2 changed files with 14 additions and 11 deletions

View File

@@ -75,7 +75,7 @@ const TERMINAL_NODE_PINS = R.compose(
)(PIN_TYPE);
// :: PatchPath -> (StrMap Pin) | Null
export const getPinsForBuiltInPatchPath =
export const getHardcodedPinsForPatchPath =
R.flip(R.prop)(R.merge(
PINS_OF_PATCH_NODES,
TERMINAL_NODE_PINS

View File

@@ -1,6 +1,6 @@
import R from 'ramda';
import { Maybe, Either } from 'ramda-fantasy';
import { explodeMaybe } from 'xod-func-tools';
import { explodeMaybe, notNil } from 'xod-func-tools';
import * as CONST from './constants';
import * as Tools from './func-tools';
@@ -10,7 +10,7 @@ import * as Pin from './pin';
import * as Utils from './utils';
import { sortGraph } from './gmath';
import { def } from './types';
import { getPinsForBuiltInPatchPath } from './builtInPatches';
import { getHardcodedPinsForPatchPath } from './builtInPatches';
import { getLocalPath } from './patchPathUtils';
/**
@@ -233,15 +233,18 @@ const computePins = R.memoize(patch =>
)(patch)
);
const getPinsForBuiltInPatch =
R.pipe(getPatchPath, getPinsForBuiltInPatchPath);
const getHardcodedPinsForPatch =
R.pipe(getPatchPath, getHardcodedPinsForPatchPath);
const getPins = patch =>
R.ifElse(
getPinsForBuiltInPatch,
getPinsForBuiltInPatch,
computePins
)(patch);
// not isPathBuiltIn, because it does not cover internal patches
const patchHasHardcodedPins =
R.pipe(getHardcodedPinsForPatch, notNil);
const getPins = R.ifElse(
patchHasHardcodedPins,
getHardcodedPinsForPatch,
computePins
);
/**
* Returns pin object by key