Permalink
Browse files

Lift `toArray` utility to the library level.

  • Loading branch information...
dervus committed Feb 8, 2013
1 parent 1e9fa25 commit 449d7a5cb1741fe36bc65a8a93959882a9148d85
Showing with 12 additions and 11 deletions.
  1. +12 −0 lib/js-yaml/common.js
  2. +0 −11 test/support/common.js
View
@@ -17,6 +17,17 @@ function isObject(subject) {
}
+function toArray(sequence) {
+ if (Array.isArray(sequence)) {
+ return sequence;
+ } else if (isNothing(sequence)) {
+ return [];
+ } else {
+ return [ sequence ];
+ }
+}
+
+
function getSetting(settings, name) {
if (!isNothing(settings) && !isNothing(settings[name])) {
return settings[name];
@@ -61,6 +72,7 @@ function repeat(string, count) {
module.exports.NIL = NIL;
module.exports.isNothing = isNothing;
module.exports.isObject = isObject;
+module.exports.toArray = toArray;
module.exports.getSetting = getSetting;
module.exports.getOption = getOption;
module.exports.repeat = repeat;
View
@@ -29,16 +29,6 @@ function each(obj, iterator, context) {
}
}
-function toArray(sequence) {
- if (Array.isArray(sequence)) {
- return sequence;
- } else if (common.isNothing(sequence)) {
- return [];
- } else {
- return [ sequence ];
- }
-}
-
function DataFile(filepath) {
this.path = path.normalize(filepath);
@@ -99,7 +89,6 @@ common.extend(module.exports, common);
common.extend(module.exports, {
each: each,
- toArray: toArray,
DataFile: DataFile,
makeClassConstructor: makeClassConstructor
});

0 comments on commit 449d7a5

Please sign in to comment.