@winkjs/composer 0.0.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +42 -103
- package/package.json +53 -29
- package/src/composer.js +75 -0
- package/src/core/batch/aoo-encoder.js +148 -0
- package/src/core/batch/index.js +12 -0
- package/src/core/batch/sliding-window.js +91 -0
- package/src/core/codec/index.js +137 -0
- package/src/core/emitter-manager/mqtt/constants.js +102 -0
- package/src/core/emitter-manager/mqtt/emitter.js +780 -0
- package/src/core/emitter-manager/mqtt/index.js +190 -0
- package/src/core/emitter-manager/mqtt/mqtt-store.js +538 -0
- package/src/core/emitter-manager/terminal/assert-columns.js +98 -0
- package/src/core/emitter-manager/terminal/formatters.js +160 -0
- package/src/core/emitter-manager/terminal/index.js +341 -0
- package/src/core/env-vars.js +245 -0
- package/src/core/mqtt-protocol.js +47 -0
- package/src/core/partition-manager/index.js +7 -0
- package/src/core/partition-manager/init.js +44 -0
- package/src/core/partition-manager/introspect.js +15 -0
- package/src/core/partition-manager/publish-to.js +6 -0
- package/src/core/partition-manager/recompute.js +5 -0
- package/src/core/partition-manager/reset.js +5 -0
- package/src/core/partition-manager/update.js +264 -0
- package/src/core/partition-manager/validate-flow.js +157 -0
- package/src/core/semantics/digest.js +128 -0
- package/src/core/semantics/index.js +83 -0
- package/src/core/semantics/loader.js +571 -0
- package/src/core/semantics/schemas/asset-class-schema.js +218 -0
- package/src/core/semantics/schemas/column-schema.js +651 -0
- package/src/core/semantics/schemas/enum-schema.js +153 -0
- package/src/core/semantics/schemas/index.js +51 -0
- package/src/core/semantics/warnings.js +141 -0
- package/src/core/shutdown-manager/index.js +289 -0
- package/src/core/source-manager/csv/index.js +171 -0
- package/src/core/source-manager/csv/start.js +456 -0
- package/src/core/source-manager/mqtt/client.js +406 -0
- package/src/core/source-manager/mqtt/constants.js +147 -0
- package/src/core/source-manager/mqtt/dedup.js +244 -0
- package/src/core/source-manager/mqtt/index.js +260 -0
- package/src/core/source-manager/mqtt/status.js +546 -0
- package/src/core/source-manager/test-harness/comparator.js +226 -0
- package/src/core/source-manager/test-harness/field-generator.js +85 -0
- package/src/core/source-manager/test-harness/fuzz.js +87 -0
- package/src/core/source-manager/test-harness/index.js +115 -0
- package/src/core/source-manager/test-harness/prng.js +57 -0
- package/src/core/source-manager/test-harness/start.js +232 -0
- package/src/core/source-manager/test-harness/validate.js +213 -0
- package/src/core/storage-manager/questdb/assert-columns.js +120 -0
- package/src/core/storage-manager/questdb/ensure-tables.js +187 -0
- package/src/core/storage-manager/questdb/index.js +1251 -0
- package/src/core/storage-manager/questdb/persist-plan.js +488 -0
- package/src/core/storage-manager/questdb/writers.js +142 -0
- package/src/core/test-utils/sealed-record.js +80 -0
- package/src/core/test-utils/soak-signature.js +149 -0
- package/src/core/test-utils/tcp-proxy.js +106 -0
- package/src/core/tunable/helpers.js +254 -0
- package/src/core/tunable/index.js +87 -0
- package/src/core/utils/console-formatter/index.js +207 -0
- package/src/core/utils/create-smart-store-as/index.js +98 -0
- package/src/core/utils/create-smart-store-as/sanitize-field.js +46 -0
- package/src/core/utils/create-smart-store-as/smart-truncate.js +93 -0
- package/src/core/utils/flow/index.js +5 -0
- package/src/core/utils/flow/make-collision-checker.js +23 -0
- package/src/core/utils/flow/to-kebab.js +20 -0
- package/src/core/utils/half-life/index.js +111 -0
- package/src/core/utils/node/disable.js +11 -0
- package/src/core/utils/node/enable.js +11 -0
- package/src/core/utils/node/execute-triggers.js +40 -0
- package/src/core/utils/node/index.js +10 -0
- package/src/core/utils/node/pause.js +11 -0
- package/src/core/utils/node/populate-predicate-inputs.js +14 -0
- package/src/core/utils/node/publish-nan.js +19 -0
- package/src/core/utils/node/reset-predicate-inputs.js +11 -0
- package/src/core/utils/node/unpause.js +11 -0
- package/src/core/utils/node/validate-spec.js +22 -0
- package/src/core/utils/options/resolve-field-keyed.js +115 -0
- package/src/core/utils/quantize/index.js +75 -0
- package/src/core/utils/stats/formulas.js +67 -0
- package/src/core/utils/stats/index.js +3 -0
- package/src/core/utils/validate/composer-validators.js +141 -0
- package/src/core/utils/validate/helpers.js +206 -0
- package/src/core/utils/validate/index.js +12 -0
- package/src/core/utils/validate/type-validators.js +538 -0
- package/src/core/utils/validate/validate.js +107 -0
- package/src/core/utils/validate/validators.js +177 -0
- package/src/core/wiring/assert-handle.js +57 -0
- package/src/core/wiring/assert-module.js +63 -0
- package/src/core/wiring/index.js +5 -0
- package/src/core/wiring/node-type-to-module.js +17 -0
- package/src/core/wiring/wire-emitters.js +256 -0
- package/src/core/wiring/wire-linear-graph.js +25 -0
- package/src/core/wiring/wire-node.js +157 -0
- package/src/core/wiring/wire-semantics.js +173 -0
- package/src/core/wiring/wire-storages.js +344 -0
- package/src/flow/check-output-collisions.js +93 -0
- package/src/flow/consts.js +9 -0
- package/src/flow/deep-clone-spec.js +64 -0
- package/src/flow/driver.js +171 -0
- package/src/flow/expand-single-input-array.js +76 -0
- package/src/flow/expand-template-spec.js +93 -0
- package/src/flow/flow-api-schemas.js +300 -0
- package/src/flow/flow.js +658 -0
- package/src/flow/for-each.js +225 -0
- package/src/flow/get-signature-pattern.js +31 -0
- package/src/flow/get-target-array.js +46 -0
- package/src/flow/inspect.js +67 -0
- package/src/flow/load-node-module.js +81 -0
- package/src/flow/make-node-method.js +112 -0
- package/src/flow/resolve-pick-by-field.js +77 -0
- package/src/flow/resolve-tunables.js +76 -0
- package/src/flow/run.js +392 -0
- package/src/flow/serialize.js +161 -0
- package/src/flow/signatures-schema.js +222 -0
- package/src/flow/spec-builder.js +65 -0
- package/src/flow/validate-triggers.js +250 -0
- package/src/flow/validate.js +261 -0
- package/src/nodes/accumulate/index.js +21 -0
- package/src/nodes/accumulate/init.js +48 -0
- package/src/nodes/accumulate/introspect.js +123 -0
- package/src/nodes/accumulate/publish-to.js +34 -0
- package/src/nodes/accumulate/recompute.js +27 -0
- package/src/nodes/accumulate/reset.js +25 -0
- package/src/nodes/accumulate/update.js +42 -0
- package/src/nodes/appraise/calibrate.js +64 -0
- package/src/nodes/appraise/decision.js +66 -0
- package/src/nodes/appraise/deviation.js +140 -0
- package/src/nodes/appraise/index.js +23 -0
- package/src/nodes/appraise/init.js +165 -0
- package/src/nodes/appraise/integrate.js +45 -0
- package/src/nodes/appraise/introspect.js +352 -0
- package/src/nodes/appraise/publish-to.js +93 -0
- package/src/nodes/appraise/receptor.js +69 -0
- package/src/nodes/appraise/recompute.js +79 -0
- package/src/nodes/appraise/reset.js +53 -0
- package/src/nodes/appraise/update.js +130 -0
- package/src/nodes/archive/csv/index.js +6 -0
- package/src/nodes/archive/csv/init.js +36 -0
- package/src/nodes/archive/csv/load.js +70 -0
- package/src/nodes/archive/csv/reset.js +14 -0
- package/src/nodes/archive/csv/simple-parser.js +216 -0
- package/src/nodes/archive/csv/test.js +173 -0
- package/src/nodes/archive/csv/update.js +63 -0
- package/src/nodes/butterworth-filter/index.js +18 -0
- package/src/nodes/butterworth-filter/init.js +184 -0
- package/src/nodes/butterworth-filter/introspect.js +228 -0
- package/src/nodes/butterworth-filter/publish-to.js +21 -0
- package/src/nodes/butterworth-filter/recompute.js +13 -0
- package/src/nodes/butterworth-filter/reset.js +30 -0
- package/src/nodes/butterworth-filter/update.js +38 -0
- package/src/nodes/categorize/index.js +19 -0
- package/src/nodes/categorize/init.js +58 -0
- package/src/nodes/categorize/introspect.js +177 -0
- package/src/nodes/categorize/publish-to.js +29 -0
- package/src/nodes/categorize/recompute.js +14 -0
- package/src/nodes/categorize/reset.js +16 -0
- package/src/nodes/categorize/update.js +53 -0
- package/src/nodes/controller/index.js +9 -0
- package/src/nodes/controller/init.js +55 -0
- package/src/nodes/controller/introspect.js +91 -0
- package/src/nodes/controller/publish-to.js +8 -0
- package/src/nodes/controller/recompute.js +9 -0
- package/src/nodes/controller/reset.js +17 -0
- package/src/nodes/controller/update.js +63 -0
- package/src/nodes/diff/index.js +19 -0
- package/src/nodes/diff/init.js +37 -0
- package/src/nodes/diff/introspect.js +132 -0
- package/src/nodes/diff/publish-to.js +21 -0
- package/src/nodes/diff/recompute.js +12 -0
- package/src/nodes/diff/reset.js +12 -0
- package/src/nodes/diff/update.js +37 -0
- package/src/nodes/digest-moments/formulas.js +12 -0
- package/src/nodes/digest-moments/index.js +14 -0
- package/src/nodes/digest-moments/init.js +67 -0
- package/src/nodes/digest-moments/introspect.js +154 -0
- package/src/nodes/digest-moments/publish-to.js +34 -0
- package/src/nodes/digest-moments/recompute.js +14 -0
- package/src/nodes/digest-moments/reset.js +14 -0
- package/src/nodes/digest-moments/update.js +120 -0
- package/src/nodes/dwell-time-tracker/index.js +14 -0
- package/src/nodes/dwell-time-tracker/init.js +59 -0
- package/src/nodes/dwell-time-tracker/introspect.js +137 -0
- package/src/nodes/dwell-time-tracker/publish-to.js +22 -0
- package/src/nodes/dwell-time-tracker/recompute.js +8 -0
- package/src/nodes/dwell-time-tracker/reset.js +23 -0
- package/src/nodes/dwell-time-tracker/update.js +103 -0
- package/src/nodes/emit-if/helpers.js +94 -0
- package/src/nodes/emit-if/index.js +16 -0
- package/src/nodes/emit-if/init.js +67 -0
- package/src/nodes/emit-if/introspect.js +102 -0
- package/src/nodes/emit-if/publish-to.js +13 -0
- package/src/nodes/emit-if/recompute.js +12 -0
- package/src/nodes/emit-if/reset.js +27 -0
- package/src/nodes/emit-if/update.js +93 -0
- package/src/nodes/es-correlation/index.js +19 -0
- package/src/nodes/es-correlation/init.js +73 -0
- package/src/nodes/es-correlation/introspect.js +176 -0
- package/src/nodes/es-correlation/publish-to.js +32 -0
- package/src/nodes/es-correlation/recompute.js +56 -0
- package/src/nodes/es-correlation/reset.js +27 -0
- package/src/nodes/es-correlation/update.js +110 -0
- package/src/nodes/es-mean/index.js +20 -0
- package/src/nodes/es-mean/init.js +58 -0
- package/src/nodes/es-mean/introspect.js +129 -0
- package/src/nodes/es-mean/publish-to.js +19 -0
- package/src/nodes/es-mean/recompute.js +16 -0
- package/src/nodes/es-mean/reset.js +24 -0
- package/src/nodes/es-mean/update.js +69 -0
- package/src/nodes/es-pairwise-correlation/index.js +19 -0
- package/src/nodes/es-pairwise-correlation/init.js +98 -0
- package/src/nodes/es-pairwise-correlation/introspect.js +187 -0
- package/src/nodes/es-pairwise-correlation/publish-to.js +31 -0
- package/src/nodes/es-pairwise-correlation/recompute.js +69 -0
- package/src/nodes/es-pairwise-correlation/reset.js +29 -0
- package/src/nodes/es-pairwise-correlation/update.js +89 -0
- package/src/nodes/es-stats/index.js +21 -0
- package/src/nodes/es-stats/init.js +105 -0
- package/src/nodes/es-stats/introspect.js +157 -0
- package/src/nodes/es-stats/publish-to.js +42 -0
- package/src/nodes/es-stats/recompute.js +74 -0
- package/src/nodes/es-stats/reset.js +49 -0
- package/src/nodes/es-stats/update-envelope.js +44 -0
- package/src/nodes/es-stats/update-welford.js +64 -0
- package/src/nodes/es-stats/update.js +59 -0
- package/src/nodes/index.js +83 -0
- package/src/nodes/invert-flag/index.js +20 -0
- package/src/nodes/invert-flag/init.js +36 -0
- package/src/nodes/invert-flag/introspect.js +115 -0
- package/src/nodes/invert-flag/publish-to.js +23 -0
- package/src/nodes/invert-flag/recompute.js +12 -0
- package/src/nodes/invert-flag/reset.js +12 -0
- package/src/nodes/invert-flag/update.js +32 -0
- package/src/nodes/kalman1d/index.js +20 -0
- package/src/nodes/kalman1d/init.js +103 -0
- package/src/nodes/kalman1d/introspect.js +250 -0
- package/src/nodes/kalman1d/publish-to.js +34 -0
- package/src/nodes/kalman1d/recompute.js +23 -0
- package/src/nodes/kalman1d/reset.js +29 -0
- package/src/nodes/kalman1d/update.js +144 -0
- package/src/nodes/kernel/index.js +18 -0
- package/src/nodes/kernel/init.js +66 -0
- package/src/nodes/kernel/introspect.js +163 -0
- package/src/nodes/kernel/presets.js +74 -0
- package/src/nodes/kernel/publish-to.js +25 -0
- package/src/nodes/kernel/recompute.js +14 -0
- package/src/nodes/kernel/reset.js +20 -0
- package/src/nodes/kernel/update.js +69 -0
- package/src/nodes/lag/index.js +21 -0
- package/src/nodes/lag/init.js +87 -0
- package/src/nodes/lag/introspect.js +202 -0
- package/src/nodes/lag/publish-to.js +64 -0
- package/src/nodes/lag/recompute.js +33 -0
- package/src/nodes/lag/reset.js +49 -0
- package/src/nodes/lag/update.js +133 -0
- package/src/nodes/median3/index.js +19 -0
- package/src/nodes/median3/init.js +40 -0
- package/src/nodes/median3/introspect.js +116 -0
- package/src/nodes/median3/publish-to.js +21 -0
- package/src/nodes/median3/recompute.js +12 -0
- package/src/nodes/median3/reset.js +15 -0
- package/src/nodes/median3/update.js +58 -0
- package/src/nodes/moments-digest/copy-from.js +12 -0
- package/src/nodes/moments-digest/flush.js +17 -0
- package/src/nodes/moments-digest/index.js +132 -0
- package/src/nodes/moments-digest/init.js +84 -0
- package/src/nodes/moments-digest/introspect.js +122 -0
- package/src/nodes/moments-digest/prelude.js +28 -0
- package/src/nodes/moments-digest/publish-to.js +31 -0
- package/src/nodes/moments-digest/recompute.js +9 -0
- package/src/nodes/moments-digest/reset.js +20 -0
- package/src/nodes/moments-digest/update.js +182 -0
- package/src/nodes/node-names.js +67 -0
- package/src/nodes/page-hinkley/index.js +20 -0
- package/src/nodes/page-hinkley/init.js +66 -0
- package/src/nodes/page-hinkley/introspect.js +193 -0
- package/src/nodes/page-hinkley/publish-to.js +28 -0
- package/src/nodes/page-hinkley/recompute.js +14 -0
- package/src/nodes/page-hinkley/reset.js +23 -0
- package/src/nodes/page-hinkley/update.js +105 -0
- package/src/nodes/pass-if/index.js +21 -0
- package/src/nodes/pass-if/init.js +37 -0
- package/src/nodes/pass-if/introspect.js +93 -0
- package/src/nodes/pass-if/publish-to.js +15 -0
- package/src/nodes/pass-if/recompute.js +15 -0
- package/src/nodes/pass-if/reset.js +18 -0
- package/src/nodes/pass-if/update.js +37 -0
- package/src/nodes/persist-if/helpers.js +111 -0
- package/src/nodes/persist-if/index.js +9 -0
- package/src/nodes/persist-if/init.js +98 -0
- package/src/nodes/persist-if/introspect.js +106 -0
- package/src/nodes/persist-if/publish-to.js +21 -0
- package/src/nodes/persist-if/recompute.js +20 -0
- package/src/nodes/persist-if/reset.js +35 -0
- package/src/nodes/persist-if/update.js +112 -0
- package/src/nodes/persistence-check/index.js +14 -0
- package/src/nodes/persistence-check/init.js +38 -0
- package/src/nodes/persistence-check/introspect.js +144 -0
- package/src/nodes/persistence-check/publish-to.js +11 -0
- package/src/nodes/persistence-check/recompute.js +7 -0
- package/src/nodes/persistence-check/reset.js +12 -0
- package/src/nodes/persistence-check/update.js +57 -0
- package/src/nodes/process-index/index.js +15 -0
- package/src/nodes/process-index/init.js +48 -0
- package/src/nodes/process-index/introspect.js +182 -0
- package/src/nodes/process-index/publish-to.js +29 -0
- package/src/nodes/process-index/recompute.js +8 -0
- package/src/nodes/process-index/reset.js +8 -0
- package/src/nodes/process-index/update.js +75 -0
- package/src/nodes/ratio/index.js +14 -0
- package/src/nodes/ratio/init.js +37 -0
- package/src/nodes/ratio/introspect.js +155 -0
- package/src/nodes/ratio/publish-to.js +15 -0
- package/src/nodes/ratio/recompute.js +7 -0
- package/src/nodes/ratio/reset.js +7 -0
- package/src/nodes/ratio/update.js +47 -0
- package/src/nodes/sanitize/index.js +82 -0
- package/src/nodes/sanitize/init.js +82 -0
- package/src/nodes/sanitize/introspect.js +194 -0
- package/src/nodes/sanitize/publish-to.js +15 -0
- package/src/nodes/sanitize/recompute.js +8 -0
- package/src/nodes/sanitize/reset.js +14 -0
- package/src/nodes/sanitize/update.js +102 -0
- package/src/nodes/spike-guard/index.js +14 -0
- package/src/nodes/spike-guard/init.js +47 -0
- package/src/nodes/spike-guard/introspect.js +130 -0
- package/src/nodes/spike-guard/publish-to.js +35 -0
- package/src/nodes/spike-guard/recompute.js +14 -0
- package/src/nodes/spike-guard/reset.js +19 -0
- package/src/nodes/spike-guard/update.js +89 -0
- package/src/nodes/sse-emitter/index.js +7 -0
- package/src/nodes/sse-emitter/init.js +105 -0
- package/src/nodes/sse-emitter/introspect.js +134 -0
- package/src/nodes/sse-emitter/publish-to.js +6 -0
- package/src/nodes/sse-emitter/recompute.js +16 -0
- package/src/nodes/sse-emitter/reset.js +19 -0
- package/src/nodes/sse-emitter/update.js +69 -0
- package/src/nodes/sse-emitter/utils/broadcast-heartbeat.js +36 -0
- package/src/nodes/sse-emitter/utils/build-message.js +31 -0
- package/src/nodes/sse-emitter/utils/connection-manager.js +45 -0
- package/src/nodes/sse-emitter/utils/endpoint-initializer.js +20 -0
- package/src/nodes/sse-emitter/utils/health-monitor.js +38 -0
- package/src/nodes/sse-emitter/utils/qos-handler.js +41 -0
- package/src/nodes/state-change-detector/helpers.js +35 -0
- package/src/nodes/state-change-detector/index.js +12 -0
- package/src/nodes/state-change-detector/init.js +56 -0
- package/src/nodes/state-change-detector/introspect.js +146 -0
- package/src/nodes/state-change-detector/publish-to.js +20 -0
- package/src/nodes/state-change-detector/recompute.js +6 -0
- package/src/nodes/state-change-detector/reset.js +20 -0
- package/src/nodes/state-change-detector/update.js +97 -0
- package/src/nodes/sw-stats/index.js +14 -0
- package/src/nodes/sw-stats/init.js +51 -0
- package/src/nodes/sw-stats/introspect.js +131 -0
- package/src/nodes/sw-stats/publish-to.js +45 -0
- package/src/nodes/sw-stats/recompute.js +33 -0
- package/src/nodes/sw-stats/reset.js +15 -0
- package/src/nodes/sw-stats/update.js +39 -0
- package/src/nodes/swing-watch/index.js +17 -0
- package/src/nodes/swing-watch/init.js +144 -0
- package/src/nodes/swing-watch/introspect.js +188 -0
- package/src/nodes/swing-watch/publish-to.js +53 -0
- package/src/nodes/swing-watch/recompute.js +22 -0
- package/src/nodes/swing-watch/reset.js +55 -0
- package/src/nodes/swing-watch/update.js +767 -0
- package/src/nodes/tally/index.js +15 -0
- package/src/nodes/tally/init.js +32 -0
- package/src/nodes/tally/introspect.js +116 -0
- package/src/nodes/tally/publish-to.js +28 -0
- package/src/nodes/tally/recompute.js +10 -0
- package/src/nodes/tally/reset.js +10 -0
- package/src/nodes/tally/update.js +44 -0
- package/src/nodes/threshold/index.js +14 -0
- package/src/nodes/threshold/init.js +121 -0
- package/src/nodes/threshold/introspect.js +192 -0
- package/src/nodes/threshold/publish-to.js +11 -0
- package/src/nodes/threshold/recompute.js +8 -0
- package/src/nodes/threshold/reset.js +14 -0
- package/src/nodes/threshold/update.js +54 -0
- package/src/nodes/transform/helpers.js +39 -0
- package/src/nodes/transform/index.js +15 -0
- package/src/nodes/transform/init.js +35 -0
- package/src/nodes/transform/introspect.js +118 -0
- package/src/nodes/transform/publish-to.js +23 -0
- package/src/nodes/transform/recompute.js +12 -0
- package/src/nodes/transform/reset.js +11 -0
- package/src/nodes/transform/update.js +32 -0
- package/src/nodes/trend/compute-confidence.js +112 -0
- package/src/nodes/trend/index.js +14 -0
- package/src/nodes/trend/init.js +81 -0
- package/src/nodes/trend/introspect.js +151 -0
- package/src/nodes/trend/publish-to.js +22 -0
- package/src/nodes/trend/recompute.js +15 -0
- package/src/nodes/trend/reset.js +26 -0
- package/src/nodes/trend/update.js +93 -0
- package/src/nodes/tw-stats/copy-from.js +16 -0
- package/src/nodes/tw-stats/flush.js +12 -0
- package/src/nodes/tw-stats/index.js +41 -0
- package/src/nodes/tw-stats/init.js +92 -0
- package/src/nodes/tw-stats/introspect.js +171 -0
- package/src/nodes/tw-stats/publish-to.js +108 -0
- package/src/nodes/tw-stats/recompute.js +9 -0
- package/src/nodes/tw-stats/reset.js +16 -0
- package/src/nodes/tw-stats/update.js +113 -0
- package/src/nodes/unbalance/index.js +15 -0
- package/src/nodes/unbalance/init.js +59 -0
- package/src/nodes/unbalance/introspect.js +167 -0
- package/src/nodes/unbalance/publish-to.js +52 -0
- package/src/nodes/unbalance/recompute.js +11 -0
- package/src/nodes/unbalance/reset.js +10 -0
- package/src/nodes/unbalance/update.js +83 -0
- package/src/nodes/vector-distance/index.js +14 -0
- package/src/nodes/vector-distance/init.js +54 -0
- package/src/nodes/vector-distance/introspect.js +149 -0
- package/src/nodes/vector-distance/publish-to.js +35 -0
- package/src/nodes/vector-distance/recompute.js +11 -0
- package/src/nodes/vector-distance/reset.js +20 -0
- package/src/nodes/vector-distance/update.js +139 -0
- package/src/nodes/winnow/index.js +12 -0
- package/src/nodes/winnow/init.js +82 -0
- package/src/nodes/winnow/introspect.js +253 -0
- package/src/nodes/winnow/publish-to.js +51 -0
- package/src/nodes/winnow/recompute.js +14 -0
- package/src/nodes/winnow/reset.js +34 -0
- package/src/nodes/winnow/update.js +203 -0
- package/src/tools/training/features.js +227 -0
- package/src/tools/training/index.js +21 -0
- package/src/tools/training/logistic.js +238 -0
- package/src/tools/training/metrics.js +126 -0
- package/src/tools/training/scale.js +239 -0
- package/src/tools/training/validate.js +103 -0
- package/src/windowing/count-sliding/create.js +16 -0
- package/src/windowing/count-sliding/get-reverse-chronological-index.js +19 -0
- package/src/windowing/count-sliding/index.js +6 -0
- package/src/windowing/count-sliding/is-not-full.js +5 -0
- package/src/windowing/count-sliding/push.js +15 -0
- package/src/windowing/count-sliding/reset.js +11 -0
- package/src/windowing/count-sliding/size.js +5 -0
- package/src/windowing/time-sliding/create.js +25 -0
- package/src/windowing/time-sliding/push.js +42 -0
- package/CODE_OF_CONDUCT.md +0 -46
- package/CONTRIBUTING.md +0 -132
- package/docs/.nojekyll +0 -0
- package/docs/CONTRIBUTING.md +0 -134
- package/docs/README.md +0 -132
- package/docs/_coverpage.md +0 -26
- package/docs/_media/bg.png +0 -0
- package/docs/_media/wink-logo.png +0 -0
- package/docs/_navbar.md +0 -14
- package/docs/_sidebar.md +0 -2
- package/docs/index.html +0 -44
- package/eslint.config.js +0 -283
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// src/tools/training/scale.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Feature scaling for training pipelines.
|
|
5
|
+
*
|
|
6
|
+
* Three methods, each with a compute → scale pair:
|
|
7
|
+
* computeStandardParams — Welford's single-pass mean/std (Welford, 1962)
|
|
8
|
+
* computeMinMaxParams — single-pass min/max per feature
|
|
9
|
+
* computeRobustParams — median and IQR per feature
|
|
10
|
+
*
|
|
11
|
+
* scale() is the unified dispatcher — reads params.method to apply the
|
|
12
|
+
* matching transform. Returns a new matrix (no mutation).
|
|
13
|
+
*
|
|
14
|
+
* Zero-variance / zero-range / zero-IQR features are flagged via isConstant
|
|
15
|
+
* and their divisor is clamped to 1, producing 0 after centering.
|
|
16
|
+
*
|
|
17
|
+
* Reference:
|
|
18
|
+
* Welford, B. P. (1962). Note on a Method for Calculating Corrected Sums
|
|
19
|
+
* of Squares and Products. Technometrics, 4(3), 419–420.
|
|
20
|
+
*
|
|
21
|
+
* The batch Welford variant uses the same delta/delta2 pattern as
|
|
22
|
+
* composer's esStats node (src/nodes/es-stats/update-welford.js),
|
|
23
|
+
* without exponential weighting.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { validateMatrix } from './validate.js';
|
|
27
|
+
|
|
28
|
+
// ── Standard (Welford) ──────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Compute per-feature mean and standard deviation using Welford's
|
|
32
|
+
* single-pass algorithm for numerical stability.
|
|
33
|
+
*
|
|
34
|
+
* @param {number[][]} X — Training matrix, one row per sample.
|
|
35
|
+
* @returns {{ method: string, mean: Float64Array, std: Float64Array, isConstant: Uint8Array }}
|
|
36
|
+
*/
|
|
37
|
+
const computeStandardParams = function ( X ) {
|
|
38
|
+
const { n, p } = validateMatrix( X, 'computeStandardParams' );
|
|
39
|
+
|
|
40
|
+
const mean = new Float64Array( p );
|
|
41
|
+
const m2 = new Float64Array( p );
|
|
42
|
+
const std = new Float64Array( p );
|
|
43
|
+
const isConstant = new Uint8Array( p );
|
|
44
|
+
|
|
45
|
+
// Welford batch variant (Welford, 1962):
|
|
46
|
+
// Single pass — accumulates mean and sum-of-squared-deviations (m2).
|
|
47
|
+
for ( let i = 0; i < n; i += 1 ) {
|
|
48
|
+
const row = X[ i ];
|
|
49
|
+
const count = i + 1;
|
|
50
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
51
|
+
const delta = row[ j ] - mean[ j ];
|
|
52
|
+
mean[ j ] += delta / count;
|
|
53
|
+
const delta2 = row[ j ] - mean[ j ];
|
|
54
|
+
m2[ j ] += delta * delta2;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
59
|
+
const variance = m2[ j ] / n;
|
|
60
|
+
if ( variance < 1e-24 ) {
|
|
61
|
+
std[ j ] = 1;
|
|
62
|
+
isConstant[ j ] = 1;
|
|
63
|
+
} else {
|
|
64
|
+
std[ j ] = Math.sqrt( variance );
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { method: 'standard', mean: mean, std: std, isConstant: isConstant };
|
|
69
|
+
}; // computeStandardParams()
|
|
70
|
+
|
|
71
|
+
// ── MinMax ───────────────────────────────────────────────────────
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Compute per-feature min and range (max − min) in a single pass.
|
|
75
|
+
*
|
|
76
|
+
* @param {number[][]} X — Training matrix, one row per sample.
|
|
77
|
+
* @returns {{ method: string, min: Float64Array, range: Float64Array, isConstant: Uint8Array }}
|
|
78
|
+
*/
|
|
79
|
+
const computeMinMaxParams = function ( X ) {
|
|
80
|
+
const { n, p } = validateMatrix( X, 'computeMinMaxParams' );
|
|
81
|
+
|
|
82
|
+
const min = new Float64Array( p );
|
|
83
|
+
const max = new Float64Array( p );
|
|
84
|
+
const range = new Float64Array( p );
|
|
85
|
+
const isConstant = new Uint8Array( p );
|
|
86
|
+
|
|
87
|
+
// Initialise from first row.
|
|
88
|
+
const first = X[ 0 ];
|
|
89
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
90
|
+
min[ j ] = first[ j ];
|
|
91
|
+
max[ j ] = first[ j ];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for ( let i = 1; i < n; i += 1 ) {
|
|
95
|
+
const row = X[ i ];
|
|
96
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
97
|
+
if ( row[ j ] < min[ j ] ) min[ j ] = row[ j ];
|
|
98
|
+
if ( row[ j ] > max[ j ] ) max[ j ] = row[ j ];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
103
|
+
range[ j ] = max[ j ] - min[ j ];
|
|
104
|
+
if ( range[ j ] < 1e-24 ) {
|
|
105
|
+
range[ j ] = 1;
|
|
106
|
+
isConstant[ j ] = 1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { method: 'minMax', min: min, range: range, isConstant: isConstant };
|
|
111
|
+
}; // computeMinMaxParams()
|
|
112
|
+
|
|
113
|
+
// ── Robust (median / IQR) ────────────────────────────────────────
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Linear interpolation percentile on a pre-sorted array.
|
|
117
|
+
*
|
|
118
|
+
* @param {Float64Array} sorted — Sorted values.
|
|
119
|
+
* @param {number} q — Quantile in [0, 1].
|
|
120
|
+
* @returns {number} Interpolated percentile value.
|
|
121
|
+
*/
|
|
122
|
+
const percentile = function ( sorted, q ) {
|
|
123
|
+
const pos = q * ( sorted.length - 1 );
|
|
124
|
+
const lo = Math.floor( pos );
|
|
125
|
+
const hi = Math.ceil( pos );
|
|
126
|
+
if ( lo === hi ) return sorted[ lo ];
|
|
127
|
+
const frac = pos - lo;
|
|
128
|
+
return ( sorted[ lo ] * ( 1 - frac ) ) + ( sorted[ hi ] * frac );
|
|
129
|
+
}; // percentile()
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Compute per-feature median and IQR. Copies each column and sorts
|
|
133
|
+
* to find percentiles — O(n log n) per feature.
|
|
134
|
+
*
|
|
135
|
+
* @param {number[][]} X — Training matrix, one row per sample.
|
|
136
|
+
* @returns {{ method: string, median: Float64Array, iqr: Float64Array, isConstant: Uint8Array }}
|
|
137
|
+
*/
|
|
138
|
+
const computeRobustParams = function ( X ) {
|
|
139
|
+
const { n, p } = validateMatrix( X, 'computeRobustParams' );
|
|
140
|
+
|
|
141
|
+
const median = new Float64Array( p );
|
|
142
|
+
const iqr = new Float64Array( p );
|
|
143
|
+
const isConstant = new Uint8Array( p );
|
|
144
|
+
|
|
145
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
146
|
+
// Extract and sort column j.
|
|
147
|
+
const col = new Float64Array( n );
|
|
148
|
+
for ( let i = 0; i < n; i += 1 ) {
|
|
149
|
+
col[ i ] = X[ i ][ j ];
|
|
150
|
+
}
|
|
151
|
+
col.sort();
|
|
152
|
+
|
|
153
|
+
median[ j ] = percentile( col, 0.50 );
|
|
154
|
+
const q1 = percentile( col, 0.25 );
|
|
155
|
+
const q3 = percentile( col, 0.75 );
|
|
156
|
+
iqr[ j ] = q3 - q1;
|
|
157
|
+
|
|
158
|
+
if ( iqr[ j ] < 1e-24 ) {
|
|
159
|
+
iqr[ j ] = 1;
|
|
160
|
+
isConstant[ j ] = 1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return { method: 'robust', median: median, iqr: iqr, isConstant: isConstant };
|
|
165
|
+
}; // computeRobustParams()
|
|
166
|
+
|
|
167
|
+
// ── Unified dispatcher ───────────────────────────────────────────
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Scale a matrix using pre-computed parameters.
|
|
171
|
+
* Reads params.method to determine the transform.
|
|
172
|
+
* Returns a new matrix — the input is never mutated.
|
|
173
|
+
*
|
|
174
|
+
* @param {number[][]} X — Matrix to scale.
|
|
175
|
+
* @param {object} params — From any compute*Params function.
|
|
176
|
+
* @returns {number[][]} Scaled copy.
|
|
177
|
+
*/
|
|
178
|
+
const scale = function ( X, params ) {
|
|
179
|
+
if ( !Array.isArray( X ) || X.length === 0 ) {
|
|
180
|
+
throw new Error( 'scale: X must be a non-empty array of rows.' );
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const n = X.length;
|
|
184
|
+
const method = params.method;
|
|
185
|
+
const result = new Array( n );
|
|
186
|
+
|
|
187
|
+
if ( method === 'standard' ) {
|
|
188
|
+
const mean = params.mean;
|
|
189
|
+
const std = params.std;
|
|
190
|
+
const p = mean.length;
|
|
191
|
+
for ( let i = 0; i < n; i += 1 ) {
|
|
192
|
+
const row = X[ i ];
|
|
193
|
+
const out = new Array( p );
|
|
194
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
195
|
+
out[ j ] = ( row[ j ] - mean[ j ] ) / std[ j ];
|
|
196
|
+
}
|
|
197
|
+
result[ i ] = out;
|
|
198
|
+
}
|
|
199
|
+
} else if ( method === 'minMax' ) {
|
|
200
|
+
const min = params.min;
|
|
201
|
+
const range = params.range;
|
|
202
|
+
const p = min.length;
|
|
203
|
+
for ( let i = 0; i < n; i += 1 ) {
|
|
204
|
+
const row = X[ i ];
|
|
205
|
+
const out = new Array( p );
|
|
206
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
207
|
+
out[ j ] = ( row[ j ] - min[ j ] ) / range[ j ];
|
|
208
|
+
}
|
|
209
|
+
result[ i ] = out;
|
|
210
|
+
}
|
|
211
|
+
} else if ( method === 'robust' ) {
|
|
212
|
+
const med = params.median;
|
|
213
|
+
const iq = params.iqr;
|
|
214
|
+
const p = med.length;
|
|
215
|
+
for ( let i = 0; i < n; i += 1 ) {
|
|
216
|
+
const row = X[ i ];
|
|
217
|
+
const out = new Array( p );
|
|
218
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
219
|
+
out[ j ] = ( row[ j ] - med[ j ] ) / iq[ j ];
|
|
220
|
+
}
|
|
221
|
+
result[ i ] = out;
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
throw new Error( 'scale: unknown method "' + method + '".' );
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return result;
|
|
228
|
+
}; // scale()
|
|
229
|
+
|
|
230
|
+
// Backward compatibility: `standardize` is an alias for `scale`.
|
|
231
|
+
const standardize = scale;
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
computeStandardParams,
|
|
235
|
+
computeMinMaxParams,
|
|
236
|
+
computeRobustParams,
|
|
237
|
+
scale,
|
|
238
|
+
standardize
|
|
239
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// src/tools/training/validate.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Shared input validation for training utilities.
|
|
5
|
+
*
|
|
6
|
+
* Three validators cover the common patterns:
|
|
7
|
+
* validateMatrix() — feature matrices (non-empty, rectangular, finite)
|
|
8
|
+
* validateBinaryLabels() — label vectors (length match, values 0 or 1)
|
|
9
|
+
* validateBinaryArray() — any binary array (predictions, labels in metrics)
|
|
10
|
+
*
|
|
11
|
+
* Each throws immediately with a descriptive message including the caller name.
|
|
12
|
+
* Finite-value checks reuse the `isFinite` predicate from composer's core
|
|
13
|
+
* validation module to keep primitive validation logic uniform.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { validators } from '../../core/utils/validate/validators.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Validate that X is a non-empty rectangular matrix of finite numbers.
|
|
20
|
+
*
|
|
21
|
+
* @param {number[][]} X — Feature matrix (n × p).
|
|
22
|
+
* @param {string} caller — Name of the calling function (for error messages).
|
|
23
|
+
* @returns {{ n: number, p: number }} Matrix dimensions.
|
|
24
|
+
*/
|
|
25
|
+
const validateMatrix = function ( X, caller ) {
|
|
26
|
+
if ( !Array.isArray( X ) || X.length === 0 ) {
|
|
27
|
+
throw new Error( caller + ': X must be a non-empty array of rows.' );
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const n = X.length;
|
|
31
|
+
const p = X[ 0 ].length;
|
|
32
|
+
|
|
33
|
+
if ( p === 0 ) {
|
|
34
|
+
throw new Error( caller + ': rows must have at least one feature.' );
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for ( let i = 0; i < n; i += 1 ) {
|
|
38
|
+
const row = X[ i ];
|
|
39
|
+
if ( !Array.isArray( row ) || row.length !== p ) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
caller + ': row ' + i + ' has length ' +
|
|
42
|
+
( Array.isArray( row ) ? row.length : 'N/A' ) +
|
|
43
|
+
', expected ' + p + '.'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
for ( let j = 0; j < p; j += 1 ) {
|
|
47
|
+
if ( !validators.isFinite( row[ j ] ) ) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
caller + ': non-finite value at row ' + i +
|
|
50
|
+
', column ' + j + '.'
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { n: n, p: p };
|
|
57
|
+
}; // validateMatrix()
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Validate that y is an array of binary labels (exactly 0 or 1)
|
|
61
|
+
* with the expected length.
|
|
62
|
+
*
|
|
63
|
+
* @param {number[]} y — Label vector.
|
|
64
|
+
* @param {number} n — Expected length (from the matrix).
|
|
65
|
+
* @param {string} caller — Name of the calling function.
|
|
66
|
+
*/
|
|
67
|
+
const validateBinaryLabels = function ( y, n, caller ) {
|
|
68
|
+
if ( !Array.isArray( y ) || y.length !== n ) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
caller + ': y must be an array with length ' + n +
|
|
71
|
+
', got ' + ( Array.isArray( y ) ? y.length : typeof y ) + '.'
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
for ( let i = 0; i < n; i += 1 ) {
|
|
76
|
+
if ( y[ i ] !== 0 && y[ i ] !== 1 ) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
caller + ': y[' + i + '] = ' + y[ i ] +
|
|
79
|
+
', expected 0 or 1.'
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}; // validateBinaryLabels()
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Validate that an array-like contains only 0 or 1 values.
|
|
87
|
+
*
|
|
88
|
+
* @param {ArrayLike<number>} arr — Array to check.
|
|
89
|
+
* @param {string} name — Parameter name (for error messages).
|
|
90
|
+
* @param {string} caller — Name of the calling function.
|
|
91
|
+
*/
|
|
92
|
+
const validateBinaryArray = function ( arr, name, caller ) {
|
|
93
|
+
for ( let i = 0; i < arr.length; i += 1 ) {
|
|
94
|
+
if ( arr[ i ] !== 0 && arr[ i ] !== 1 ) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
caller + ': ' + name + '[' + i + '] = ' + arr[ i ] +
|
|
97
|
+
', expected 0 or 1.'
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}; // validateBinaryArray()
|
|
102
|
+
|
|
103
|
+
export { validateMatrix, validateBinaryLabels, validateBinaryArray };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const create = function ( size ) {
|
|
2
|
+
const state = Object.create( null );
|
|
3
|
+
|
|
4
|
+
state.size = size;
|
|
5
|
+
state.buffer = new Float64Array( state.size );
|
|
6
|
+
// Explicitly initialize to `0`.
|
|
7
|
+
state.buffer.fill( 0 );
|
|
8
|
+
// Next index to write into `[ 0..size-1 ]`.
|
|
9
|
+
state.head = 0;
|
|
10
|
+
// Number of slots currently occupied (≤ size).
|
|
11
|
+
state.used = 0;
|
|
12
|
+
|
|
13
|
+
return state;
|
|
14
|
+
}; // create()
|
|
15
|
+
|
|
16
|
+
export default create;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const getReverseChronologicalIndex = function (state, position) {
|
|
2
|
+
// Validate position
|
|
3
|
+
if (position < 0 || position >= state.used) return -1;
|
|
4
|
+
|
|
5
|
+
// Calculate buffer index based on fill status
|
|
6
|
+
if (state.used === state.size) {
|
|
7
|
+
// Buffer full: head points to oldest, newest is at (head - 1)
|
|
8
|
+
let index = state.head - 1 - position;
|
|
9
|
+
// Handle wrap-around
|
|
10
|
+
if (index < 0) index += state.size;
|
|
11
|
+
return index;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Buffer partial: newest is at (used - 1), oldest at 0
|
|
15
|
+
return state.used - 1 - position;
|
|
16
|
+
|
|
17
|
+
}; // getReverseChronologicalIndex()
|
|
18
|
+
|
|
19
|
+
export default getReverseChronologicalIndex;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const push = function ( state, value ) {
|
|
2
|
+
// If buffer not yet full, return `undefined`; else return the overwritten slot.
|
|
3
|
+
const evicted = ( state.used < state.size ) ? undefined : state.buffer[ state.head ];
|
|
4
|
+
// Overwrite at head index.
|
|
5
|
+
state.buffer[ state.head ] = value;
|
|
6
|
+
// Advance head, wrapping around; modulus is slower i.e. `head = ( head + 1 ) % size`.
|
|
7
|
+
state.head += 1;
|
|
8
|
+
if ( state.head === state.size ) state.head = 0;
|
|
9
|
+
// Track occupancy until full.
|
|
10
|
+
if ( state.used < state.size ) state.used += 1;
|
|
11
|
+
|
|
12
|
+
return evicted;
|
|
13
|
+
}; // push()
|
|
14
|
+
|
|
15
|
+
export default push;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const create = function ( spec ) {
|
|
2
|
+
const state = Object.create( null );
|
|
3
|
+
|
|
4
|
+
state.duration = spec.duration;
|
|
5
|
+
state.size = spec.maxSize || 8192;
|
|
6
|
+
|
|
7
|
+
// Ring buffer storage
|
|
8
|
+
state.timestamps = new Float64Array( state.size );
|
|
9
|
+
state.values = new Float64Array( state.size );
|
|
10
|
+
state.head = 0;
|
|
11
|
+
state.tail = 0;
|
|
12
|
+
state.count = 0;
|
|
13
|
+
|
|
14
|
+
// Time extraction
|
|
15
|
+
if ( spec.timeStrategy === 'eventTime' ) {
|
|
16
|
+
const field = spec.timeField || 'timestamp';
|
|
17
|
+
state.getTime = ( msg ) => msg[ field ];
|
|
18
|
+
} else {
|
|
19
|
+
state.getTime = () => Date.now();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return state;
|
|
23
|
+
}; // create()
|
|
24
|
+
|
|
25
|
+
export default create;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const push = function ( state, value, msg ) {
|
|
2
|
+
const timestamp = state.getTime( msg );
|
|
3
|
+
const cutoff = timestamp - state.duration;
|
|
4
|
+
|
|
5
|
+
const evicted = [];
|
|
6
|
+
|
|
7
|
+
// Evict values outside [cutoff, timestamp)
|
|
8
|
+
while ( state.count > 0 && state.timestamps[ state.tail ] < cutoff ) {
|
|
9
|
+
evicted.push({
|
|
10
|
+
timestamp: state.timestamps[ state.tail ],
|
|
11
|
+
value: state.values[ state.tail ]
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
state.tail += 1;
|
|
15
|
+
if ( state.tail >= state.size ) state.tail = 0;
|
|
16
|
+
state.count -= 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Add new value
|
|
20
|
+
state.timestamps[ state.head ] = timestamp;
|
|
21
|
+
state.values[ state.head ] = value;
|
|
22
|
+
|
|
23
|
+
state.head += 1;
|
|
24
|
+
if ( state.head >= state.size ) state.head = 0;
|
|
25
|
+
state.count += 1;
|
|
26
|
+
|
|
27
|
+
// Handle overflow
|
|
28
|
+
if ( state.count > state.size ) {
|
|
29
|
+
evicted.push({
|
|
30
|
+
timestamp: state.timestamps[ state.tail ],
|
|
31
|
+
value: state.values[ state.tail ]
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
state.tail += 1;
|
|
35
|
+
if ( state.tail >= state.size ) state.tail = 0;
|
|
36
|
+
state.count = state.size;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return evicted;
|
|
40
|
+
}; // push()
|
|
41
|
+
|
|
42
|
+
export default push;
|
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
-
|
|
7
|
-
## Our Standards
|
|
8
|
-
|
|
9
|
-
Examples of behavior that contributes to creating a positive environment include:
|
|
10
|
-
|
|
11
|
-
* Using welcoming and inclusive language
|
|
12
|
-
* Being respectful of differing viewpoints and experiences
|
|
13
|
-
* Gracefully accepting constructive criticism
|
|
14
|
-
* Focusing on what is best for the community
|
|
15
|
-
* Showing empathy towards other community members
|
|
16
|
-
|
|
17
|
-
Examples of unacceptable behavior by participants include:
|
|
18
|
-
|
|
19
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
|
20
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
21
|
-
* Public or private harassment
|
|
22
|
-
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
|
23
|
-
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
24
|
-
|
|
25
|
-
## Our Responsibilities
|
|
26
|
-
|
|
27
|
-
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
|
28
|
-
|
|
29
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
-
|
|
31
|
-
## Scope
|
|
32
|
-
|
|
33
|
-
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
|
34
|
-
|
|
35
|
-
## Enforcement
|
|
36
|
-
|
|
37
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ContactUs@graype.in. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
|
38
|
-
|
|
39
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
|
40
|
-
|
|
41
|
-
## Attribution
|
|
42
|
-
|
|
43
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
|
44
|
-
|
|
45
|
-
[homepage]: http://contributor-covenant.org
|
|
46
|
-
[version]: http://contributor-covenant.org/version/1/4/
|