Permalink
Browse files

allow for project to take a single string arg

  • Loading branch information...
1 parent 367da09 commit da4770bae85e5dfe49844df92595d9235f902b77 @mckoss committed May 5, 2011
Showing with 12 additions and 5 deletions.
  1. +4 −1 namespace-plus.js
  2. +2 −2 namespace-plus.min.js
  3. +4 −1 src/types.js
  4. +2 −1 test/test-types.js
View
@@ -62,7 +62,7 @@
/* Source: src/types.js */
namespace.module('org.startpad.types', function (exports, require) {
exports.extend({
- 'VERSION': '0.2.1',
+ 'VERSION': '0.2.2',
'isArguments': function (value) { return isType(value, 'arguments'); },
'isArray': function (value) { return isType(value, 'array'); },
'copyArray': copyArray,
@@ -150,6 +150,9 @@ function extend(dest) {
// into the new object. Ignore undefined properties.
function project(obj, props) {
var result = {};
+ if (typeof props == 'string') {
+ props = [props];
+ }
for (var i = 0; i < props.length; i++) {
var name = props[i];
if (obj && obj.hasOwnProperty(name)) {
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,5 +1,5 @@
exports.extend({
- 'VERSION': '0.2.1',
+ 'VERSION': '0.2.2',
'isArguments': function (value) { return isType(value, 'arguments'); },
'isArray': function (value) { return isType(value, 'array'); },
'copyArray': copyArray,
@@ -87,6 +87,9 @@ function extend(dest) {
// into the new object. Ignore undefined properties.
function project(obj, props) {
var result = {};
+ if (typeof props == 'string') {
+ props = [props];
+ }
for (var i = 0; i < props.length; i++) {
var name = props[i];
if (obj && obj.hasOwnProperty(name)) {
View
@@ -95,7 +95,8 @@ namespace.module('org.startpad.types.test', function (exports, require) {
[{a: 1, b: 2}, ['a'], {a: 1}],
[{a: 1, b: 2}, ['c'], {}],
[undefined, ['a'], {}],
- [{a: 1, b: 2}, [], {}]
+ [{a: 1, b: 2}, [], {}],
+ [{a1: 1, b2: 2}, 'a1', {a1: 1}]
];
for (var i = 0; i < tests.length; i++) {
var t = tests[i];

0 comments on commit da4770b

Please sign in to comment.