diff --git a/packages/xod-project/src/index.js b/packages/xod-project/src/index.js index b6ba8401..a525fff4 100644 --- a/packages/xod-project/src/index.js +++ b/packages/xod-project/src/index.js @@ -45,6 +45,7 @@ export { isTerminalPin, normalizePinLabels, isPinBindable, + isPulsePin, } from './pin'; export * from './link'; export * from './constants'; diff --git a/packages/xod-project/src/pin.js b/packages/xod-project/src/pin.js index 1909586d..3f802851 100644 --- a/packages/xod-project/src/pin.js +++ b/packages/xod-project/src/pin.js @@ -156,6 +156,18 @@ export const isTerminalPin = def( ) ); +/** + * Checks pin type to be Pulse + * TODO: Add functions for other types when needed. + */ +export const isPulsePin = def( + 'isPulsePin :: Pin -> Boolean', + R.compose( + R.equals(CONST.PIN_TYPE.PULSE), + getPinType + ) +); + // ============================================================================= // // Setters diff --git a/packages/xod-project/test/pin.spec.js b/packages/xod-project/test/pin.spec.js index 96754316..074f9c98 100644 --- a/packages/xod-project/test/pin.spec.js +++ b/packages/xod-project/test/pin.spec.js @@ -79,6 +79,16 @@ describe('Pin', () => { expect(Pin.isTerminalPin(pin)).to.be.true(); }); }); + describe('isPulsePin', () => { + it('should return false for non-pulse pin', () => { + const pin = Helper.defaultizePin({ type: CONST.PIN_TYPE.STRING }); + expect(Pin.isPulsePin(pin)).to.be.false(); + }); + it('should return true for pulse pin', () => { + const pin = Helper.defaultizePin({ type: CONST.PIN_TYPE.PULSE }); + expect(Pin.isPulsePin(pin)).to.be.true(); + }); + }); describe('normalizePinLabels', () => { it('should return list of pins with unique labels', () => { const pins = [