vk-api-util

Utility methods for working with VK API

Usage no npm install needed!

<script type="module">
  import vkApiUtil from 'https://cdn.skypack.dev/vk-api-util';
</script>

README

vk-api-util Build Status

Utility methods for working with VK API

Install

$ npm install --save vk-api-util

Usage

var vkUtil = require('vk-api-util');

vkUtil.bitMask(['friends', 'photos']);
//=> 6

API

vkUtil.isMethod(method) → boolean

Returns true if given metod is mentioned in VK API docs.

method

Required
Type: string

vkUtil.isOpenMethod(method) → boolean

Returns true if given method doesn't require authentication.

method

Required
Type: string

vkUtil.bitMask(scope) → number

Returns bit mask for given scope.

scope

Required
Type: string, array or number

Pass a string of scopes divided by comma (,) or array of scopes. If number is passed it assumed to be a bit mask itself and returned without changes.

vkUtil.checkScope(area, scope) → boolean

Returns true if given area is visible within given scope.

vkApiUtil.checkScope(['friends', 'video'], 4456466);
//=> true

area

Required
Type: string, array or number

scope

Required
Type: string, array or number

area and scope arguments are same as scope in aforementioned vkUtil.bitMask() method.

vkUtil.isMethodInScope(method, [scope]) → boolean

Returns true if given method is reachable within given scope.

method

Required
Type: string

scope

Type: string, array or number
Default: 0

Related

License

MIT © Dmitriy Sobolev