mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-31 18:49:43 +08:00
Update code style
This commit is contained in:
parent
fd87e968f0
commit
b09eb06cb0
@ -1,4 +1,5 @@
|
|||||||
import { callCordovaPlugin, wrapInstance, wrapPromise } from './common';
|
import { callCordovaPlugin, wrapPromise } from './common';
|
||||||
|
|
||||||
declare const window: any;
|
declare const window: any;
|
||||||
|
|
||||||
class MockPlugin {
|
class MockPlugin {
|
||||||
@ -29,11 +30,10 @@ class MockInstancePluginObject {
|
|||||||
|
|
||||||
class MockCordovaPlugin {
|
class MockCordovaPlugin {
|
||||||
static ping = jest.fn((arg: string) => 'pong');
|
static ping = jest.fn((arg: string) => 'pong');
|
||||||
ping = jest.fn((arg: string) => 'pong');
|
|
||||||
|
|
||||||
static pingAsync = jest.fn(
|
static pingAsync = jest.fn(
|
||||||
(arg: string, success: Function, error: Function) => success('pong')
|
(arg: string, success: Function, error: Function) => success('pong')
|
||||||
);
|
);
|
||||||
|
ping = jest.fn((arg: string) => 'pong');
|
||||||
pingAsync = jest.fn((arg: string, success: Function, error: Function) =>
|
pingAsync = jest.fn((arg: string, success: Function, error: Function) =>
|
||||||
success('pong')
|
success('pong')
|
||||||
);
|
);
|
||||||
|
@ -286,7 +286,8 @@ export function setIndex(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const setErrorIndex = () => {
|
const setErrorIndex = () => {
|
||||||
// We don't want that the reject cb gets spliced into the position of an optional argument that has not been defined and thus causing non expected behavior.
|
// We don't want that the reject cb gets spliced into the position of an optional argument that has not been
|
||||||
|
// defined and thus causing non expected behavior.
|
||||||
if (opts.errorIndex > args.length) {
|
if (opts.errorIndex > args.length) {
|
||||||
args[opts.errorIndex] = reject; // insert the reject fn at the correct specific index
|
args[opts.errorIndex] = reject; // insert the reject fn at the correct specific index
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { checkAvailability, getPlugin } from './common';
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { checkAvailability, getPlugin } from './common';
|
||||||
|
|
||||||
function overrideFunction(pluginObj: any, methodName: string): Observable<any> {
|
function overrideFunction(pluginObj: any, methodName: string): Observable<any> {
|
||||||
return new Observable(observer => {
|
return new Observable(observer => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { CordovaOptions } from './interfaces';
|
|
||||||
import { wrapInstance } from './common';
|
import { wrapInstance } from './common';
|
||||||
|
import { CordovaOptions } from './interfaces';
|
||||||
|
|
||||||
export function cordovaInstance(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | Array<any>) {
|
export function cordovaInstance(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | Array<any>) {
|
||||||
args = Array.from(args);
|
args = Array.from(args);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { CordovaOptions } from './interfaces';
|
|
||||||
import { wrap } from './common';
|
import { wrap } from './common';
|
||||||
|
import { CordovaOptions } from './interfaces';
|
||||||
|
|
||||||
export function cordova(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | Array<any>) {
|
export function cordova(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | Array<any>) {
|
||||||
return wrap(pluginObj, methodName, config).apply(this, args);
|
return wrap(pluginObj, methodName, config).apply(this, args);
|
||||||
|
@ -38,7 +38,8 @@ export interface CordovaOptions {
|
|||||||
*/
|
*/
|
||||||
sync?: boolean;
|
sync?: boolean;
|
||||||
/**
|
/**
|
||||||
* Callback order. Set to reverse if the success/error callbacks are the first 2 arguments that the wrapped method takes.
|
* Callback order. Set to reverse if the success/error callbacks are the first 2 arguments that the wrapped method
|
||||||
|
* takes.
|
||||||
*/
|
*/
|
||||||
callbackOrder?: 'reverse';
|
callbackOrder?: 'reverse';
|
||||||
/**
|
/**
|
||||||
@ -70,7 +71,8 @@ export interface CordovaOptions {
|
|||||||
*/
|
*/
|
||||||
clearFunction?: string;
|
clearFunction?: string;
|
||||||
/**
|
/**
|
||||||
* This can be used if clearFunction is set. Set this to true to call the clearFunction with the same arguments used in the initial function.
|
* This can be used if clearFunction is set. Set this to true to call the clearFunction with the same arguments used
|
||||||
|
* in the initial function.
|
||||||
*/
|
*/
|
||||||
clearWithArgs?: boolean;
|
clearWithArgs?: boolean;
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user