File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,27 @@ export default class ScriptStd {
131131 return ts
132132 }
133133
134+ /**
135+ * Creates a new custom sampler.
136+ * Return the an array. Id is auto-genrated
137+ * @param {* } x - A variable to sample from
138+ * @param {string } type - Sampler type
139+ * @param {(number|string) } tf - Timeframe in ms or as a string
140+ * @return {TS } - New time-series
141+ */
142+ sample ( x , type , tf , _id ) {
143+ let ts = this . env . tss [ _id ]
144+ if ( ! ts ) {
145+ ts = this . env . tss [ _id ] = [ x ]
146+ ts . __id__ = _id
147+ ts . __tf__ = u . tf_from_str ( tf )
148+ ts . __fn__ = Sampler ( type ) . bind ( ts )
149+ } else {
150+ ts . __fn__ ( x )
151+ }
152+ return ts
153+ }
154+
134155 /**
135156 * Replaces the variable if it's NaN
136157 * @param {* } x - The variable
You can’t perform that action at this time.
0 commit comments