feathers-commons
Advanced tools
Comparing version 0.8.0 to 0.8.1
# Change Log | ||
## [v0.8.0](https://github.com/feathersjs/feathers-commons/tree/v0.8.0) (2016-11-09) | ||
[Full Changelog](https://github.com/feathersjs/feathers-commons/compare/v0.7.8...v0.8.0) | ||
**Merged pull requests:** | ||
- Implementing lodash utilities and helpers for selecting [\#38](https://github.com/feathersjs/feathers-commons/pull/38) ([daffl](https://github.com/daffl)) | ||
- jshint —\> semistandard [\#37](https://github.com/feathersjs/feathers-commons/pull/37) ([corymsmith](https://github.com/corymsmith)) | ||
## [v0.7.8](https://github.com/feathersjs/feathers-commons/tree/v0.7.8) (2016-10-21) | ||
@@ -4,0 +12,0 @@ [Full Changelog](https://github.com/feathersjs/feathers-commons/compare/v0.7.7...v0.7.8) |
@@ -14,3 +14,2 @@ 'use strict'; | ||
exports.select = select; | ||
exports.selectMany = selectMany; | ||
exports.matcher = matcher; | ||
@@ -135,25 +134,19 @@ exports.sorter = sorter; | ||
function select() { | ||
for (var _len3 = arguments.length, fields = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
fields[_key3] = arguments[_key3]; | ||
function select(params) { | ||
var fields = params && params.query && params.query.$select; | ||
for (var _len3 = arguments.length, otherFields = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
otherFields[_key3 - 1] = arguments[_key3]; | ||
} | ||
return function (result) { | ||
return _.pick.apply(_, [result].concat(fields)); | ||
}; | ||
} | ||
if (Array.isArray(fields) && otherFields.length) { | ||
fields.push.apply(fields, otherFields); | ||
} | ||
function selectMany() { | ||
var selector = select.apply(undefined, arguments); | ||
return function (result) { | ||
if (Array.isArray(result)) { | ||
return result.map(selector); | ||
if (!Array.isArray(fields)) { | ||
return result; | ||
} | ||
if (result.data) { | ||
result.data = result.data.map(selector); | ||
} | ||
return result; | ||
return _.pick.apply(_, [result].concat(_toConsumableArray(fields))); | ||
}; | ||
@@ -160,0 +153,0 @@ } |
{ | ||
"name": "feathers-commons", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "Shared Feathers utility functions", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/feathersjs/feathers-commons", |
33231
557