Skip to content

StevenElberger/WKW

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

WKW

WKW - Client Side JS Wrapper for WaniKani API

Properties

  • getUser function takes an api key and returns a user object

proto

Prototype for user's data objects. Contains basic state and functionality (e.g., expiration and emptiness).

Properties

  • time number the expiration time for this data type
  • isEmpty boolean whether or not this object is "empty"
  • apiResourceLoc string the location of this data type from the API's URL
  • userResourceLoc string the name of this data type's key in the user object
  • expiration number unix timestamp for when this object was created
  • isExpired function returns whether or not this data has expired

makeProto

Factory function for objects that have proto as their prototype.

Parameters

  • overrides object properties to overwrite in this object's prototype

Returns object an object whose prototype is proto

userInformationProto

User information prototype (user.user_information)

Properties

  • username string user's username
  • gravatar string md5 gravatar hash for user's avatar
  • level number user's level
  • title string user's title
  • about string user's about me
  • website string user's website URL
  • twitter string user's twitter handle
  • topics_count number number of topics on message board
  • posts_count number number of posts made by user
  • creation_date number unix timestamp for account creation
  • vacation_date (number | null) unix timestamp for vacation setting

studyQueueProto

Study queue prototype (user.study_queue)

Properties

  • lessons_available number number of lessons currently available
  • reviews_available number number of reviews currently available
  • next_review_date (number | null) unix timestamp for next review (or null if vacation mode)
  • reviews_available_next_hour number number of reviews available within the next hour
  • reviews_available_next_day number number of reviews available within the next day

levelProgressionProto

Level progression prototype (user.level_progression)

Properties

  • radicals_progress number number of radicals completed for the current level
  • radicals_total number total number of radicals for this level
  • kanji_progress number number of kanji completed for the current level
  • kanji_total number total number of kanji for this level

srsDistributionProto

SRS distribution prototype (user.srs_distribution)

Properties

  • apprentice object items at apprentice level
    • apprentice.radicals number the number of radicals
    • apprentice.kanji number the number of kanji
    • apprentice.vocabulary number the number of vocabulary
    • apprentice.total number the total number of items
  • guru object items at guru level (same structure as apprentice)
  • master object items at master level (same structure as apprentice)
  • enlighten object items at enlighten level (same structure as apprentice)
  • burned object items at burned level (same structure as apprentice)

listInterface

Simple list interface object that provides useful functionality to list data objects.

getBy

Returns an array of objects whose specified properties have the specified value.

Parameters

  • prop string the property of each object to look under
  • value string the value to look for of said property

Returns array contains objects whose prop are value

recentUnlocksProto

Recent unlocks list prototype (user.recent_unlocks) 3 different types of objects in here For an example of the objects stored, please see the WaniKani API.

getBy

See listInterface

getRadicals

Returns array containing all radicals in this

getKanji

Returns array containing all kanji in this

getVocabulary

Returns array containing all vocabulary in this

getByCharacter

Parameters

  • character string desired character

Returns array containing all items in this with the given character

getByMeaning

Parameters

  • meaning string desired meaning

Returns array containing all items in this with the given meaning

getByLevel

Parameters

Returns array containing all items in this with the given level

getByUnlockedDate

Parameters

  • unlocked_date number desired unlocked_date

Returns array containing all items in this with the given unlocked date

criticalItemsProto

Critical items list prototype (user.critical_items) 3 different types of objects in here For an example of the objects stored, please see the WaniKani API.

getBy

See listInterface

getRadicals

Returns array containing all radicals in this

getKanji

Returns array containing all kanji in this

getVocabulary

Returns array containing all vocabulary in this

getByCharacter

Parameters

  • character string desired character

Returns array containing all items in this with the given character

getByMeaning

Parameters

  • meaning string desired meaning

Returns array containing all items in this with the given meaning

getByLevel

Parameters

Returns array containing all items in this with the given level

getByPercentage

Parameters

  • percentage number desired percentage

Returns array containing all items in this with the given percentage

radicalsProto

Radicals list prototype (user.radicals) For an example of the objects stored, please see the WaniKani API.

getBy

See listInterface

getByCharacter

Parameters

  • character string desired character

Returns array containing all items in this with the given character

getByMeaning

Parameters

  • meaning string desired meaning

Returns array containing all items in this with the given meaning

getByImage

Parameters

  • image string desired image URL

Returns array containing all items in this with the given image url

getByLevel

Parameters

Returns array containing all items in this with the given level

kanjiProto

Kanji list prototype (user.kanji) For an example of the objects stored, please see the WaniKani API.

getBy

See listInterface

getByCharacter

Parameters

  • character string desired character

Returns array containing all items in this with the given character

getByMeaning

Parameters

  • meaning string desired meaning

Returns array containing all items in this with the given meaning

getByImportantReading

Parameters

  • important_reading string desired important reading

Returns array containing all items in this with given reading

getByLevel

Parameters

Returns array containing all items in this with the given level

vocabularyProto

Vocabulary list prototype (user.vocabulary) For an example of the objects stored, please see the WaniKani API.

getBy

See listInterface

getByCharacter

Parameters

  • character string desired character

Returns array containing all items in this with the given character

getByKana

Parameters

  • kana string desired hiragana or katakana

Returns array containing all items in this with the given kana

getByMeaning

Parameters

  • meaning string desired meaning

Returns array containing all items in this with the given meaning

getByLevel

Parameters

Returns array containing all items in this with the given level

deepCopy

Performs a deep copy on parent over to child. Catches objects / arrays.

Parameters

  • parent object the object to be copied from
  • child object the object to copy to

updateRateLimiting

Updates rate limiting information before making a request to the API.

Parameters

retrieveObjectData

Retrieves data for given object. Takes a spec object with the following attributes:

Parameters

  • spec object spec object for passing params
    • spec.user object the user object
    • spec.obj object the object whose data needs to be retrieved
    • spec.param number optional parameter (e.g., percentages, levels, etc.)
    • spec.force boolean optional param to force the api call regardless of rate limiting

Returns object a Promise object

isExpiredOrEmpty

Checks if an object is expired or empty.

Parameters

Returns boolean whether or not the object is expired or empty

numbersAreValid

Checks if given numbers are valid for certain parameters. (e.g., levels, percentages, etc.)

Parameters

  • numbers (string | number) numbers requested
  • min number the min the numbers can be
  • max number the max the numbers can be

Returns boolean whether or not the given numbers are valid

getSpecObject

Returns object a spec object for any given getter method which should be handed over to retrieveObjectData.

user

prototype object for users

isRateLimited

Returns boolean true if the user is rate limited, false otherwise.

getUserInformation

Retrieves the user's information.

Parameters

  • force boolean whether or not to force the call to the api

Returns object a Promise object

getStudyQueue

Retrieves the user's study queue.

Parameters

  • force boolean whether or not to force the call to the api

Returns object a Promise object

getLevelProgression

Retrieves the user's level progression.

Parameters

  • force boolean whether or not to force the call to the api

Returns object a Promise object

getSRSDistribution

Retrieves the user's SRS distribution.

Parameters

  • force boolean whether or not to force the call to the api

Returns object a Promise object

getRecentUnlocksList

Retrieves the user's recent unlocks list.

Parameters

  • limit string limit for number of items returned
  • force boolean whether or not to force the call to the api

Returns object a Promise object

getCriticalItemsList

Retrieves the user's critical items list.

Parameters

  • percentage string percentage correct
  • force boolean whether or not to force the call to the api

Returns object a Promise object

getRadicalsList

Retrieves the user's radicals list.

Parameters

  • levels string radicals of given level(s)
  • force boolean whether or not to force the call to the api

Returns object a Promise object

getKanjiList

Retrieves the user's kanji list.

Parameters

  • levels string kanji of given level(s)
  • force boolean whether or not to force the call to the api

Returns object a Promise object

getVocabularyList

Retrieves the user's voabulary list.

Parameters

  • levels (string | number) vocabulary of given level(s)
  • force boolean whether or not to force the call to the api

Returns object a Promise object

getAllData

Retrieves all data for the user.

Returns object a Promise object

getUser

Factory for user objects.

Parameters

  • api_key number user's WK API key

Returns object a User object

storageAvailable

Tests whether or not browser supports local storage.

Parameters

  • type

Returns boolean true if supported, false otherwise

getStoredData

Retrieves any data from localStorage and keeps a local cache inside the users object. Called on initializing WKW and available in debug.

saveUsers

Saves the local cache of users (the users object) in localStorage. Called after any data is updated.

About

A JavaScript wrapper for the WaniKani API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages