Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// typings:expect-error
yield apply(obj, obj.meth1)
// typings:expect-error
yield apply(obj, obj.meth1, [])
// typings:expect-error
yield apply(obj, obj.meth1, [1])
yield apply(obj, obj.meth1, ['a'])
yield apply number>(obj, obj.meth1, ['a'])
// typings:expect-error
yield apply(obj, 'meth1')
// typings:expect-error
yield apply(obj, 'meth1', [])
// typings:expect-error
yield apply(obj, 'meth1', [1])
yield apply(obj, 'meth1', ['a'])
yield apply(obj, 'meth1', ['a'])
// typings:expect-error
yield apply(obj, obj.meth2, ['a'])
// typings:expect-error
yield apply(obj, obj.meth2, ['a', 'b'])
// typings:expect-error
yield apply(obj, obj.meth2, [1, 'b'])
yield apply(obj, obj.meth2, ['a', 1])
yield apply number>(obj, obj.meth2, ['a', 1])
// typings:expect-error
yield apply(obj, 'meth2', ['a'])
// typings:expect-error
yield apply(obj, 'meth2', ['a', 'b'])
// typings:expect-error
function applyTest() {
const c0 = apply(context, fn0);
const c1 = apply(context, fn1, '1');
const c2 = apply(context, fn2, '1', 2);
const c3 = apply(context, fn3, '1', 2, '3');
const c4 = apply(context, fn4, '1', 2, '3', 4);
const c5 = apply(context, fn5, '1', 2, '3', 4, '5');
const c6 = apply(context, fn6, '1', 2, '3', 4, '5', 6);
const cClass = apply(context2, fn1, '1');
// Fn tests
(c1.CALL.fn: typeof fn1);
(c2.CALL.fn: typeof fn2);
(c3.CALL.fn: typeof fn3);
(c4.CALL.fn: typeof fn4);
(c5.CALL.fn: typeof fn5);
(c6.CALL.fn: typeof fn6);
// $ExpectError: Wrong number of parameters
(c6.CALL.fn: typeof fn1);
getFoo() {
return this.foo
},
meth1(a: string) {
return 1
},
meth2(a: string, b: number) {
return 1
},
meth7(a: string, b: number, c: string, d: number, e: string, f: number, g: string) {
return 1
},
}
// typings:expect-error
yield apply(obj, obj.foo, [])
yield apply(obj, obj.getFoo, [])
yield apply string>(obj, obj.getFoo, [])
// typings:expect-error
yield apply(obj, 'foo', [])
yield apply(obj, 'getFoo', [])
yield apply(obj, 'getFoo', [])
// typings:expect-error
yield apply(obj, obj.meth1)
// typings:expect-error
yield apply(obj, obj.meth1, [])
// typings:expect-error
yield apply(obj, obj.meth1, [1])
yield apply(obj, obj.meth1, ['a'])
yield apply number>(obj, obj.meth1, ['a'])
const task = yield* this.task.task(category, id)
if ( ! task || ! task[TASK] || ! task.done ) {
this.__utils.log('error', 'onComplete received an invalid task object: ', task)
return
}
try { yield task.done } finally {
// Make the callback if the function is found, otherwise transmit
// a message to console
if ( ! callback ) { return }
if ( Array.isArray(callback) ) {
const fn = this[callback[0]] && this[callback[0]][callback[1]]
if ( typeof fn === 'function' ) { yield apply(this, fn, props) }
} else if ( typeof this[callback] === 'function' ) {
yield apply(this, this[callback], props)
} else if ( typeof callback === 'function' ) {
yield apply(this, callback, props)
} else {
this.__utils.log('error', 'onCompelte callback not found: ', callback)
}
}
},
function* executeReauthenticateLoggedInUser() {
try {
// sign into google
let state = yield select();
logAttemptReauthenticateGoogleAnalytics(state);
const user = yield apply(GoogleSignin, GoogleSignin.signIn);
// sign into our servers
Analytics.setUserID(user.id);
state = yield select();
logAttemptReauthenticateOpenBarbellAnalytics(state);
let json = yield call(API.login, user.idToken);
const origEmail = yield select(AuthSelectors.getEmail);
const isDifferentUser = origEmail !== user.email;
if (isDifferentUser) {
// switch accounts, aka lose everything
yield put(AuthActionCreators.loginSucceeded(json.accessToken, json.refreshToken, user.email, new Date(), json.revision, json.sets));
} else {
// success
// note that we do not utilize the revisions or the set data
// reason being that we only want to exchange our google token for access and refresh tokens
test("It fetches and puts the current user's data",()=>{
const id = `NCC1701`;
const user = {name:"Jean Luc"};
const json = ()=>{};
const response = {json};
const gen = currentUserSaga();
expect(gen.next().value).toEqual(take(GET_CURRENT_USER_INFO));
expect(gen.next({id}).value).toEqual(call(fetch,`http://localhost:8081/user/${id}`));
expect(gen.next(response).value).toEqual(apply(response, json));
expect(gen.next(user).value).toEqual(put(setCurrentUser(user)));
});
});
function* watchPlayback(
player: Spotify.SpotifyPlayer,
partyId: string,
currentTrackRef: TrackReference,
durationMs: number,
) {
while (true) {
const playbackState: Spotify.PlaybackState | null = yield apply(player, player.getCurrentState);
if (!playbackState) {
console.warn('Missing playback state in playback watcher.');
yield call(delay, WATCHER_INTERVAL);
continue;
}
const { paused, position } = playbackState;
yield firebase.database!()
.ref('/parties')
.child(partyId)
.child('playback')
.update({
last_change: firebaseNS.database!.ServerValue.TIMESTAMP,
last_position_ms: position,
playing: !paused,
});
export function* signParitySignerTransactionHandler({
tx,
wallet
}: IFullWalletAndTransaction): SagaIterator {
const from = yield apply(wallet, wallet.getAddressString);
const rlp = yield call(transactionToRLP, tx);
yield put(paritySignerActions.requestTransactionSignature(from, rlp));
const { payload }: paritySignerTypes.FinalizeSignatureAction = yield take(
paritySignerTypes.ParitySignerActions.FINALIZE_SIGNATURE
);
const signedTransaction: Buffer = yield call(signTransactionWithSignature, tx, payload);
const indexingHash: string = yield call(computeIndexingHash, signedTransaction);
yield put(
actions.signLocalTransactionSucceeded({
signedTransaction,
indexingHash,
noVerify: false
})
export function* signLocalTransactionHandler({
tx,
wallet
}: IFullWalletAndTransaction): SagaIterator {
const signedTransaction: Buffer = yield apply(wallet, wallet.signRawTransaction, [tx]);
const indexingHash: string = yield call(computeIndexingHash, signedTransaction);
yield put(signLocalTransactionSucceeded({ signedTransaction, indexingHash, noVerify: false }));
}
export function* handleFetchWalkthroughIllusts(action) {
const { nextUrl, options } = action.payload;
try {
let response;
if (nextUrl) {
response = yield apply(pixiv, pixiv.requestUrl, [nextUrl]);
} else {
response = yield apply(pixiv, pixiv.illustWalkthrough, [options]);
}
const normalized = normalize(
response.illusts.filter(illust => illust.visible && illust.id),
Schemas.ILLUST_ARRAY,
);
yield put(
fetchWalkthroughIllustsSuccess(normalized.entities, normalized.result),
);
} catch (err) {
yield put(fetchWalkthroughIllustsFailure());
yield put(addError(err));
}
}