From 647c553bf48c08238db0ccb825f99d38df33c9c8 Mon Sep 17 00:00:00 2001 From: carlo Date: Thu, 22 Feb 2018 16:13:59 +0100 Subject: [PATCH] fixes the techan importing problems --- package.json | 2 +- src/accessor/adx.js | 4 +- src/accessor/aroon.js | 4 +- src/accessor/atrtrailingstop.js | 4 +- src/accessor/bollinger.js | 4 +- src/accessor/crosshair.js | 4 +- src/accessor/ichimoku.js | 4 +- src/accessor/index.js | 61 ++++++++++++++-------- src/accessor/macd.js | 4 +- src/accessor/ohlc.js | 4 +- src/accessor/rsi.js | 4 +- src/accessor/stochastic.js | 4 +- src/accessor/supstance.js | 4 +- src/accessor/tick.js | 4 +- src/accessor/trade.js | 4 +- src/accessor/trendline.js | 4 +- src/accessor/value.js | 4 +- src/accessor/volume.js | 4 +- src/accessor/williams.js | 4 +- src/indicator/adx.js | 4 +- src/indicator/aroon.js | 4 +- src/indicator/atr.js | 4 +- src/indicator/atrtrailingstop.js | 4 +- src/indicator/bollinger.js | 4 +- src/indicator/ema.js | 4 +- src/indicator/heikinashi.js | 7 ++- src/indicator/ichimoku.js | 4 +- src/indicator/index.js | 59 ++++++++++++++-------- src/indicator/indicatormixin.js | 4 +- src/indicator/macd.js | 4 +- src/indicator/rsi.js | 4 +- src/indicator/sma.js | 4 +- src/indicator/sroc.js | 4 +- src/indicator/stochastic.js | 4 +- src/indicator/vwap.js | 4 +- src/indicator/williams.js | 6 +-- src/plot/adx.js | 4 +- src/plot/aroon.js | 4 +- src/plot/atrtrailingstop.js | 4 +- src/plot/axisannotation.js | 5 +- src/plot/bollinger.js | 4 +- src/plot/candlestick.js | 6 +-- src/plot/crosshair.js | 4 +- src/plot/ichimoku.js | 4 +- src/plot/index.js | 87 +++++++++++++++++++++----------- src/plot/line.js | 4 +- src/plot/macd.js | 4 +- src/plot/ohlc.js | 4 +- src/plot/plot.js | 9 ++-- src/plot/plotmixin.js | 4 +- src/plot/rsi.js | 4 +- src/plot/stochastic.js | 4 +- src/plot/supstance.js | 4 +- src/plot/tick.js | 4 +- src/plot/tradearrow.js | 4 +- src/plot/trendline.js | 4 +- src/plot/volume.js | 4 +- src/plot/williams.js | 4 +- src/scale/financetime.js | 8 +-- src/scale/index.js | 17 ++++--- src/scale/zoomable.js | 4 +- src/svg/arrow.js | 4 +- src/svg/index.js | 8 +-- src/techan.js | 31 +++++------- src/util/circularbuffer.js | 2 +- src/util/index.js | 6 +-- 66 files changed, 237 insertions(+), 281 deletions(-) diff --git a/package.json b/package.json index 33d2c9e9..f7fe6d3d 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "type": "git", "url": "https://github.com/andredumas/techan.js.git" }, - "license" : "MIT", + "license": "MIT", "dependencies": { "d3": "~4.2.6" }, diff --git a/src/accessor/adx.js b/src/accessor/adx.js index ba331423..48cfe731 100644 --- a/src/accessor/adx.js +++ b/src/accessor/adx.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const adx = function() { var date = function(d) { return d.date; }, adx = function(d) { return d.adx; }, plusDi = function(d) { return d.plusDi; }, diff --git a/src/accessor/aroon.js b/src/accessor/aroon.js index 90742030..16d2b910 100644 --- a/src/accessor/aroon.js +++ b/src/accessor/aroon.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const aroon = function () { var date = function(d) { return d.date; }, up = function(d) { return d.up; }, diff --git a/src/accessor/atrtrailingstop.js b/src/accessor/atrtrailingstop.js index bd542761..1189b33b 100644 --- a/src/accessor/atrtrailingstop.js +++ b/src/accessor/atrtrailingstop.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const atrtrailingstop = function() { var date = function(d) { return d.date; }, up = function(d) { return d.up; }, down = function(d) { return d.down; }; diff --git a/src/accessor/bollinger.js b/src/accessor/bollinger.js index 691b01d4..f2d605d8 100644 --- a/src/accessor/bollinger.js +++ b/src/accessor/bollinger.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const bollinger = function() { var date = function(d) { return d.date; }, middle = function(d) { return d.middleBand; }, upper = function(d) { return d.upperBand; }, diff --git a/src/accessor/crosshair.js b/src/accessor/crosshair.js index 31085165..3c1cd08c 100644 --- a/src/accessor/crosshair.js +++ b/src/accessor/crosshair.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const crosshair = function() { /** * Supports getter and setter. Watch out if used in d3 and the second parameter is an index!! * This approach needs further thought. diff --git a/src/accessor/ichimoku.js b/src/accessor/ichimoku.js index 0daf9b9d..adb00eee 100644 --- a/src/accessor/ichimoku.js +++ b/src/accessor/ichimoku.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const ichimoku = function() { var date = function(d) { return d.date; }, tenkanSen = function(d) { return d.tenkanSen; }, // Conversion line kijunSen = function(d) { return d.kijunSen; }, // Base Line diff --git a/src/accessor/index.js b/src/accessor/index.js index 5f6e14fb..14f58a7c 100644 --- a/src/accessor/index.js +++ b/src/accessor/index.js @@ -1,24 +1,41 @@ -'use strict'; + + +import { atrtrailingstop } from './atrtrailingstop'; +import { crosshair } from './crosshair'; +import { ichimoku } from './ichimoku'; +import { macd } from './macd'; +import { ohlc } from './ohlc'; +import { rsi } from './rsi'; +import { trendline } from './trendline'; +import { value } from './value'; +import { volume } from './volume'; +import { tick } from './tick'; +import { trade } from './trade'; +import { adx } from './adx'; +import { aroon } from './aroon'; +import { stochastic } from './stochastic'; +import { supstance } from './supstance'; +import { williams } from './williams'; +import { bollinger } from './bollinger'; + // Provide IDs for all accessors. Default to date, but at least provide an option -module.exports = function() { - return { - atrtrailingstop: require('./atrtrailingstop'), - crosshair: require('./crosshair'), - ichimoku: require('./ichimoku'), - macd: require('./macd'), - ohlc: require('./ohlc'), - rsi: require('./rsi'), - trendline: require('./trendline'), - value: require('./value'), - volume: require('./volume'), - tick: require('./tick'), - trade: require('./trade'), - adx: require('./adx'), - aroon: require('./aroon'), - stochastic: require('./stochastic'), - supstance: require('./supstance'), - williams: require('./williams'), - bollinger: require('./bollinger') - }; -}; +export const accessors = ()=>({ + atrtrailingstop: atrtrailingstop, + crosshair: crosshair, + ichimoku: ichimoku, + macd: macd, + ohlc: ohlc, + rsi: rsi, + trendline: trendline, + value: value, + volume: volume, + tick: tick, + trade: trade, + adx: adx, + aroon: aroon, + stochastic: stochastic, + supstance: supstance, + williams: williams, + bollinger: bollinger + }); diff --git a/src/accessor/macd.js b/src/accessor/macd.js index 3e3bb546..ae1485c5 100644 --- a/src/accessor/macd.js +++ b/src/accessor/macd.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const macd = function() { var date = function(d) { return d.date; }, macd = function(d) { return d.macd; }, zero = function(d) { return d.zero; }, diff --git a/src/accessor/ohlc.js b/src/accessor/ohlc.js index 40a7c1d0..50be7a77 100644 --- a/src/accessor/ohlc.js +++ b/src/accessor/ohlc.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const ohlc = function() { var date = function(d) { return d.date; }, open = function(d) { return d.open; }, high = function(d) { return d.high; }, diff --git a/src/accessor/rsi.js b/src/accessor/rsi.js index 857d8eaa..e70995dc 100644 --- a/src/accessor/rsi.js +++ b/src/accessor/rsi.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const rsi = function() { var date = function(d) { return d.date; }, rsi = function(d) { return d.rsi; }, overbought = function(d) { return d.overbought; }, diff --git a/src/accessor/stochastic.js b/src/accessor/stochastic.js index a0721801..9b93fb79 100644 --- a/src/accessor/stochastic.js +++ b/src/accessor/stochastic.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const stochastic = function() { var date = function(d) { return d.date; }, stochasticK = function(d) { return d.stochasticK; }, stochasticD = function(d) { return d.stochasticD; }, diff --git a/src/accessor/supstance.js b/src/accessor/supstance.js index 9c42a328..3c2d0d0a 100644 --- a/src/accessor/supstance.js +++ b/src/accessor/supstance.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const supstance = function() { var start = function(d) { return d.start; }, end = function(d) { return d.end; }, /** diff --git a/src/accessor/tick.js b/src/accessor/tick.js index e1791a26..26374b84 100644 --- a/src/accessor/tick.js +++ b/src/accessor/tick.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const tick = function() { var date = function(d) { return d.date; }, high = function(d) { return d.high; }, low = function(d) { return d.low; }, diff --git a/src/accessor/trade.js b/src/accessor/trade.js index c703b031..3a823aba 100644 --- a/src/accessor/trade.js +++ b/src/accessor/trade.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const trade = function() { var date = function(d) { return d.date; }, type = function(d) { return d.type; }, price = function(d) { return d.price; }; diff --git a/src/accessor/trendline.js b/src/accessor/trendline.js index 2330f516..25796259 100644 --- a/src/accessor/trendline.js +++ b/src/accessor/trendline.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const trendline = function() { var startDate = function(d, _) { if(arguments.length < 2) return d.start.date; d.start.date = _; diff --git a/src/accessor/value.js b/src/accessor/value.js index bb80e753..0b9f5f64 100644 --- a/src/accessor/value.js +++ b/src/accessor/value.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const value = function() { var date = function(d) { return d.date; }, /** * Supports getter and setter diff --git a/src/accessor/volume.js b/src/accessor/volume.js index 5be4c390..d3f140b1 100644 --- a/src/accessor/volume.js +++ b/src/accessor/volume.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const volume = function() { var date = function(d) { return d.date; }, volume = function(d) { return d.volume; }; diff --git a/src/accessor/williams.js b/src/accessor/williams.js index bfcd947a..97ac31b9 100644 --- a/src/accessor/williams.js +++ b/src/accessor/williams.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const williams = function() { var date = function(d) { return d.date; }, williams = function(d) { return d.williams; }; diff --git a/src/indicator/adx.js b/src/indicator/adx.js index c8ef4281..07620f83 100644 --- a/src/indicator/adx.js +++ b/src/indicator/adx.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_max, indicatorMixin, accessor_ohlc, indicator_ema) { // Injected dependencies +export const adx = function(d3_max, indicatorMixin, accessor_ohlc, indicator_ema) { // Injected dependencies return function() { // Closure function var p = {}; // Container for private, direct access mixed in variables diff --git a/src/indicator/aroon.js b/src/indicator/aroon.js index 60712e23..6a7bbffd 100644 --- a/src/indicator/aroon.js +++ b/src/indicator/aroon.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc) { // Injected dependencies +export const aroon = function(indicatorMixin, accessor_ohlc) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables overbought = 70, diff --git a/src/indicator/atr.js b/src/indicator/atr.js index 927f33b7..d104a28c 100644 --- a/src/indicator/atr.js +++ b/src/indicator/atr.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc, indicator_sma) { // Injected dependencies +export const atr_init = function(indicatorMixin, accessor_ohlc, indicator_sma) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables initialAtr = indicator_sma(), diff --git a/src/indicator/atrtrailingstop.js b/src/indicator/atrtrailingstop.js index 757f5390..1191a6a2 100644 --- a/src/indicator/atrtrailingstop.js +++ b/src/indicator/atrtrailingstop.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc, indicator_atr) { // Injected dependencies +export const atrtrailingstop = function(indicatorMixin, accessor_ohlc, indicator_atr) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables multiplier = 3, diff --git a/src/indicator/bollinger.js b/src/indicator/bollinger.js index 54e1ba38..830e0341 100755 --- a/src/indicator/bollinger.js +++ b/src/indicator/bollinger.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc, indicator_sma) { // Injected dependencies +export const bollinger = function(indicatorMixin, accessor_ohlc, indicator_sma) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables sdMultiplication = 2, diff --git a/src/indicator/ema.js b/src/indicator/ema.js index e7755243..96d04ac1 100644 --- a/src/indicator/ema.js +++ b/src/indicator/ema.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc, alpha_init) { // Injected dependencies +export const ema_init = function(indicatorMixin, accessor_ohlc, alpha_init) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables previous, diff --git a/src/indicator/heikinashi.js b/src/indicator/heikinashi.js index 3c7df05d..067f25c9 100644 --- a/src/indicator/heikinashi.js +++ b/src/indicator/heikinashi.js @@ -1,7 +1,6 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc, min, max) { // Injected dependencies - return function() { // Closure function +export const heikinashi = function(indicatorMixin, accessor_ohlc, min, max) { // Injected dependencies + //Injected dependencies + return function() { // Closure function var p = {}; // Container for private, direct access mixed in variables function indicator(data) { diff --git a/src/indicator/ichimoku.js b/src/indicator/ichimoku.js index 4cebb544..7658b4f0 100644 --- a/src/indicator/ichimoku.js +++ b/src/indicator/ichimoku.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc) { // Injected dependencies +export const ichimoku = function(indicatorMixin, accessor_ohlc) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables tenkanSen = 9, diff --git a/src/indicator/index.js b/src/indicator/index.js index 5057148b..8a0f3a79 100644 --- a/src/indicator/index.js +++ b/src/indicator/index.js @@ -1,34 +1,51 @@ -'use strict'; -module.exports = function(d3) { - var indicatorMixin = require('./indicatormixin')(), - accessor = require('../accessor')(), - ema_init = require('./ema'), +import { indicatormixin } from './indicatormixin'; +import { accessors } from '../accessor'; +import { ema_init } from './ema'; +import { sma_init } from './sma'; +import { atr_init } from './atr'; +import { util } from '../util'; +import { sroc_init } from './sroc'; +import { vwap } from './vwap'; + + +import { atrtrailingstop } from './atrtrailingstop'; +import { heikinashi } from './heikinashi'; +import { ichimoku } from './ichimoku'; +import { macd } from './macd'; +import { rsi } from './rsi'; +import { adx } from './adx'; +import { aroon } from './aroon'; +import { stochastic } from './stochastic'; +import { williams } from './williams'; +import { bollinger } from './bollinger'; + +export const indicators = function(d3) { + var indicatorMixin = indicatormixin(), + accessor = accessors(), ema = ema_init(indicatorMixin, accessor.ohlc, ema_alpha_init), - sma = require('./sma')(indicatorMixin, accessor.ohlc), - atr = require('./atr')(indicatorMixin, accessor.ohlc, sma), - circularbuffer = require('../util')().circularbuffer, - sroc_init = require('./sroc'), - vwap = require('./vwap')(indicatorMixin, accessor.ohlc); + sma = sma_init(indicatorMixin, accessor.ohlc), + atr = atr_init(indicatorMixin, accessor.ohlc, sma), + circularbuffer = util().circularbuffer; return { atr: atr, - atrtrailingstop: require('./atrtrailingstop')(indicatorMixin, accessor.ohlc, atr), + atrtrailingstop: atrtrailingstop(indicatorMixin, accessor.ohlc, atr), ema: ema, - heikinashi: require('./heikinashi')(indicatorMixin, accessor.ohlc, d3.min, d3.max), - ichimoku: require('./ichimoku')(indicatorMixin, accessor.ohlc), - macd: require('./macd')(indicatorMixin, accessor.ohlc, ema), - rsi: require('./rsi')(indicatorMixin, accessor.ohlc, ema), + heikinashi: heikinashi(indicatorMixin, accessor.ohlc, d3.min, d3.max), + ichimoku: ichimoku(indicatorMixin, accessor.ohlc), + macd: macd(indicatorMixin, accessor.ohlc, ema), + rsi: rsi(indicatorMixin, accessor.ohlc, ema), sma: sma, wilderma: ema_init(indicatorMixin, accessor.ohlc, wilder_alpha_init), - aroon: require('./aroon')(indicatorMixin, accessor.ohlc), + aroon: aroon(indicatorMixin, accessor.ohlc), roc: sroc_init(circularbuffer, indicatorMixin, accessor.ohlc, ema, 1), sroc: sroc_init(circularbuffer, indicatorMixin, accessor.ohlc, ema, 13), - stochastic: require('./stochastic')(indicatorMixin, accessor.ohlc, ema), - williams: require('./williams')(indicatorMixin, accessor.ohlc, ema), - adx: require('./adx')(d3.max, indicatorMixin, accessor.ohlc, ema), - bollinger: require('./bollinger')(indicatorMixin, accessor.ohlc, sma), - vwap: vwap + stochastic: stochastic(indicatorMixin, accessor.ohlc, ema), + williams: williams(indicatorMixin, accessor.ohlc, ema), + adx: adx(d3.max, indicatorMixin, accessor.ohlc, ema), + bollinger: bollinger(indicatorMixin, accessor.ohlc, sma), + vwap: vwap(indicatorMixin, accessor.ohlc) }; }; diff --git a/src/indicator/indicatormixin.js b/src/indicator/indicatormixin.js index 3498be97..e418bc7a 100644 --- a/src/indicator/indicatormixin.js +++ b/src/indicator/indicatormixin.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function() { +export const indicatormixin = function() { return function(source, priv) { var indicatorMixin = {}; diff --git a/src/indicator/macd.js b/src/indicator/macd.js index 295694a9..3d7cbefd 100644 --- a/src/indicator/macd.js +++ b/src/indicator/macd.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc, indicator_ema) { // Injected dependencies +export const macd = function(indicatorMixin, accessor_ohlc, indicator_ema) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables fast = 12, diff --git a/src/indicator/rsi.js b/src/indicator/rsi.js index 8d860bbb..9b9aabfc 100644 --- a/src/indicator/rsi.js +++ b/src/indicator/rsi.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc, indicator_ema) { // Injected dependencies +export const rsi = function(indicatorMixin, accessor_ohlc, indicator_ema) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables overbought = 70, diff --git a/src/indicator/sma.js b/src/indicator/sma.js index 8fd4829e..87950f73 100644 --- a/src/indicator/sma.js +++ b/src/indicator/sma.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc) { // Injected dependencies +export const sma_init = function(indicatorMixin, accessor_ohlc) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables samples, diff --git a/src/indicator/sroc.js b/src/indicator/sroc.js index cede2be1..088b7d8b 100644 --- a/src/indicator/sroc.js +++ b/src/indicator/sroc.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(techan_util_circularbuffer, indicatorMixin, accessor_ohlc, indicator_smoothing, smoothed_period) { // Injected dependencies +export const sroc_init = function(techan_util_circularbuffer, indicatorMixin, accessor_ohlc, indicator_smoothing, smoothed_period) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables smoothing = indicator_smoothing().period(smoothed_period), diff --git a/src/indicator/stochastic.js b/src/indicator/stochastic.js index 11302de9..5a486f57 100644 --- a/src/indicator/stochastic.js +++ b/src/indicator/stochastic.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc) { // Injected dependencies +export const stochastic = function(indicatorMixin, accessor_ohlc) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables periodD = 3, diff --git a/src/indicator/vwap.js b/src/indicator/vwap.js index 157e2956..c8ff9679 100644 --- a/src/indicator/vwap.js +++ b/src/indicator/vwap.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc) { // Injected dependencies +export const vwap = function(indicatorMixin, accessor_ohlc) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables cumul_total, diff --git a/src/indicator/williams.js b/src/indicator/williams.js index 069825b5..a6a6bc2a 100644 --- a/src/indicator/williams.js +++ b/src/indicator/williams.js @@ -1,7 +1,4 @@ -'use strict'; - -module.exports = function(indicatorMixin, accessor_ohlc) { // Injected dependencies - return function() { // Closure function +export const williams = function(indicatorMixin, accessor_ohlc) { // Injected dependencies var p = {}, // Container for private, direct access mixed in variables overbought = 80, middle = 50, @@ -53,7 +50,6 @@ module.exports = function(indicatorMixin, accessor_ohlc) { // Injected dependen indicatorMixin(indicator, p).accessor(accessor_ohlc()).period(20); return indicator; - }; }; function datum(date, williams, middle, overbought, oversold) { diff --git a/src/plot/adx.js b/src/plot/adx.js index 3d568fb9..5292c905 100644 --- a/src/plot/adx.js +++ b/src/plot/adx.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_adx, plot, plotMixin) { // Injected dependencies +export const adx = function(accessor_adx, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables adxLine = plot.pathLine(), diff --git a/src/plot/aroon.js b/src/plot/aroon.js index f8982786..36ca3a9b 100644 --- a/src/plot/aroon.js +++ b/src/plot/aroon.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_aroon, plot, plotMixin) { // Injected dependencies +export const aroon = function(accessor_aroon, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables oscLine = plot.pathLine(), diff --git a/src/plot/atrtrailingstop.js b/src/plot/atrtrailingstop.js index 7f2d4deb..a02e2e50 100644 --- a/src/plot/atrtrailingstop.js +++ b/src/plot/atrtrailingstop.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_atrtrailingstop, plot, plotMixin) { // Injected dependencies +export const atrtrailingstop = function(accessor_atrtrailingstop, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables upLine = plot.pathLine(), diff --git a/src/plot/axisannotation.js b/src/plot/axisannotation.js index 89684b57..223fb172 100644 --- a/src/plot/axisannotation.js +++ b/src/plot/axisannotation.js @@ -1,9 +1,7 @@ -'use strict'; - /** * TODO Refactor this to techan.plot.annotation.axis()? */ -module.exports = function(d3_svg_axis, d3_scale_linear, accessor_value, plot, plotMixin) { // Injected dependencies +export const axisannotation = function(d3_svg_axis, d3_scale_linear, accessor_value, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, axis = d3_svg_axis(d3_scale_linear()), @@ -107,6 +105,7 @@ function textAttributes(text, accessor, axis, orient, neg) { break; case 'top': case 'bottom': + default: text.attr('x', textPosition(accessor, scale)) .attr('y', neg*(Math.max(axis.tickSizeInner(), 0) + axis.tickPadding())) .attr('dy', neg < 0 ? '0em' : '.72em') diff --git a/src/plot/bollinger.js b/src/plot/bollinger.js index 05d22bcd..0db5228e 100755 --- a/src/plot/bollinger.js +++ b/src/plot/bollinger.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_bollinger, plot, plotMixin) { // Injected dependencies +export const bollinger = function(accessor_bollinger, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables upperLine = plot.pathLine(), diff --git a/src/plot/candlestick.js b/src/plot/candlestick.js index 6b0fd254..d3bf90b2 100644 --- a/src/plot/candlestick.js +++ b/src/plot/candlestick.js @@ -1,7 +1,5 @@ -'use strict'; - -module.exports = function(d3_scale_linear, d3_extent, accessor_ohlc, plot, plotMixin) { // Injected dependencies - return function() { // Closure constructor +export const candlestick = function(d3_scale_linear, d3_extent, accessor_ohlc, plot, plotMixin) { // Injected dependencies + return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables bodyPathGenerator, wickGenerator, diff --git a/src/plot/crosshair.js b/src/plot/crosshair.js index 9290b193..c415c59a 100644 --- a/src/plot/crosshair.js +++ b/src/plot/crosshair.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_select, d3_event, d3_mouse, d3_dispatch, accessor_crosshair, plot, plotMixin) { // Injected dependencies +export const crosshair = function(d3_select, d3_event, d3_mouse, d3_dispatch, accessor_crosshair, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables dispatcher = d3_dispatch('enter', 'out', 'move'), diff --git a/src/plot/ichimoku.js b/src/plot/ichimoku.js index 1f70a27b..46fd816c 100644 --- a/src/plot/ichimoku.js +++ b/src/plot/ichimoku.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_svg_area, d3_line_interpolate, accessor_ichimoku, plot, plotMixin) { // Injected dependencies +export const ichimoku = function(d3_svg_area, d3_line_interpolate, accessor_ichimoku, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables kumoClip = kumoClipArea(), diff --git a/src/plot/index.js b/src/plot/index.js index fc94dd59..899d5624 100644 --- a/src/plot/index.js +++ b/src/plot/index.js @@ -1,49 +1,76 @@ -'use strict'; +import { scale as _scale } from '../scale'; +import { accessors as _accessors } from '../accessor'; +import { plot as _plot } from './plot'; +import { util } from '../util'; +import { plotmixin as _plotmixin } from './plotmixin'; +import { candlestick as _candlestick} from './candlestick'; +import { axisannotation as _axisannotation } from './axisannotation'; +import { svg as _svg } from '../svg'; -module.exports = function(d3) { - var scale = require('../scale')(d3), - accessor = require('../accessor')(), - plot = require('./plot')(d3.line, d3.area, d3.curveMonotoneX, d3.select), - d3_functor = require('../util')().functor, - plotMixin = require('./plotmixin')(d3.scaleLinear, d3_functor, scale.financetime, plot.dataSelector, plot.barWidth), - candlestick = require('./candlestick')(d3.scaleLinear, d3.extent, accessor.ohlc, plot, plotMixin), - line = require('./line'), - axisannotation = require('./axisannotation')(d3.axisTop, d3.scaleLinear, accessor.value, plot, plotMixin), - svg = require('../svg')(d3); +import { line } from './line'; + +import { adx } from './adx'; +import { aroon } from './aroon'; +import { atrtrailingstop } from './atrtrailingstop'; +import { bollinger } from './bollinger'; +import { crosshair } from './crosshair'; +import { ichimoku } from './ichimoku'; +import { macd } from './macd'; +import { ohlc } from './ohlc'; +import { rsi } from './rsi'; +import { stochastic } from './stochastic'; +import { supstance } from './supstance'; +import { tick } from './tick'; +import { tradearrow } from './tradearrow'; +import { trendline } from './trendline'; +import { williams } from './williams'; +import { volume } from './volume'; + +import * as d3 from 'd3'; +function d3_event() { + return d3.event; +} + +export const plot = function(d3) { + var scale = _scale(d3), + accessor = _accessors(), + plot = _plot(d3.line, d3.area, d3.curveMonotoneX, d3.select), + d3_functor = util().functor, + plotMixin = _plotmixin(d3.scaleLinear, d3_functor, scale.financetime, plot.dataSelector, plot.barWidth), + candlestick = _candlestick(d3.scaleLinear, d3.extent, accessor.ohlc, plot, plotMixin), + axisannotation = _axisannotation(d3.axisTop, d3.scaleLinear, accessor.value, plot, plotMixin), + svg = _svg(d3); return { - adx: require('./adx')(accessor.adx, plot, plotMixin), - aroon: require('./aroon')(accessor.aroon, plot, plotMixin), + adx: adx(accessor.adx, plot, plotMixin), + aroon: aroon(accessor.aroon, plot, plotMixin), atr: line(accessor.value, plot, plotMixin), - atrtrailingstop: require('./atrtrailingstop')(accessor.atrtrailingstop, plot, plotMixin), + atrtrailingstop: atrtrailingstop(accessor.atrtrailingstop, plot, plotMixin), axisannotation: axisannotation, - bollinger: require('./bollinger')(accessor.bollinger, plot, plotMixin), + bollinger: bollinger(accessor.bollinger, plot, plotMixin), candlestick: candlestick, close: line(accessor.ohlc, plot, plotMixin), - crosshair: require('./crosshair')(d3.select, d3_event, d3.mouse, d3.dispatch, accessor.crosshair, plot, plotMixin), + crosshair: crosshair(d3.select, d3_event, d3.mouse, d3.dispatch, accessor.crosshair, plot, plotMixin), ema: line(accessor.value, plot, plotMixin), heikinashi: candlestick, - ichimoku: require('./ichimoku')(d3.area, d3.curveMonotoneX, accessor.ichimoku, plot, plotMixin), - macd: require('./macd')(accessor.macd, plot, plotMixin), + ichimoku: ichimoku(d3.area, d3.curveMonotoneX, accessor.ichimoku, plot, plotMixin), + macd: macd(accessor.macd, plot, plotMixin), momentum: line(accessor.value, plot, plotMixin, true), moneyflow: line(accessor.value, plot, plotMixin, true), - ohlc: require('./ohlc')(d3.scaleLinear, d3.extent, accessor.ohlc, plot, plotMixin), + ohlc: ohlc(d3.scaleLinear, d3.extent, accessor.ohlc, plot, plotMixin), roc: line(accessor.value, plot, plotMixin, true), - rsi: require('./rsi')(accessor.rsi, plot, plotMixin), + rsi: rsi(accessor.rsi, plot, plotMixin), sma: line(accessor.value, plot, plotMixin), sroc: line(accessor.value, plot, plotMixin, true), - stochastic: require('./stochastic')(accessor.stochastic, plot, plotMixin), - supstance: require('./supstance')(d3.drag, d3_event, d3.select, d3.dispatch, accessor.supstance, plot, plotMixin), - tick: require('./tick')(d3.scaleLinear, d3.extent, accessor.tick, plot, plotMixin), - tradearrow: require('./tradearrow')(d3.select, d3_functor, d3.mouse, d3.dispatch, accessor.trade, plot, plotMixin, svg.arrow), - trendline: require('./trendline')(d3.drag, d3_event, d3.select, d3.dispatch, accessor.trendline, plot, plotMixin), - volume: require('./volume')(accessor.volume, plot, plotMixin), + stochastic: stochastic(accessor.stochastic, plot, plotMixin), + supstance: supstance(d3.drag, d3_event, d3.select, d3.dispatch, accessor.supstance, plot, plotMixin), + tick: tick(d3.scaleLinear, d3.extent, accessor.tick, plot, plotMixin), + tradearrow: tradearrow(d3.select, d3_functor, d3.mouse, d3.dispatch, accessor.trade, plot, plotMixin, svg.arrow), + trendline: trendline(d3.drag, d3_event, d3.select, d3.dispatch, accessor.trendline, plot, plotMixin), + volume: volume(accessor.volume, plot, plotMixin), vwap: line(accessor.value, plot, plotMixin), wilderma: line(accessor.value, plot, plotMixin), - williams: require('./williams')(accessor.williams, plot, plotMixin) + williams: williams(accessor.williams, plot, plotMixin) }; }; -function d3_event() { - return d3.event; -} diff --git a/src/plot/line.js b/src/plot/line.js index 292fddef..07502f2c 100644 --- a/src/plot/line.js +++ b/src/plot/line.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_value, plot, plotMixin, showZero) { // Injected dependencies +export const line = function(accessor_value, plot, plotMixin, showZero) { // Injected dependencies showZero = showZero || false; return function() { // Closure function diff --git a/src/plot/macd.js b/src/plot/macd.js index 90deb7c0..9aa51eb2 100644 --- a/src/plot/macd.js +++ b/src/plot/macd.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_macd, plot, plotMixin) { // Injected dependencies +export const macd = function(accessor_macd, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables differenceGenerator, diff --git a/src/plot/ohlc.js b/src/plot/ohlc.js index 69a2f818..6edfbd99 100644 --- a/src/plot/ohlc.js +++ b/src/plot/ohlc.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_scale_linear, d3_extent, accessor_ohlc, plot, plotMixin) { // Injected dependencies +export const ohlc = function(d3_scale_linear, d3_extent, accessor_ohlc, plot, plotMixin) { // Injected dependencies return function() { // Closure constructor var p = {}, // Container for private, direct access mixed in variables ohlcGenerator, diff --git a/src/plot/plot.js b/src/plot/plot.js index 8c198771..ab7c9251 100644 --- a/src/plot/plot.js +++ b/src/plot/plot.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_svg_line, d3_svg_area, d3_line_interpolate, d3_select) { +export const plot = function(d3_svg_line, d3_svg_area, d3_line_interpolate, d3_select) { var DataSelector = function(mapper) { var key, scope, @@ -117,7 +115,10 @@ module.exports = function(d3_svg_line, d3_svg_area, d3_line_interpolate, d3_sele } function appendPlotTypePath(g, data, plotNames, direction) { - g.selectAll('path.' + arrayJoin(plotNames, '.') + '.' + direction).data(function(d) { return [d.filter(data)]; }) + g.selectAll('path.' + arrayJoin(plotNames, '.') + '.' + direction) + .data(function(d) { + return [d.filter(data)]; + }) .enter().append('path').attr('class', arrayJoin(plotNames, ' ') + ' ' + direction); } diff --git a/src/plot/plotmixin.js b/src/plot/plotmixin.js index eed3e315..d0d36d89 100644 --- a/src/plot/plotmixin.js +++ b/src/plot/plotmixin.js @@ -1,10 +1,10 @@ -'use strict'; + /** * Module allows optionally mixing in helper methods to plots such as xScale, yScale, accessor setters * and helpers for defining dispatching methods. */ -module.exports = function(d3_scale_linear, d3_functor, techan_scale_financetime, plot_dataselector, plot_width) { +export const plotmixin = function(d3_scale_linear, d3_functor, techan_scale_financetime, plot_dataselector, plot_width) { var PlotMixin = function(source, priv) { var plotMixin = {}; diff --git a/src/plot/rsi.js b/src/plot/rsi.js index 013abeee..167e1b8f 100644 --- a/src/plot/rsi.js +++ b/src/plot/rsi.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_rsi, plot, plotMixin) { // Injected dependencies +export const rsi = function(accessor_rsi, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables rsiLine = plot.pathLine(); diff --git a/src/plot/stochastic.js b/src/plot/stochastic.js index 9614216a..66c3cebc 100644 --- a/src/plot/stochastic.js +++ b/src/plot/stochastic.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_stochastic, plot, plotMixin) { // Injected dependencies +export const stochastic = function(accessor_stochastic, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables kLine = plot.pathLine(), diff --git a/src/plot/supstance.js b/src/plot/supstance.js index a7f7ad74..d1cf850f 100644 --- a/src/plot/supstance.js +++ b/src/plot/supstance.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_behavior_drag, d3_event, d3_select, d3_dispatch, accessor_supstance, plot, plotMixin) { // Injected dependencies +export const supstance = function(d3_behavior_drag, d3_event, d3_select, d3_dispatch, accessor_supstance, plot, plotMixin) { // Injected dependencies function Supstance() { // Closure function var p = {}, // Container for private, direct access mixed in variables dispatch = d3_dispatch('mouseenter', 'mouseout', 'mousemove', 'drag', 'dragstart', 'dragend'), diff --git a/src/plot/tick.js b/src/plot/tick.js index 32f962f2..9256c58f 100644 --- a/src/plot/tick.js +++ b/src/plot/tick.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_scale_linear, d3_extent, accessor_tick, plot, plotMixin) { // Injected dependencies +export const tick = function(d3_scale_linear, d3_extent, accessor_tick, plot, plotMixin) { // Injected dependencies return function() { // Closure constructor var p = {}, // Container for private, direct access mixed in variables tickGenerator, diff --git a/src/plot/tradearrow.js b/src/plot/tradearrow.js index 83f26d35..a31ff0ca 100644 --- a/src/plot/tradearrow.js +++ b/src/plot/tradearrow.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_select, d3_functor, d3_mouse, d3_dispatch, accessor_trade, plot, plotMixin, svg_arrow) { // Injected dependencies +export const tradearrow = function(d3_select, d3_functor, d3_mouse, d3_dispatch, accessor_trade, plot, plotMixin, svg_arrow) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables dispatch = d3_dispatch('mouseenter', 'mouseout'), diff --git a/src/plot/trendline.js b/src/plot/trendline.js index 2c9863a1..fc0b0902 100644 --- a/src/plot/trendline.js +++ b/src/plot/trendline.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_behavior_drag, d3_event, d3_select, d3_dispatch, accessor_trendline, plot, plotMixin) { // Injected dependencies +export const trendline = function(d3_behavior_drag, d3_event, d3_select, d3_dispatch, accessor_trendline, plot, plotMixin) { // Injected dependencies function Trendline() { // Closure function var p = {}, // Container for private, direct access mixed in variables dispatch = d3_dispatch('mouseenter', 'mouseout', 'mousemove', 'drag', 'dragstart', 'dragend'); diff --git a/src/plot/volume.js b/src/plot/volume.js index 674cf70a..4dc0cb9c 100644 --- a/src/plot/volume.js +++ b/src/plot/volume.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_volume, plot, plotMixin) { // Injected dependencies +export const volume = function(accessor_volume, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables volumeGenerator; diff --git a/src/plot/williams.js b/src/plot/williams.js index 0615cfbf..c4e9ff57 100644 --- a/src/plot/williams.js +++ b/src/plot/williams.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(accessor_williams, plot, plotMixin) { // Injected dependencies +export const williams = function(accessor_williams, plot, plotMixin) { // Injected dependencies return function() { // Closure function var p = {}, // Container for private, direct access mixed in variables upLine = plot.pathLine(); diff --git a/src/scale/financetime.js b/src/scale/financetime.js index a213d301..0020c5b8 100644 --- a/src/scale/financetime.js +++ b/src/scale/financetime.js @@ -1,11 +1,9 @@ -'use strict'; - /* Finance time scale which is not necessarily continuous, is required to be plot continuous. Finance scale generally contains data points on days where a market is open but no points when closed, such as weekday and weekends respectively. When plot, is done so without weekend gaps. */ -module.exports = function(d3_scale_linear, d3_time, d3_bisect, techan_util_rebindCallback, scale_widen, techan_scale_zoomable) { // Injected dependencies +export const financetime = function(d3_scale_linear, d3_time, d3_bisect, techan_util_rebindCallback, scale_widen, techan_scale_zoomable) { // Injected dependencies function financetime(tickMethods, genericFormat, index, domain, padding, outerPadding, zoomLimit, closestTicks, zoomable) { var dateIndexMap, tickState = { tickFormat: tickMethods.daily[tickMethods.daily.length-1][2] }, @@ -303,7 +301,9 @@ module.exports = function(d3_scale_linear, d3_time, d3_bisect, techan_util_rebin [d3_time.timeFormat('%Y'), function() { return true; }] ]), intradayFormat = d3_v3_multi_shim([ - [d3_time.timeFormat(':%S'), function(d) { return d.getSeconds(); }], + [d3_time.timeFormat(':%S'), function(d) { + return d.getSeconds(); + }], [d3_time.timeFormat('%I:%M'), function(d) { return d.getMinutes(); }], [d3_time.timeFormat('%I %p'), function () { return true; }] ]), diff --git a/src/scale/index.js b/src/scale/index.js index a0ce85e0..e266d054 100644 --- a/src/scale/index.js +++ b/src/scale/index.js @@ -1,10 +1,13 @@ -'use strict'; - -module.exports = function(d3) { - var zoomable = require('./zoomable')(), - util = require('../util')(), - accessors = require('../accessor')(), - financetime = require('./financetime')(d3.scaleLinear, d3, d3.bisect, util.rebindCallback, widen, zoomable); +import { util as _util } from "../util"; +import { zoomable as _zoomable } from "./zoomable"; +import { accessors as _accessors } from "../accessor"; +import { financetime as _financetime } from "./financetime"; + +export const scale = function(d3) { + var zoomable = _zoomable(), + util = _util(), + accessors = _accessors(), + financetime = _financetime(d3.scaleLinear, d3, d3.bisect, util.rebindCallback, widen, zoomable); function ohlc(data, accessor) { accessor = accessor || accessors.ohlc(); diff --git a/src/scale/zoomable.js b/src/scale/zoomable.js index bdf7d7c1..eac1ac4a 100644 --- a/src/scale/zoomable.js +++ b/src/scale/zoomable.js @@ -1,5 +1,3 @@ -'use strict'; - /** * Creates a decorated zoomable view of the passed scale. As the finance scale deals with an array and integer positions within the * array, it does not support the d3 zoom behaviour. d3 zoom behaviour rescales the input domain. @@ -9,7 +7,7 @@ * * NOTE: This is not a complete scale, it will throw errors if it is used for anything else but zooming */ -module.exports = function() { +export const zoomable = function() { function zoomable(linear, zoomed, domainLimit, clamp) { clamp = clamp !== undefined ? clamp : true; diff --git a/src/svg/arrow.js b/src/svg/arrow.js index b31ae51c..b26c0bfd 100644 --- a/src/svg/arrow.js +++ b/src/svg/arrow.js @@ -1,6 +1,4 @@ -'use strict'; - -module.exports = function(d3_functor) { // Injected dependencies +export const arrow = function(d3_functor) { // Injected dependencies return function() { var fx = d3_functor(0), fy = d3_functor(0), diff --git a/src/svg/index.js b/src/svg/index.js index 6ed69169..b78d807f 100644 --- a/src/svg/index.js +++ b/src/svg/index.js @@ -1,7 +1,9 @@ -'use strict'; -module.exports = function(d3) { +import { arrow as _arrow } from './arrow'; +import { util } from '../util'; + +export const svg = function(d3) { return { - arrow: require('./arrow')(require('../util')().functor) + arrow: _arrow(util().functor)() }; }; \ No newline at end of file diff --git a/src/techan.js b/src/techan.js index 67647836..faa89165 100644 --- a/src/techan.js +++ b/src/techan.js @@ -1,19 +1,16 @@ -'use strict'; +import * as d3 from 'd3'; -var _d3; +import { indicators } from './indicator'; +import { accessors } from './accessor'; +import { svg } from './svg'; +import { plot } from './plot'; +import { scale } from './scale'; -// If running in browser (window !undefined), assume d3 available -if('undefined' != typeof window) _d3 = window.d3; -else if('object' == typeof module) _d3 = require('d3'); // else we're in the only other supported mode: v8/node -else throw "Unsupported runtime environment: Could not find d3. Ensure defined globally on window, or available as dependency."; - -module.exports = (function(d3) { - return { - version: require('../build/version'), - accessor: require('./accessor')(), - indicator: require('./indicator')(d3), - plot: require('./plot')(d3), - scale: require('./scale')(d3), - svg: require('./svg')(d3) - }; -})(_d3); \ No newline at end of file +export const techan = { +// version: require('../build/version'), + accessor: accessors(), + indicator: indicators(d3), + plot: plot(d3), + scale: scale(d3), + svg: svg(d3) +}; \ No newline at end of file diff --git a/src/util/circularbuffer.js b/src/util/circularbuffer.js index a8968974..1c3cf1bc 100644 --- a/src/util/circularbuffer.js +++ b/src/util/circularbuffer.js @@ -1,4 +1,4 @@ -'use strict'; + /** * http://www.embedded.com/electronics-blogs/embedded-round-table/4419407/The-ring-buffer diff --git a/src/util/index.js b/src/util/index.js index a3ba2bab..3ee6f076 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -1,8 +1,8 @@ -'use strict'; +import circularbuffer from './circularbuffer'; -module.exports = function() { +export const util = function() { return { - circularbuffer: require('./circularbuffer'), + circularbuffer: circularbuffer, rebindCallback: rebindCallback,