Skip to content

shikimori/shiki-utils

Repository files navigation

Build Status

shiki-utils

Different tools used in shikimori and in shiki-editor.

flash based on toastify-js

Provides helpers to show flash messages.

import { flash } from 'shiki-utils'
// or to import with tree shaking use
// import { flash } from 'shiki-utils/src/flash';

flash.info('flash.info');
flash.error('flash.error');
flash.notice('flash.notice');
@import './node_modules/shiki-utils/flash.sass';

mobileDetect based on ismobilejs.

Provides detectors of phone, tablet or mobile (combined phone or tablet).

import { mobileDetect, isTablet, isPhone, isMobile } from 'shiki-utils';

isTablet(); // check if it is tablet devise
isPhone(); // check if it is phone devise
isMobile();  // check if it is phone or tablet devise

RequestId

Provides requests counter to avoid handling of irrelevant requests

import { RequestId } from 'shiki-utils';
// or to import with tree shaking use
// import RequestId from 'shiki-utils/src/request_id';

class Autocomplete {
  fetch() {
    const requestId = new RequestId('autocomplete_users');
    const { data } = await fetch(...);

    if (requestId.isCurrent) {
      // handle data
    }
  }
}

ShikiRequest

Provides api to some of shikimori resources .

It uses axios to perform ajax requests.

import { ShikiRequest } from 'shiki-utils';
// or to import with tree shaking use
// import ShikiRequest from 'shiki-utils/src/shiki_request';

import axios from 'axios'

const origin = 'https://shikimori.one';
const shikiRequest = new ShikiRequest(origin, axios)

cosnt reuslt = await shikiRequest.autocomplete('user', 'z');

Package release command

GITHUB_TOKEN=... npm run release