index.js (1532B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 /** 22 * Iterator symbol. 23 * 24 * @module @stdlib/symbol/iterator 25 * 26 * @example 27 * var IteratorSymbol = require( '@stdlib/symbol/iterator' ); 28 * 29 * function iterator() { 30 * var it; 31 * var i; 32 * 33 * i = -1; 34 * 35 * it = {}; 36 * it.next = next; 37 * it.return = done; 38 * 39 * if ( IteratorSymbol ) { 40 * it[ IteratorSymbol ] = iterator; 41 * } 42 * return it; 43 * 44 * function next() { 45 * i += 1; 46 * return { 47 * 'value': i, 48 * 'done': false 49 * }; 50 * } 51 * 52 * function done( value ) { 53 * if ( arguments.length === 0 ) { 54 * return { 55 * 'done': true 56 * }; 57 * } 58 * return { 59 * 'value': value, 60 * 'done': true 61 * }; 62 * } 63 * } 64 * 65 * var obj = iterator(); 66 */ 67 68 // MAIN // 69 70 var IteratorSymbol = require( './main.js' ); 71 72 73 // EXPORTS // 74 75 module.exports = IteratorSymbol;