+158
| var test = require('tape'); | ||
| var forEach = require('./index.js'); | ||
| test('first argument: iterable', function (t) { | ||
| var iterator = function () {}; | ||
| t.throws(function () { forEach(undefined, iterator); }, TypeError, 'undefined is not iterable'); | ||
| t.throws(function () { forEach(null, iterator); }, TypeError, 'null is not iterable'); | ||
| t.throws(function () { forEach(true, iterator); }, TypeError, 'true is not iterable'); | ||
| t.throws(function () { forEach(false, iterator); }, TypeError, 'false is not iterable'); | ||
| t.throws(function () { forEach(NaN, iterator); }, TypeError, 'NaN is not iterable'); | ||
| t.throws(function () { forEach(42, iterator); }, TypeError, '42 is not iterable'); | ||
| t.doesNotThrow(function () { forEach('', iterator); }, TypeError, 'string is iterable'); | ||
| t.doesNotThrow(function () { forEach([], iterator); }, TypeError, 'array is iterable'); | ||
| t.doesNotThrow(function () { forEach({}, iterator); }, TypeError, 'object is iterable'); | ||
| t.doesNotThrow(function () { forEach(new Date(), iterator); }, TypeError, 'object subtype is iterable'); | ||
| t.end(); | ||
| }); | ||
| test('second argument: iterator', function (t) { | ||
| var arr = []; | ||
| t.throws(function () { forEach(arr); }, TypeError, 'undefined is not a function'); | ||
| t.throws(function () { forEach(arr, null); }, TypeError, 'null is not a function'); | ||
| t.throws(function () { forEach(arr, ''); }, TypeError, 'string is not a function'); | ||
| t.throws(function () { forEach(arr, /a/); }, TypeError, 'regex is not a function'); | ||
| t.throws(function () { forEach(arr, true); }, TypeError, 'true is not a function'); | ||
| t.throws(function () { forEach(arr, false); }, TypeError, 'false is not a function'); | ||
| t.throws(function () { forEach(arr, NaN); }, TypeError, 'NaN is not a function'); | ||
| t.throws(function () { forEach(arr, 42); }, TypeError, '42 is not a function'); | ||
| t.doesNotThrow(function () { forEach(arr, function () {}); }, 'function is a function'); | ||
| t.end(); | ||
| }); | ||
| test('array', function (t) { | ||
| var arr = [1, 2, 3]; | ||
| t.test('iterates over every item', function (st) { | ||
| var index = 0; | ||
| forEach(arr, function () { index += 1; }); | ||
| st.equal(index, arr.length, 'iterates ' + arr.length + ' times'); | ||
| st.end(); | ||
| }); | ||
| t.test('first iterator argument', function (st) { | ||
| var index = 0; | ||
| st.plan(arr.length); | ||
| forEach(arr, function (item) { | ||
| st.equal(arr[index], item, 'item ' + index + ' is passed as first argument'); | ||
| index += 1; | ||
| }); | ||
| }); | ||
| t.test('second iterator argument', function (st) { | ||
| var counter = 0; | ||
| st.plan(arr.length); | ||
| forEach(arr, function (item, index) { | ||
| st.equal(counter, index, 'index ' + index + ' is passed as second argument'); | ||
| counter += 1; | ||
| }); | ||
| }); | ||
| t.test('third iterator argument', function (st) { | ||
| st.plan(arr.length); | ||
| forEach(arr, function (item, index, array) { | ||
| st.deepEqual(arr, array, 'array is passed as third argument'); | ||
| }); | ||
| }); | ||
| t.test('context argument', function (st) { | ||
| var context = {}; | ||
| forEach([], function () { | ||
| st.equal(this, context, '"this" is the passed context'); | ||
| }, context); | ||
| st.end(); | ||
| }); | ||
| t.end(); | ||
| }); | ||
| test('object', function (t) { | ||
| var obj = { | ||
| a: 1, | ||
| b: 2, | ||
| c: 3 | ||
| }; | ||
| var keys = ['a', 'b', 'c']; | ||
| var F = function () { | ||
| this.a = 1; | ||
| this.b = 2; | ||
| }; | ||
| F.prototype.c = 3; | ||
| var fKeys = ['a', 'b']; | ||
| t.test('iterates over every object literal key', function (st) { | ||
| var counter = 0; | ||
| forEach(obj, function () { counter += 1; }); | ||
| st.equal(counter, keys.length, 'iterated ' + counter + ' times'); | ||
| st.end(); | ||
| }); | ||
| t.test('iterates only over own keys', function (st) { | ||
| var counter = 0; | ||
| forEach(new F(), function () { counter += 1; }); | ||
| st.equal(counter, fKeys.length, 'iterated ' + fKeys.length + ' times'); | ||
| st.end(); | ||
| }); | ||
| t.test('first iterator argument', function (st) { | ||
| var index = 0; | ||
| st.plan(keys.length); | ||
| forEach(obj, function (item) { | ||
| st.equal(obj[keys[index]], item, 'item at key ' + keys[index] + ' is passed as first argument'); | ||
| index += 1; | ||
| }); | ||
| }); | ||
| t.test('second iterator argument', function (st) { | ||
| var counter = 0; | ||
| st.plan(keys.length); | ||
| forEach(obj, function (item, key) { | ||
| st.equal(keys[counter], key, 'key ' + key + ' is passed as second argument'); | ||
| counter += 1; | ||
| }); | ||
| }); | ||
| t.test('third iterator argument', function (st) { | ||
| st.plan(keys.length); | ||
| forEach(obj, function (item, key, object) { | ||
| st.deepEqual(obj, object, 'object is passed as third argument'); | ||
| }); | ||
| }); | ||
| t.test('context argument', function (st) { | ||
| var context = {}; | ||
| forEach({}, function () { | ||
| st.equal(this, context, '"this" is the passed context'); | ||
| }, context); | ||
| st.end(); | ||
| }); | ||
| t.end(); | ||
| }); | ||
| test('string', function (t) { | ||
| var str = 'str'; | ||
| t.test('second iterator argument', function (st) { | ||
| var counter = 0; | ||
| st.plan(str.length * 2 + 1); | ||
| forEach(str, function (item, index) { | ||
| st.equal(counter, index, 'index ' + index + ' is passed as second argument'); | ||
| st.equal(str[index], item); | ||
| counter += 1; | ||
| }); | ||
| st.equal(counter, str.length, 'iterates ' + str.length + ' times'); | ||
| }); | ||
| t.end(); | ||
| }); |
+248
-51
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="ChangeListManager"> | ||
| <list default="true" id="e6fb313f-0649-4034-a364-705babaf40b2" name="Default" comment=""> | ||
| <change type="MODIFICATION" beforePath="$PROJECT_DIR$/Readme.md" afterPath="$PROJECT_DIR$/Readme.md" /> | ||
| <list default="true" id="4d4d926b-27cc-45f9-a202-810e1c9be476" name="Default" comment=""> | ||
| <change type="MODIFICATION" beforePath="$PROJECT_DIR$/index.js" afterPath="$PROJECT_DIR$/index.js" /> | ||
| <change type="MODIFICATION" beforePath="$PROJECT_DIR$/test.js" afterPath="$PROJECT_DIR$/test.js" /> | ||
| </list> | ||
| <ignored path="manuelstofer-foreach.iws" /> | ||
| <ignored path=".idea/workspace.xml" /> | ||
| <file path="/Dummy.txt" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1365335334385" ignored="false" /> | ||
| <file path="/a.dummy" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363890896138" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-mapr/test/test.js" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363892026712" ignored="false" /> | ||
| <file path="/test.js" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363892010403" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-mapr/component.json" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363892422104" ignored="false" /> | ||
| <file path="/component.json" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363891447340" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-mapr/package.json" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363892426835" ignored="false" /> | ||
| <file path="/package.json" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363891477658" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-mapr/build/build.js" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363892034191" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-mapr/index.js" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363891926009" ignored="false" /> | ||
| <file path="/index.js" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1365335368429" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-mapr/test/test-runner.html" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363891971222" ignored="false" /> | ||
| <file path="/test-runner.html" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363891968487" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-mapr/Readme.md" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1363892582415" ignored="false" /> | ||
| <file path="/Readme.md" changelist="e6fb313f-0649-4034-a364-705babaf40b2" time="1365335618433" ignored="false" /> | ||
| <file path="/Dummy.txt" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365465302443" ignored="false" /> | ||
| <file path="/Readme.md" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378619965" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-json-pointer/package.json" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365376303789" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-content-element/test/content-element.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365377761734" ignored="false" /> | ||
| <file path="/content-element.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365377746213" ignored="false" /> | ||
| <file path="/a.dummy" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365377918958" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-content-element/src/plugins/x-collection.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365377855014" ignored="false" /> | ||
| <file path="/x-collection.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365377855014" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../../demo/templates/page.html" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365377937263" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../../demo/templates/edit/page.html" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378012400" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../../demo/templates/navigation/page.html" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378028227" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../../demo/templates/search/page.html" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378035977" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/Readme.md" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378667210" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/src/pflock.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378667210" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/package.json" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378667210" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/test/x-each.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378667210" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/component.json" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378667210" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/src/util.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378667210" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/test/test.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378667210" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/src/plugins/x-each.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378667210" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/src/plugins/x-bind.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378667210" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-pflock/index.html" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365378779510" ignored="false" /> | ||
| <file path="/index.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365463992294" ignored="false" /> | ||
| <file path="/test.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365465697863" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/node_modules/tape/node_modules/defined/package.json" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365456642256" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/node_modules/tape/node_modules/deep-equal/package.json" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365456642256" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-test-jepso-ci/index.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365463999682" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-test-jepso-ci/test/test.html" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365466091057" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-test-jepso-ci/test/test.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365465703534" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-test-jepso-ci/component.json" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365465964266" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-test-jepso-ci/.jepso-ci.json" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365464206077" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-json-pointer/components/manuelstofer-foreach/index.js" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365465433182" ignored="false" /> | ||
| <file path="$PROJECT_DIR$/../manuelstofer-test-jepso-ci/Makefile" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365465985517" ignored="false" /> | ||
| <file path="/test.html" changelist="4d4d926b-27cc-45f9-a202-810e1c9be476" time="1365466057714" ignored="false" /> | ||
| <option name="TRACKING_ENABLED" value="true" /> | ||
@@ -43,6 +63,6 @@ <option name="SHOW_DIALOG" value="false" /> | ||
| <leaf> | ||
| <file leaf-file-name="package.json" pinned="false" current="false" current-in-tab="false"> | ||
| <entry file="file://$PROJECT_DIR$/package.json"> | ||
| <file leaf-file-name="test.js" pinned="false" current="false" current-in-tab="false"> | ||
| <entry file="file://$PROJECT_DIR$/test.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="3" column="22" selection-start="101" selection-end="101" vertical-scroll-proportion="-2.0357144"> | ||
| <state line="11" column="0" selection-start="173" selection-end="173" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
@@ -54,5 +74,5 @@ </state> | ||
| <file leaf-file-name="index.js" pinned="false" current="false" current-in-tab="false"> | ||
| <entry file="file://$PROJECT_DIR$/index.js"> | ||
| <entry file="file://$PROJECT_DIR$/node_modules/tape/index.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="5" column="20" selection-start="148" selection-end="148" vertical-scroll-proportion="0.0"> | ||
| <state line="64" column="0" selection-start="1793" selection-end="1793" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
@@ -63,6 +83,24 @@ </state> | ||
| </file> | ||
| <file leaf-file-name="Readme.md" pinned="false" current="true" current-in-tab="true"> | ||
| <file leaf-file-name="test.js" pinned="false" current="false" current-in-tab="false"> | ||
| <entry file="file://$PROJECT_DIR$/node_modules/tape/lib/test.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="318" column="27" selection-start="7687" selection-end="7687" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| </file> | ||
| <file leaf-file-name="Makefile" pinned="false" current="false" current-in-tab="false"> | ||
| <entry file="file://$PROJECT_DIR$/Makefile"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="4" column="0" selection-start="38" selection-end="38" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| </file> | ||
| <file leaf-file-name="Readme.md" pinned="false" current="false" current-in-tab="false"> | ||
| <entry file="file://$PROJECT_DIR$/Readme.md"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="20" column="3" selection-start="380" selection-end="380" vertical-scroll-proportion="0.521978"> | ||
| <state line="24" column="2" selection-start="481" selection-end="481" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
@@ -73,6 +111,15 @@ </state> | ||
| </file> | ||
| <file leaf-file-name="index.js" pinned="false" current="true" current-in-tab="true"> | ||
| <entry file="file://$PROJECT_DIR$/index.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="8" column="22" selection-start="224" selection-end="224" vertical-scroll-proportion="0.20879121"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| </file> | ||
| <file leaf-file-name="component.json" pinned="false" current="false" current-in-tab="false"> | ||
| <entry file="file://$PROJECT_DIR$/component.json"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="3" column="20" selection-start="99" selection-end="99" vertical-scroll-proportion="0.0"> | ||
| <state line="3" column="21" selection-start="100" selection-end="100" vertical-scroll-proportion="-2.0357144"> | ||
| <folding /> | ||
@@ -83,2 +130,11 @@ </state> | ||
| </file> | ||
| <file leaf-file-name="package.json" pinned="false" current="false" current-in-tab="false"> | ||
| <entry file="file://$PROJECT_DIR$/package.json"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="23" column="16" selection-start="561" selection-end="561" vertical-scroll-proportion="-15.607142"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| </file> | ||
| </leaf> | ||
@@ -102,5 +158,7 @@ </component> | ||
| <list> | ||
| <option value="$PROJECT_DIR$/Readme.md" /> | ||
| <option value="$PROJECT_DIR$/component.json" /> | ||
| <option value="$PROJECT_DIR$/package.json" /> | ||
| <option value="$PROJECT_DIR$/test.js" /> | ||
| <option value="$PROJECT_DIR$/index.js" /> | ||
| <option value="$PROJECT_DIR$/Readme.md" /> | ||
| </list> | ||
@@ -140,3 +198,2 @@ </option> | ||
| <panes> | ||
| <pane id="Scope" /> | ||
| <pane id="ProjectPane"> | ||
@@ -160,4 +217,81 @@ <subPane> | ||
| </PATH> | ||
| <PATH> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="manuelstofer-foreach" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="manuelstofer-foreach" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="node_modules" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="tape" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| </PATH> | ||
| <PATH> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="manuelstofer-foreach" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="manuelstofer-foreach" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="node_modules" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="tape" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="test" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| </PATH> | ||
| <PATH> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="manuelstofer-foreach" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="manuelstofer-foreach" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="node_modules" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="tape" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="lib" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| </PATH> | ||
| <PATH> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="manuelstofer-foreach" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="manuelstofer-foreach" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| <PATH_ELEMENT> | ||
| <option name="myItemId" value="node_modules" /> | ||
| <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> | ||
| </PATH_ELEMENT> | ||
| </PATH> | ||
| </subPane> | ||
| </pane> | ||
| <pane id="Scope" /> | ||
| </panes> | ||
@@ -167,12 +301,5 @@ </component> | ||
| <property name="WebServerToolWindowFactoryState" value="false" /> | ||
| <property name="FullScreen" value="false" /> | ||
| </component> | ||
| <component name="RunManager"> | ||
| <configuration default="true" type="DartUnitRunConfigurationType" factoryName="DartUnit"> | ||
| <option name="VMOptions" /> | ||
| <option name="arguments" /> | ||
| <option name="filePath" /> | ||
| <option name="scope" value="ALL" /> | ||
| <option name="testName" /> | ||
| <method /> | ||
| </configuration> | ||
| <list size="0" /> | ||
@@ -200,5 +327,5 @@ </component> | ||
| <task active="true" id="Default" summary="Default task"> | ||
| <changelist id="e6fb313f-0649-4034-a364-705babaf40b2" name="Default" comment="" /> | ||
| <created>1363890856178</created> | ||
| <updated>1363890856178</updated> | ||
| <changelist id="4d4d926b-27cc-45f9-a202-810e1c9be476" name="Default" comment="" /> | ||
| <created>1365371005647</created> | ||
| <updated>1365371005647</updated> | ||
| </task> | ||
@@ -208,4 +335,4 @@ <servers /> | ||
| <component name="ToolWindowManager"> | ||
| <frame x="0" y="22" width="1440" height="874" extended-state="6" /> | ||
| <editor active="true" /> | ||
| <frame x="0" y="22" width="1440" height="874" extended-state="0" /> | ||
| <editor active="false" /> | ||
| <layout> | ||
@@ -215,3 +342,3 @@ <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> | ||
| <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> | ||
| <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.18983768" sideWeight="0.9351852" order="0" side_tool="false" content_ui="combo" /> | ||
| <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24982357" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> | ||
| <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> | ||
@@ -225,3 +352,3 @@ <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> | ||
| <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> | ||
| <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.48280424" sideWeight="0.9534227" order="1" side_tool="false" content_ui="tabs" /> | ||
| <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> | ||
| <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> | ||
@@ -293,5 +420,5 @@ <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> | ||
| <component name="editorHistoryManager"> | ||
| <entry file="file://$PROJECT_DIR$/package.json"> | ||
| <entry file="file://$PROJECT_DIR$/test.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="3" column="22" selection-start="118" selection-end="118" vertical-scroll-proportion="0.0"> | ||
| <state line="34" column="42" selection-start="963" selection-end="1933" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
@@ -301,5 +428,5 @@ </state> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/component.json"> | ||
| <entry file="file://$PROJECT_DIR$/Makefile"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="3" column="20" selection-start="116" selection-end="116" vertical-scroll-proportion="0.0"> | ||
| <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
@@ -309,5 +436,19 @@ </state> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/Readme.md"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="24" column="2" selection-start="481" selection-end="481" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/index.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="3" column="0" selection-start="48" selection-end="48" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/component.json"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="3" column="20" selection-start="99" selection-end="99" vertical-scroll-proportion="0.0"> | ||
| <state line="3" column="21" selection-start="100" selection-end="100" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
@@ -319,3 +460,3 @@ </state> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="3" column="22" selection-start="101" selection-end="101" vertical-scroll-proportion="-2.0357144"> | ||
| <state line="25" column="17" selection-start="592" selection-end="592" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
@@ -325,5 +466,5 @@ </state> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/index.js"> | ||
| <entry file="file://$PROJECT_DIR$/test.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="5" column="20" selection-start="148" selection-end="148" vertical-scroll-proportion="0.0"> | ||
| <state line="78" column="0" selection-start="1934" selection-end="1934" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
@@ -335,3 +476,3 @@ </state> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="20" column="3" selection-start="380" selection-end="380" vertical-scroll-proportion="0.521978"> | ||
| <state line="27" column="6" selection-start="494" selection-end="494" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
@@ -341,4 +482,60 @@ </state> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/Readme.md"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="24" column="2" selection-start="481" selection-end="481" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/Makefile"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="4" column="0" selection-start="38" selection-end="38" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/node_modules/tape/index.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="64" column="0" selection-start="1793" selection-end="1793" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/node_modules/tape/lib/test.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="318" column="27" selection-start="7687" selection-end="7687" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/package.json"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="23" column="16" selection-start="561" selection-end="561" vertical-scroll-proportion="-15.607142"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/component.json"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="3" column="21" selection-start="100" selection-end="100" vertical-scroll-proportion="-2.0357144"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/test.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="11" column="0" selection-start="173" selection-end="173" vertical-scroll-proportion="0.0"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| <entry file="file://$PROJECT_DIR$/index.js"> | ||
| <provider selected="true" editor-type-id="text-editor"> | ||
| <state line="8" column="22" selection-start="224" selection-end="224" vertical-scroll-proportion="0.20879121"> | ||
| <folding /> | ||
| </state> | ||
| </provider> | ||
| </entry> | ||
| </component> | ||
| </project> | ||
+1
-1
| { | ||
| "name": "foreach", | ||
| "description": "foreach component + npm package", | ||
| "version": "2.0.0", | ||
| "version": "2.0.2", | ||
| "keywords": [], | ||
@@ -6,0 +6,0 @@ "dependencies": {}, |
+7
-1
@@ -5,3 +5,8 @@ | ||
| module.exports = function forEach (obj, fn, ctx) { | ||
| if (obj == null) return; | ||
| if (!(typeof obj === 'object' || typeof obj === 'string') || obj === null) { | ||
| throw new TypeError('can only iterate over objects, arrays and strings'); | ||
| } | ||
| if (typeof fn !== 'function') { | ||
| throw new TypeError('iterator must be a function'); | ||
| } | ||
| var l = obj.length; | ||
@@ -20,1 +25,2 @@ if (l === +l) { | ||
| }; | ||
+25
-2
| { | ||
| "name": "foreach", | ||
| "description": "foreach component + npm package", | ||
| "version": "2.0.1", | ||
| "version": "2.0.2", | ||
| "author": "Manuel Stofer <manuel@takimata.ch>", | ||
| "license": "MIT", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "node test.js" | ||
| }, | ||
| "repository": { | ||
@@ -19,4 +23,23 @@ "type": "git", | ||
| "dependencies": {}, | ||
| "devDependencies": {} | ||
| "devDependencies": { | ||
| "tape": "*" | ||
| }, | ||
| "testling": { | ||
| "files": "test.js", | ||
| "browsers": [ | ||
| "iexplore/6.0..latest", | ||
| "firefox/3.0", | ||
| "firefox/15.0..latest", | ||
| "firefox/nightly", | ||
| "chrome/4.0", | ||
| "chrome/22.0..latest", | ||
| "chrome/canary", | ||
| "opera/10.0..latest", | ||
| "opera/next", | ||
| "safari/5.0.5..latest", | ||
| "ipad/6.0..latest", | ||
| "iphone/6.0..latest" | ||
| ] | ||
| } | ||
| } | ||
+8
-2
@@ -6,2 +6,4 @@ | ||
| [![browser support][1]][2] | ||
| ## API | ||
@@ -14,13 +16,17 @@ | ||
| each([1,2,3], function (value, key) { | ||
| each([1,2,3], function (value, key, array) { | ||
| // value === 1, 2, 3 | ||
| // key === 0, 1, 2 | ||
| // array === [1, 2, 3] | ||
| }); | ||
| each({0:1,1:2,2:3}, function (value, key) { | ||
| each({0:1,1:2,2:3}, function (value, key, object) { | ||
| // value === 1, 2, 3 | ||
| // key === 0, 1, 2 | ||
| // object === {0:1,1:2,2:3} | ||
| }); | ||
| ``` | ||
| [1]: https://ci.testling.com/manuelstofer/foreach.png | ||
| [2]: https://ci.testling.com/manuelstofer/foreach | ||
39730
86.55%15
7.14%169
525.93%31
24%1
Infinity%