This commit is contained in:
2022-04-07 18:09:31 +05:30
parent 36ea86d8e6
commit 1c779ef816
14095 changed files with 1769361 additions and 47 deletions
+24
View File
@@ -0,0 +1,24 @@
'use strict';
var _require = require('../helpers/is'),
isFunction = _require.isFunction;
module.exports = function sole(key, operator, value) {
var collection = void 0;
if (isFunction(key)) {
collection = this.filter(key);
} else {
collection = this.where(key, operator, value);
}
if (collection.isEmpty()) {
throw new Error('Item not found.');
}
if (collection.count() > 1) {
throw new Error('Multiple items found.');
}
return collection.first();
};