@amphibian/for-own

for...in abstraction to iterate over an objects own keys

Usage no npm install needed!

<script type="module">
  import amphibianForOwn from 'https://cdn.skypack.dev/@amphibian/for-own';
</script>

README

for-own

build status

for...in abstraction to iterate over an objects own keys

npm install @amphibian/for-own
var forOwn = require('@amphibian/for-own');
var object = {
    foo: 'bar',
    bar: 'foo'
};

// Iterate over object keys and values
forOwn(object, function (key, value) {
    console.log(key, value);
});

// Iterate over object keys, but stop if the key is `foo`
var question = forOwn(object, function (key, value, end) {
    console.log(key, value);

    if (key === 'foo') {
        end('hola que hora es');
    }
});

console.log(question); // > hola que hora es