Skip to content

Commit 8c5458a

Browse files
committed
annotate utils
1 parent c9b4932 commit 8c5458a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/utils/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const _handler = (resolve, reject, err, resp) => {
1818
* @param object
1919
* @returns {{}}
2020
*/
21-
export function reverseKeyValues(object) {
21+
export function reverseKeyValues(object: Object): Object {
2222
const output = {};
2323
for (const key in object) {
2424
output[object[key]] = key;
@@ -29,15 +29,15 @@ export function reverseKeyValues(object) {
2929
/**
3030
* No operation func
3131
*/
32-
export function noop() {
32+
export function noop(): void {
3333
}
3434

3535
/**
3636
* Wraps a native module method to support promises.
3737
* @param fn
3838
* @param NativeModule
3939
*/
40-
export function promisify(fn, NativeModule) {
40+
export function promisify(fn: Function, NativeModule: Object): Function<Promise> {
4141
return (...args) => {
4242
return new Promise((resolve, reject) => {
4343
const _fn = typeof fn === 'function' ? fn : NativeModule[fn];
@@ -56,7 +56,7 @@ export function promisify(fn, NativeModule) {
5656
* @param callback
5757
* @private
5858
*/
59-
function _delayChunk(collection, chunkSize, operation, callback) {
59+
function _delayChunk(collection, chunkSize, operation, callback): void {
6060
const length = collection.length;
6161
const iterations = Math.ceil(length / chunkSize);
6262

@@ -84,7 +84,7 @@ function _delayChunk(collection, chunkSize, operation, callback) {
8484
* @param iterator
8585
* @param cb
8686
*/
87-
export function each(array, chunkSize, iterator, cb) {
87+
export function each(array: Array, chunkSize?: number, iterator: Function, cb: Function): void {
8888
if (typeof chunkSize === 'function') {
8989
cb = iterator;
9090
iterator = chunkSize;
@@ -106,7 +106,7 @@ export function each(array, chunkSize, iterator, cb) {
106106
* @param cb
107107
* @returns {*}
108108
*/
109-
export function map(array, chunkSize, iterator, cb) {
109+
export function map(array: Array, chunkSize?: number, iterator: Function, cb: Function): void {
110110
if (typeof chunkSize === 'function') {
111111
cb = iterator;
112112
iterator = chunkSize;
@@ -137,7 +137,7 @@ const lastRandChars = [];
137137
* @param serverTimeOffset - pass in server time offset from native side
138138
* @returns {string}
139139
*/
140-
export function generatePushID(serverTimeOffset = 0) {
140+
export function generatePushID(serverTimeOffset?: number = 0): string {
141141
const timeStampChars = new Array(8);
142142
let now = new Date().getTime() + serverTimeOffset;
143143
const duplicateTime = (now === lastPushTime);

0 commit comments

Comments
 (0)