.findOne() - DarthJDG/Mangler.js GitHub Wiki

Returns a new mangler object with the first item that passes the test.

.findOne([test])
Parameter Type Default Description
test Test {} The test expression to check against.

Returns

Returns a new mangler object.


If called without a test parameter, it returns the first item. The result will be returned wrapped in a new mangler object for method chaining. Call the .end() method to return to the previous mangler object in the chain, or the .endAll() method to return the mangler object at the top of the chain.

For more information on test expressions, see Mangler.test().

Example

m = Mangler([1, 2, 3, 4]);

m.findOne();              // Returns new mangler object with item [1]
m.findOne({ $gt: 2 });    // Returns new mangler object with item [3]
⚠️ **GitHub.com Fallback** ⚠️