| 
						
						
						
					 | 
					@ -1,49 +1,75 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					'use strict'; | 
					 | 
					 | 
					'use strict'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					/** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					 * SelectValue - Wraps and pairs an arbitrary value with a reducer. | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					 * @class SelectValue | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					 * @param {any} value                An arbitrary value to store within. | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					 * @param {(Function|null)} resolve  The reducer. | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					 */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					class SelectValue { | 
					 | 
					 | 
					class SelectValue { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						constructor(value, resolve) { | 
					 | 
					 | 
						constructor(value, resolve = null) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
							this.value = value; | 
					 | 
					 | 
							this.value = value; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							if (resolve) this.resolve = resolve; | 
					 | 
					 | 
							if (resolve !== null) this.resolve = resolve; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					SelectValue.prototype.resolve = () => null; | 
					 | 
					 | 
					SelectValue.prototype.resolve = () => null; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					class SelectIterable { | 
					 | 
					 | 
					class SelectIterable { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						constructor(values, tests) { | 
					 | 
					 | 
						constructor(values, conditionals) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
							this.values = values | 
					 | 
					 | 
							this.values = values.map(value => value instanceof SelectValue ? value : new SelectValue(value)); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
								.map(x => x instanceof SelectValue | 
					 | 
					 | 
							this.conditionals = conditionals; | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
									? x | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									: new SelectValue(x) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							this.tests = tests; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					
 | 
					 | 
					 | 
						for(predicate, consequent) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						for(test, consequent) { | 
					 | 
					 | 
							return new SelectIterable(this.values, [...this.conditionals, { predicate, consequent }]); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
							const self = this; | 
					 | 
					 | 
						} | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
							return new SelectIterable( | 
					 | 
					 | 
						forField(...pairs) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
								self.values, | 
					 | 
					 | 
							var pair; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
								[ ...self.tests, { test, consequent } ] | 
					 | 
					 | 
							var callback; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
							); | 
					 | 
					 | 
							var even; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							for ( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								// beforeBegin:
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								var loc = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								// beforeEvery:
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								even = loc % 2 === 0, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								// breakPredicate:
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								loc < pairs.length; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								// afterEvery:
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								loc++ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								pair = this.conditionals[this.conditionals.length]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								if (pair.length === 2) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
									this.conditionals.push({}); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								}; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								callback = conditionals[loc]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								if (typeof callback === "object") { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
									if (Array.isArray(callback)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
										pair.predicate = callback[0]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
										pair.consequent = callback[0]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
									} else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
										Object.assign(pair, { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
											predicate: callback.predicate, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
											consequent: callback.consequent | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
										}); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
									} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
									continue; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								if (even) pair.predicate = callback; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								if (!even) pair.consequent = callback; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							return new SelectIterable(this.values, [...this.conditionals, ...conditionals]); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						subsetOf(value, consequent) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							return this.for(this.value.every(element => element in this.value)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					/* eslint-disable-next-line func-names */ | 
					 | 
					 | 
					/* eslint-disable-next-line func-names */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					SelectIterable.prototype.resolve = function (...args) { | 
					 | 
					 | 
					SelectIterable.prototype.resolve = function (...args) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						const self = this; | 
					 | 
					 | 
						return this.values.map(item => { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						return self.values.map(item => { | 
					 | 
					 | 
							const resolve = this.conditionals.find(tuple => tuple.predicate(item.value) ? tuple.consequent : null); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
							const resolve = self | 
					 | 
					 | 
							return resolve ? resolve.consequent(...args, this.value) : () => null; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
								.tests | 
					 | 
					 | 
						}, this); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
								/* eslint-disable-next-line */ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								.find(x => { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									return x.test(item.value) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
										? x.consequent | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
										: null; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								}); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							return resolve | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								? resolve.consequent(...args, self.value) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								: () => null; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						}); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					}; | 
					 | 
					 | 
					}; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					class Select extends SelectValue { | 
					 | 
					 | 
					class Select extends SelectValue { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -51,17 +77,16 @@ class Select extends SelectValue { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							super(value, resolve); | 
					 | 
					 | 
							super(value, resolve); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							this.iterable = typeof value === "object" && Symbol.iterator in value; | 
					 | 
					 | 
							this.iterable = typeof value === "object" && Symbol.iterator in value; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					
 | 
					 | 
					 | 
						for(predicate, consequent) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
						for(test, consequent) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
							if (this.iterable) { | 
					 | 
					 | 
							if (this.iterable) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
								return new SelectIterable( | 
					 | 
					 | 
								return new SelectIterable(Array.from(this.value), [{ predicate, consequent }]); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
									Array.from(this.value), | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									[ { test, consequent } ], | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
							} | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							if (test(this.value)) return new Select(this.value, consequent); | 
					 | 
					 | 
							if (predicate(this.value)) return new Select(this.value, consequent); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
							return this; | 
					 | 
					 | 
							return this; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						is(value, consequent) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							return this.for(value === this.value, consequent); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					module.exports = Select; | 
					 | 
					 | 
					module.exports = Select; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					
  |