(...args: any[])
| 42 | } |
| 43 | |
| 44 | export function sample(...args: any[]) { |
| 45 | let target |
| 46 | let name |
| 47 | let [[source, clock, fn], metadata] = processArgsToConfig(args) |
| 48 | let sid |
| 49 | let batch = true |
| 50 | let filter |
| 51 | const errorTitle = generateErrorTitle('sample', metadata) |
| 52 | /** config case */ |
| 53 | if ( |
| 54 | isVoid(clock) && |
| 55 | isObject(source) && |
| 56 | validateSampleConfig(source, errorTitle) |
| 57 | ) { |
| 58 | clock = source.clock |
| 59 | fn = source.fn |
| 60 | if ('batch' in source) { |
| 61 | batch = source.batch |
| 62 | } else { |
| 63 | deprecate(!('greedy' in source), 'greedy in sample', 'batch', errorTitle) |
| 64 | batch = !source.greedy |
| 65 | } |
| 66 | filter = source.filter |
| 67 | /** optional target & name accepted only from config */ |
| 68 | target = source.target |
| 69 | name = source.name |
| 70 | sid = source.sid |
| 71 | source = source.source |
| 72 | } |
| 73 | return createSampling( |
| 74 | 'sample', |
| 75 | clock, |
| 76 | source, |
| 77 | filter, |
| 78 | target, |
| 79 | fn, |
| 80 | name, |
| 81 | metadata, |
| 82 | batch, |
| 83 | true, |
| 84 | false, |
| 85 | sid, |
| 86 | ) |
| 87 | } |
| 88 | |
| 89 | export const createSampling = ( |
| 90 | method: string, |
searching dependent graphs…