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;
|
||||
|
||||
class MockPlugin {
|
||||
@ -29,11 +30,10 @@ class MockInstancePluginObject {
|
||||
|
||||
class MockCordovaPlugin {
|
||||
static ping = jest.fn((arg: string) => 'pong');
|
||||
ping = jest.fn((arg: string) => 'pong');
|
||||
|
||||
static pingAsync = jest.fn(
|
||||
(arg: string, success: Function, error: Function) => success('pong')
|
||||
);
|
||||
ping = jest.fn((arg: string) => 'pong');
|
||||
pingAsync = jest.fn((arg: string, success: Function, error: Function) =>
|
||||
success('pong')
|
||||
);
|
||||
|
@ -286,7 +286,8 @@ export function setIndex(
|
||||
};
|
||||
|
||||
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) {
|
||||
args[opts.errorIndex] = reject; // insert the reject fn at the correct specific index
|
||||
} else {
|
||||
@ -374,12 +375,12 @@ export function pluginWarn(
|
||||
if (method) {
|
||||
console.warn(
|
||||
'Native: tried calling ' +
|
||||
pluginName +
|
||||
'.' +
|
||||
method +
|
||||
', but the ' +
|
||||
pluginName +
|
||||
' plugin is not installed.'
|
||||
pluginName +
|
||||
'.' +
|
||||
method +
|
||||
', but the ' +
|
||||
pluginName +
|
||||
' plugin is not installed.'
|
||||
);
|
||||
} else {
|
||||
console.warn(
|
||||
@ -402,16 +403,16 @@ export function cordovaWarn(pluginName: string, method?: string): void {
|
||||
if (method) {
|
||||
console.warn(
|
||||
'Native: tried calling ' +
|
||||
pluginName +
|
||||
'.' +
|
||||
method +
|
||||
', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'
|
||||
pluginName +
|
||||
'.' +
|
||||
method +
|
||||
', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'
|
||||
);
|
||||
} else {
|
||||
console.warn(
|
||||
'Native: tried accessing the ' +
|
||||
pluginName +
|
||||
' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'
|
||||
pluginName +
|
||||
' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -419,7 +420,7 @@ export function cordovaWarn(pluginName: string, method?: string): void {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export const wrap = function(
|
||||
export const wrap = function (
|
||||
pluginObj: any,
|
||||
methodName: string,
|
||||
opts: CordovaOptions = {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { checkAvailability, getPlugin } from './common';
|
||||
import { Observable } from 'rxjs';
|
||||
import { checkAvailability, getPlugin } from './common';
|
||||
|
||||
function overrideFunction(pluginObj: any, methodName: string): Observable<any> {
|
||||
return new Observable(observer => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { CordovaOptions } from './interfaces';
|
||||
import { wrapInstance } from './common';
|
||||
import { CordovaOptions } from './interfaces';
|
||||
|
||||
export function cordovaInstance(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | Array<any>) {
|
||||
args = Array.from(args);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { CordovaOptions } from './interfaces';
|
||||
import { wrap } from './common';
|
||||
import { CordovaOptions } from './interfaces';
|
||||
|
||||
export function cordova(pluginObj: any, methodName: string, config: CordovaOptions, args: IArguments | Array<any>) {
|
||||
return wrap(pluginObj, methodName, config).apply(this, args);
|
||||
|
@ -38,7 +38,8 @@ export interface CordovaOptions {
|
||||
*/
|
||||
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';
|
||||
/**
|
||||
@ -70,7 +71,8 @@ export interface CordovaOptions {
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
|
@ -13,8 +13,8 @@ export function initAngular1(plugins: any) {
|
||||
const serviceName = '$cordova' + name;
|
||||
const cls = plugins[name];
|
||||
|
||||
(function(serviceName, cls, name) {
|
||||
ngModule.service(serviceName, [function() {
|
||||
(function (serviceName, cls, name) {
|
||||
ngModule.service(serviceName, [function () {
|
||||
const funcs = window.angular.copy(cls);
|
||||
funcs.__proto__['name'] = name;
|
||||
return funcs;
|
||||
|
Loading…
Reference in New Issue
Block a user