Comparing version 0.9.3 to 0.9.4
@@ -326,2 +326,5 @@ (function(undefined) { | ||
} | ||
if (obj && typeof obj.toString === 'function') { | ||
return obj.toString() | ||
} | ||
// TODO: location | ||
@@ -1085,2 +1088,66 @@ return null | ||
backbeam.collection = function() { | ||
var arr = [] | ||
function addWithPrefix(values, prefix) { | ||
for (var i = 0; i < values.length; i++) { | ||
var value = values[i] | ||
if (value) { | ||
if (_.isArray(value)) { | ||
for (var i = 0; i < value.length; i++) { | ||
arr.push(prefix+value[i]) | ||
} | ||
} else { | ||
arr.push(prefix+value) | ||
} | ||
} | ||
} | ||
} | ||
var obj = { | ||
add: function() { | ||
for (var i = 0; i < arguments.length; i++) { | ||
var value = arguments[i] | ||
if (value) { | ||
if (typeof value.id === 'function') { | ||
arr.push(value.id()) | ||
} else if (_.isArray(value)) { | ||
for (var i = 0; i < value.length; i++) { | ||
arr.push(value[i]) | ||
} | ||
} else { | ||
arr.push(value) | ||
} | ||
} | ||
} | ||
return this | ||
}, | ||
addTwitter: function() { | ||
addWithPrefix(arguments, 'tw:') | ||
return this | ||
}, | ||
addFacebook: function() { | ||
addWithPrefix(arguments, 'fb:') | ||
return this | ||
}, | ||
addEmail: function() { | ||
addWithPrefix(arguments, 'email:') | ||
return this | ||
}, | ||
toString: function() { | ||
return arr.join('\n') | ||
} | ||
} | ||
if (arguments.length === 1) { | ||
if (_.isArray(arguments[0])) { | ||
obj.add(arguments[0]) | ||
} else { | ||
obj.add(arguments[0]) | ||
} | ||
} else { | ||
obj.add(Array.prototype.slice.call(arguments)) | ||
} | ||
return obj | ||
} | ||
})() |
{ | ||
"name": "backbeam", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Javascript library for backbeam.io. For both nodejs and the browser", | ||
@@ -5,0 +5,0 @@ "main": "backbeam.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
348446
8635