From 3fd0185d4e356343815fbe704a1d3dc1dff80c36 Mon Sep 17 00:00:00 2001 From: Ibby Date: Sat, 11 Mar 2017 11:29:11 -0500 Subject: [PATCH] chore(): add check decroators --- src/@ionic-native/plugins/file/index.ts | 31 ++++++++++++++++--- .../plugins/google-maps/index.ts | 6 ++-- src/@ionic-native/plugins/sqlite/index.ts | 4 +-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/@ionic-native/plugins/file/index.ts b/src/@ionic-native/plugins/file/index.ts index 18d7ab140..0dfb4c5ef 100644 --- a/src/@ionic-native/plugins/file/index.ts +++ b/src/@ionic-native/plugins/file/index.ts @@ -350,6 +350,10 @@ export declare var FileError: { * ``` * import { File } from '@ionic-native/file'; * + * constructor(private file: File) { } + * + * ... + * * this.file.checkDir(this.file.dataDirectory, 'mydir').then(_ => console.log('Directory exists')).catch(err => console.log('Directory doesnt exist')); * ``` * @@ -461,9 +465,7 @@ export class File { * Get free disk space in Bytes * @returns {Promise} Returns a promise that resolves with the remaining free disk space in Bytes */ - @CordovaCheck({ - promise: true - }) + @CordovaCheck() getFreeDiskSpace(): Promise { return new Promise((resolve, reject) => { cordova.exec(resolve, reject, 'File', 'getFreeDiskSpace', []); @@ -477,6 +479,7 @@ export class File { * @param {string} dir Name of directory to check * @returns {Promise} Returns a Promise that resolves to true if the directory exists or rejects with an error. */ + @CordovaCheck() checkDir(path: string, dir: string): Promise { if ((/^\//.test(dir))) { let err = new FileError(5); @@ -501,6 +504,7 @@ export class File { * @param {boolean} replace If true, replaces file with same name. If false returns error * @returns {Promise} Returns a Promise that resolves with a DirectoryEntry or rejects with an error. */ + @CordovaCheck() createDir(path: string, dirName: string, replace: boolean): Promise { if ((/^\//.test(dirName))) { let err = new FileError(5); @@ -529,6 +533,7 @@ export class File { * @param {string} dirName The directory name * @returns {Promise} Returns a Promise that resolves to a RemoveResult or rejects with an error. */ + @CordovaCheck() removeDir(path: string, dirName: string): Promise { if ((/^\//.test(dirName))) { let err = new FileError(5); @@ -554,6 +559,7 @@ export class File { * @param {string} newDirName The destination directory name * @returns {Promise} Returns a Promise that resolves to the new DirectoryEntry object or rejects with an error. */ + @CordovaCheck() moveDir(path: string, dirName: string, newPath: string, newDirName: string): Promise { newDirName = newDirName || dirName; @@ -584,6 +590,7 @@ export class File { * @param {string} newDirName New name of directory to copy to (leave blank to remain the same) * @returns {Promise} Returns a Promise that resolves to the new Entry object or rejects with an error. */ + @CordovaCheck() copyDir(path: string, dirName: string, newPath: string, newDirName: string): Promise { if ((/^\//.test(newDirName))) { let err = new FileError(5); @@ -610,6 +617,7 @@ export class File { * @param {string} dirName Name of directory * @returns {Promise} Returns a Promise that resolves to an array of Entry objects or rejects with an error. */ + @CordovaCheck() listDir(path: string, dirName: string): Promise { if ((/^\//.test(dirName))) { let err = new FileError(5); @@ -634,6 +642,7 @@ export class File { * @param {string} dirName Name of directory * @returns {Promise} Returns a Promise that resolves with a RemoveResult or rejects with an error. */ + @CordovaCheck() removeRecursively(path: string, dirName: string): Promise { if ((/^\//.test(dirName))) { let err = new FileError(5); @@ -657,6 +666,7 @@ export class File { * @param {string} file Name of file to check * @returns {Promise} Returns a Promise that resolves with a boolean or rejects with an error. */ + @CordovaCheck() checkFile(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); @@ -686,6 +696,7 @@ export class File { * @param {boolean} replace If true, replaces file with same name. If false returns error * @returns {Promise} Returns a Promise that resolves to a FileEntry or rejects with an error. */ + @CordovaCheck() createFile(path: string, fileName: string, replace: boolean): Promise { if ((/^\//.test(fileName))) { let err = new FileError(5); @@ -714,6 +725,7 @@ export class File { * @param {string} fileName Name of file to remove * @returns {Promise} Returns a Promise that resolves to a RemoveResult or rejects with an error. */ + @CordovaCheck() removeFile(path: string, fileName: string): Promise { if ((/^\//.test(fileName))) { let err = new FileError(5); @@ -738,6 +750,7 @@ export class File { * @param {WriteOptions} options replace file if set to true. See WriteOptions for more information. * @returns {Promise} Returns a Promise that resolves to updated file entry or rejects with an error. */ + @CordovaCheck() writeFile(path: string, fileName: string, text: string | Blob | ArrayBuffer, options: WriteOptions = {}): Promise { if ((/^\//.test(fileName))) { @@ -792,6 +805,7 @@ export class File { * @param {string | Blob} text content or blob to write * @returns {Promise} Returns a Promise that resolves or rejects with an error. */ + @CordovaCheck() writeExistingFile(path: string, fileName: string, text: string | Blob): Promise { return this.writeFile(path, fileName, text, { replace: true }); } @@ -803,6 +817,7 @@ export class File { * @param {string} file Name of file, relative to path. * @returns {Promise} Returns a Promise that resolves with the contents of the file as string or rejects with an error. */ + @CordovaCheck() readAsText(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); @@ -844,6 +859,7 @@ export class File { * @param {string} file Name of file, relative to path. * @returns {Promise} Returns a Promise that resolves with the contents of the file as data URL or rejects with an error. */ + @CordovaCheck() readAsDataURL(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); @@ -886,6 +902,7 @@ export class File { * @param {string} file Name of file, relative to path. * @returns {Promise} Returns a Promise that resolves with the contents of the file as string rejects with an error. */ + @CordovaCheck() readAsBinaryString(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); @@ -922,11 +939,11 @@ export class File { /** * Read file and return data as an ArrayBuffer. - * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} file Name of file, relative to path. * @returns {Promise} Returns a Promise that resolves with the contents of the file as ArrayBuffer or rejects with an error. */ + @CordovaCheck() readAsArrayBuffer(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); @@ -970,6 +987,7 @@ export class File { * @param {string} newFileName New name of file to move to (leave blank to remain the same) * @returns {Promise} Returns a Promise that resolves to the new Entry or rejects with an error. */ + @CordovaCheck() moveFile(path: string, fileName: string, newPath: string, newFileName: string): Promise { newFileName = newFileName || fileName; @@ -1000,6 +1018,7 @@ export class File { * @param {string} newFileName New name of file to copy to (leave blank to remain the same) * @returns {Promise} Returns a Promise that resolves to an Entry or rejects with an error. */ + @CordovaCheck() copyFile(path: string, fileName: string, newPath: string, newFileName: string): Promise { newFileName = newFileName || fileName; @@ -1035,6 +1054,7 @@ export class File { * @param fileUrl {string} file system url * @returns {Promise} */ + @CordovaCheck() resolveLocalFilesystemUrl(fileUrl: string): Promise { return new Promise((resolve, reject) => { try { @@ -1056,6 +1076,7 @@ export class File { * @param directoryUrl {string} directory system url * @returns {Promise} */ + @CordovaCheck() resolveDirectoryUrl(directoryUrl: string): Promise { return this.resolveLocalFilesystemUrl(directoryUrl) .then((de) => { @@ -1076,6 +1097,7 @@ export class File { * @param flags {Flags} Options * @returns {Promise} */ + @CordovaCheck() getDirectory(directoryEntry: DirectoryEntry, directoryName: string, flags: Flags): Promise { return new Promise((resolve, reject) => { try { @@ -1099,6 +1121,7 @@ export class File { * @param flags {Flags} Options * @returns {Promise} */ + @CordovaCheck() getFile(directoryEntry: DirectoryEntry, fileName: string, flags: Flags): Promise { return new Promise((resolve, reject) => { try { diff --git a/src/@ionic-native/plugins/google-maps/index.ts b/src/@ionic-native/plugins/google-maps/index.ts index 08cc16f93..700703843 100644 --- a/src/@ionic-native/plugins/google-maps/index.ts +++ b/src/@ionic-native/plugins/google-maps/index.ts @@ -109,7 +109,7 @@ export class GoogleMap { * * @returns {Observable} */ - @InstanceCheck() + @InstanceCheck({ observable: true }) on(eventName: string): Observable { return new Observable((observer) => { this._objectInstance.on(eventName, observer.next.bind(observer)); @@ -1751,9 +1751,7 @@ export class Geocoder { * @param {GeocoderRequest} request Request object with either an address or a position * @returns {Promise} */ - @CordovaCheck({ - promise: true - }) + @CordovaCheck() static geocode(request: GeocoderRequest): Promise { return new Promise(resolve => { plugin.google.maps.Geocoder.geocode(request, resolve); diff --git a/src/@ionic-native/plugins/sqlite/index.ts b/src/@ionic-native/plugins/sqlite/index.ts index 18d48cce8..fcd0e99b5 100644 --- a/src/@ionic-native/plugins/sqlite/index.ts +++ b/src/@ionic-native/plugins/sqlite/index.ts @@ -199,9 +199,7 @@ export class SQLite { * @param config the config for opening the database. * @return Promise */ - @CordovaCheck({ - promise: true - }) + @CordovaCheck() create(config: any): Promise { return new Promise((resolve, reject) => { sqlitePlugin.openDatabase(config, db => resolve(new SQLiteObject(db)), reject);