Skip to content

Commit

Permalink
- Rollback data.js to master version
Browse files Browse the repository at this point in the history
- Added comment to `merge` changes made
  • Loading branch information
ZER0 committed Sep 5, 2012
1 parent 59aa190 commit 0a0dc9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
18 changes: 6 additions & 12 deletions packages/api-utils/lib/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const base64 = require("../base64");
const IOService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);

const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});

const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm");
const FaviconService = Cc["@mozilla.org/browser/favicon-service;1"].
getService(Ci.nsIFaviconService);

Expand Down Expand Up @@ -57,28 +56,23 @@ function getChromeURIContent(chromeURI) {
input.close();
return content;
}

exports.getChromeURIContent = function deprecated_getChromeURIContent() {
console.error('DEPRECATED: require("api-utils/utils/data").getChromeURIContent' +
' is deprecated, please use require("api-utils/url/io").readURI ' +
'instead, for non binary content.');
}
exports.getChromeURIContent = getChromeURIContent;

/**
* Creates a base-64 encoded ASCII string from a string of binary data.
*/
exports.base64Encode = function base64Encode(data) {
console.error('DEPRECATED: require("api-utils/utils/data").base64Encode is '
'deprecated, please use require("api-utils/base64").encode instead');
console.warn('require("api-utils/utils/data").base64Encode is deprecated, ' +
'please use require("api-utils/base64").encode instead');

return base64.encode(data);
}
/**
* Decodes a string of data which has been encoded using base-64 encoding.
*/
exports.base64Decode = function base64Decode(data) {
console.error('DEPRECATED: require("api-utils/utils/data").base64Dencode is ' +
'deprecated, please use require("api-utils/base64").decode instead');
console.warn('require("api-utils/utils/data").base64Dencode is deprecated, ' +
'please use require("api-utils/base64").decode instead');

return base64.decode(data);
}
7 changes: 7 additions & 0 deletions packages/api-utils/lib/utils/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
* is overridden, with precedence from right to left, implying, that properties
* of the object on the left are overridden by a same named property of the
* object on the right.
*
* Any argument given with "falsy" value - commonly `null` and `undefined` in
* case of objects - are skipped.
*
* @examples
* var a = { bar: 0, a: 'a' }
* var b = merge(a, { foo: 'foo', bar: 1 }, { foo: 'bar', name: 'b' });
Expand All @@ -21,6 +25,9 @@
*/
function merge(source) {
let descriptor = {};
// `Boolean` converts the first parameter to a boolean value. Any object is
// converted to `true` where `null` and `undefined` becames `false`. Therefore
// the `filter` method will keep only objects that are defined and not null.
Array.slice(arguments, 1).filter(Boolean).forEach(function onEach(properties) {
Object.getOwnPropertyNames(properties).forEach(function(name) {
descriptor[name] = Object.getOwnPropertyDescriptor(properties, name);
Expand Down

0 comments on commit 0a0dc9f

Please sign in to comment.