nuclide-commons
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -27,2 +27,3 @@ "use strict"; | ||
exports.collect = collect; | ||
exports.objectValues = objectValues; | ||
exports.objectEntries = objectEntries; | ||
@@ -38,2 +39,3 @@ exports.objectFromMap = objectFromMap; | ||
exports.iterableContains = iterableContains; | ||
exports.count = count; | ||
/** | ||
@@ -381,2 +383,6 @@ * Copyright (c) 2017-present, Facebook, Inc. | ||
exports.MultiMap = MultiMap; | ||
function objectValues(obj) { | ||
return Object.keys(obj).map(key => obj[key]); | ||
} | ||
function objectEntries(obj) { | ||
@@ -457,2 +463,11 @@ if (obj == null) { | ||
return !iterableIsEmpty(filterIterable(iterable, element => element === value)); | ||
} | ||
function count(iterable) { | ||
let size = 0; | ||
// eslint-disable-next-line no-unused-vars | ||
for (const element of iterable) { | ||
size++; | ||
} | ||
return size; | ||
} |
@@ -268,3 +268,3 @@ 'use strict'; | ||
}); | ||
}function rmdir(filePath) { | ||
}function rimrafWrapper(filePath) { | ||
return new Promise((resolve, reject) => { | ||
@@ -494,3 +494,3 @@ (0, (_rimraf || _load_rimraf()).default)(filePath, (err, result) => { | ||
mkdirp, | ||
rmdir, | ||
rimraf: rimrafWrapper, | ||
isNfs, | ||
@@ -497,0 +497,0 @@ glob, |
{ | ||
"name": "nuclide-commons", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "Common Nuclide node modules.", | ||
@@ -5,0 +5,0 @@ "license": "BSD-3-Clause", |
@@ -30,2 +30,6 @@ 'use strict'; | ||
} | ||
// Guard against invalid original environments. | ||
if (!Object.keys(cachedOriginalEnvironment).length) { | ||
cachedOriginalEnvironment = process.env; | ||
} | ||
} else { | ||
@@ -32,0 +36,0 @@ cachedOriginalEnvironment = process.env; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.asyncSome = exports.asyncObjFilter = exports.asyncFilter = exports.Deferred = exports.retryLimit = exports.triggerAfterWait = exports.RequestSerializer = undefined; | ||
exports.PromiseWithState = exports.asyncSome = exports.asyncObjFilter = exports.asyncFilter = exports.Deferred = exports.retryLimit = exports.triggerAfterWait = exports.RequestSerializer = undefined; | ||
@@ -565,2 +565,30 @@ var _asyncToGenerator = _interopRequireDefault(require('async-to-generator')); | ||
}); | ||
} | ||
} | ||
/** | ||
* With a pure promise object, there's no way to tell synchronously | ||
* whether or not it has 'settled' (i.e. been fulfilled or rejected). | ||
* Here we provide a wrapper that provides that information. | ||
*/ | ||
class PromiseWithState { | ||
constructor(promise) { | ||
this._state = { kind: 'pending' }; | ||
this._promise = promise.then(value => { | ||
this._state = { kind: 'fulfilled', value }; | ||
return value; | ||
}, error => { | ||
this._state = { kind: 'rejected', error }; | ||
throw error; | ||
}); | ||
} | ||
getPromise() { | ||
return this._promise; | ||
} | ||
getState() { | ||
return this._state; | ||
} | ||
} | ||
exports.PromiseWithState = PromiseWithState; |
@@ -19,2 +19,3 @@ 'use strict'; | ||
exports.pluralize = pluralize; | ||
exports.capitalize = capitalize; | ||
@@ -180,2 +181,6 @@ var _shellQuote; | ||
function capitalize(str) { | ||
return str.length === 0 ? str : str.charAt(0).toUpperCase().concat(str.slice(1)); | ||
} | ||
// Originally copied from: | ||
@@ -182,0 +187,0 @@ // http://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
310911
56
4466
7