forked from 0x2620/oxjs
use markdown
This commit is contained in:
parent
c831b89944
commit
9269b96469
4 changed files with 44 additions and 47 deletions
|
|
@ -79,8 +79,7 @@ Ox.count = function(collection) {
|
|||
|
||||
/*@
|
||||
Ox.every <f> Tests if every element of a collection satisfies a given condition
|
||||
Unlike <code>[].every()</code>, <code>Ox.every()</code> works for arrays,
|
||||
objects and strings.
|
||||
Unlike `[].every()`, `Ox.every()` works for arrays, objects and strings.
|
||||
> Ox.every([0, 1, 2], function(v, i) { return v == i; })
|
||||
true
|
||||
> Ox.every({a: 1, b: 2, c: 3}, function(v) { return v == 1; })
|
||||
|
|
@ -98,8 +97,7 @@ Ox.every = function(collection, iterator) {
|
|||
|
||||
/*@
|
||||
Ox.filter <f> Filters a collection by a given condition
|
||||
Unlike <code>[].filter()</code>, <code>Ox.filter()</code> works for arrays,
|
||||
objects and strings.
|
||||
Unlike `[].filter()`, `Ox.filter()` works for arrays, objects and strings.
|
||||
> Ox.filter([2, 1, 0], function(v, i) { return v == i; })
|
||||
[1]
|
||||
> Ox.filter({a: 'c', b: 'b', c: 'a'}, function(v, k) { return v == k; })
|
||||
|
|
@ -129,12 +127,10 @@ Ox.filter = function(collection, iterator, that) {
|
|||
// FIXME: documentation is outdated!
|
||||
/*@
|
||||
Ox.forEach <f> forEach loop
|
||||
<code>Ox.forEach()</code> loops over arrays, objects and strings.
|
||||
Returning <code>false</code> from the iterator function acts like a
|
||||
<code>break</code> statement (unlike <code>[].forEach()</code>, like
|
||||
<code>$.each()</code>). The arguments of the iterator function are
|
||||
<code>(value, key, index)</code> (more like <code>[].forEach()</code>
|
||||
than like <code>$.each()</code>).
|
||||
`Ox.forEach()` loops over arrays, objects and strings. Returning `false`
|
||||
from the iterator function acts like a `break` statement (unlike
|
||||
`[].forEach()`, like `$.each()`). The arguments of the iterator function are
|
||||
`(value, key, index)` (more like `[].forEach()` than like `$.each()`).
|
||||
(collection, callback) <a|o|s> The collection
|
||||
(collection, callback, includePrototype) <a|o|s> The collection
|
||||
collection <a|o|s> An array, object or string
|
||||
|
|
@ -248,8 +244,8 @@ Ox.isEmpty = function(value) {
|
|||
|
||||
/*@
|
||||
Ox.last <f> Gets or sets the last element of an array
|
||||
Unlike <code>arrayWithALongName[arrayWithALongName.length - 1]</code>,
|
||||
<code>Ox.last(arrayWithALongName)</code> is short.
|
||||
Unlike `arrayWithALongName[arrayWithALongName.length - 1]`,
|
||||
`Ox.last(arrayWithALongName)` is short.
|
||||
<script>
|
||||
Ox.test.array = [1, 2, 3];
|
||||
</script>
|
||||
|
|
@ -275,9 +271,8 @@ Ox.last = function(array, value) {
|
|||
|
||||
/*@
|
||||
Ox.len <f> Returns the length of an array, node list, object or string
|
||||
Not to be confused with <code>Ox.length</code>, which is the
|
||||
<code>length</code> property of the <code>Ox</code> function
|
||||
(<code>1</code>).
|
||||
Not to be confused with `Ox.length`, which is the `length` property of the
|
||||
`Ox` function (`1`).
|
||||
> Ox.len((function() { return arguments; }(1, 2, 3)))
|
||||
3
|
||||
> Ox.len([1, 2, 3])
|
||||
|
|
@ -309,8 +304,7 @@ Ox.len = function(collection) {
|
|||
|
||||
/*@
|
||||
Ox.map <f> Transforms the values of an array, object or string
|
||||
Unlike <code>[].map()</code>, <code>Ox.map()</code> works for arrays,
|
||||
objects and strings.
|
||||
Unlike `[].map()`, `Ox.map()` works for arrays, objects and strings.
|
||||
> Ox.map([2, 1, 0], function(v, i) { return v == i; })
|
||||
[false, true, false]
|
||||
> Ox.map({a: 'b', b: 'b', c: 'b'}, function(v, k) { return v == k; })
|
||||
|
|
@ -454,7 +448,7 @@ Ox.shuffle = function(collection) {
|
|||
};
|
||||
|
||||
/*@
|
||||
Ox.slice <f> Alias for <code>Array.prototype.slice.call</code>
|
||||
Ox.slice <f> Alias for `Array.prototype.slice.call`
|
||||
> (function() { return Ox.slice(arguments, 1, -1); }(1, 2, 3))
|
||||
[2]
|
||||
> (function() { return Ox.slice(arguments, 1); }(1, 2, 3))
|
||||
|
|
@ -484,8 +478,7 @@ if (
|
|||
|
||||
/*@
|
||||
Ox.some <f> Tests if one or more elements of a collection meet a given condition
|
||||
Unlike <code>[].some()</code>, <code>Ox.some()</code> works for arrays,
|
||||
objects and strings.
|
||||
Unlike `[].some()`, `Ox.some()` works for arrays, objects and strings.
|
||||
> Ox.some([2, 1, 0], function(i, v) { return i == v; })
|
||||
true
|
||||
> Ox.some({a: 1, b: 2, c: 3}, function(v) { return v == 1; })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue