11const _ = require ( 'underscore' ) ;
22const AVError = require ( './error' ) ;
3+ const Promise = require ( './promise' ) ;
34const { _request } = require ( './request' ) ;
45const {
56 isNullOrUndefined,
@@ -144,7 +145,7 @@ module.exports = function(AV) {
144145 */
145146
146147 AV . Object . fetchAll = ( objects , options ) =>
147- AV . Promise . resolve ( )
148+ Promise . resolve ( )
148149 . then ( ( ) =>
149150 _request (
150151 'batch' ,
@@ -978,7 +979,7 @@ module.exports = function(AV) {
978979 * @param {AuthOptions } options AuthOptions plus:
979980 * @param {Boolean } options.fetchWhenSave fetch and update object after save succeeded
980981 * @param {AV.Query } options.query Save object only when it matches the query
981- * @return {AV. Promise } A promise that is fulfilled when the save
982+ * @return {Promise } A promise that is fulfilled when the save
982983 * completes.
983984 * @see AVError
984985 */
@@ -1018,7 +1019,7 @@ module.exports = function(AV) {
10181019 this . _startSave ( ) ;
10191020 this . _saving = ( this . _saving || 0 ) + 1 ;
10201021
1021- this . _allPreviousSaves = this . _allPreviousSaves || AV . Promise . resolve ( ) ;
1022+ this . _allPreviousSaves = this . _allPreviousSaves || Promise . resolve ( ) ;
10221023 this . _allPreviousSaves = this . _allPreviousSaves
10231024 . catch ( e => { } )
10241025 . then ( function ( ) {
@@ -1400,7 +1401,7 @@ module.exports = function(AV) {
14001401 */
14011402 AV . Object . destroyAll = function ( objects , options = { } ) {
14021403 if ( ! objects || objects . length === 0 ) {
1403- return AV . Promise . resolve ( ) ;
1404+ return Promise . resolve ( ) ;
14041405 }
14051406 const objectsByClassNameAndFlags = _ . groupBy ( objects , object =>
14061407 JSON . stringify ( {
@@ -1655,7 +1656,7 @@ module.exports = function(AV) {
16551656 var unsavedFiles = [ ] ;
16561657 AV . Object . _findUnsavedChildren ( object , unsavedChildren , unsavedFiles ) ;
16571658
1658- var promise = AV . Promise . resolve ( ) ;
1659+ var promise = Promise . resolve ( ) ;
16591660 _ . each ( unsavedFiles , function ( file ) {
16601661 promise = promise . then ( function ( ) {
16611662 return file . save ( ) ;
@@ -1667,7 +1668,7 @@ module.exports = function(AV) {
16671668
16681669 return promise
16691670 . then ( function ( ) {
1670- return AV . Promise . _continueWhile (
1671+ return Promise . _continueWhile (
16711672 function ( ) {
16721673 return remaining . length > 0 ;
16731674 } ,
@@ -1692,7 +1693,7 @@ module.exports = function(AV) {
16921693
16931694 // If we can't save any objects, there must be a circular reference.
16941695 if ( batch . length === 0 ) {
1695- return AV . Promise . reject (
1696+ return Promise . reject (
16961697 new AVError (
16971698 AVError . OTHER_CAUSE ,
16981699 'Tried to save a batch with a cycle.'
@@ -1701,9 +1702,9 @@ module.exports = function(AV) {
17011702 }
17021703
17031704 // Reserve a spot in every object's save queue.
1704- var readyToStart = AV . Promise . resolve (
1705+ var readyToStart = Promise . resolve (
17051706 _ . map ( batch , function ( object ) {
1706- return object . _allPreviousSaves || AV . Promise . resolve ( ) ;
1707+ return object . _allPreviousSaves || Promise . resolve ( ) ;
17071708 } )
17081709 ) ;
17091710
0 commit comments