@iabtechlabtcf/stub
Version:
CMP API Stub code
58 lines (41 loc) • 1.37 kB
Markdown
[](https://www.npmjs.com/package/@iabtechlabtcf/stub)
[](https://www.npmjs.org/package/@iabtechlabtcf/stub)
[](https://circleci.com/gh/InteractiveAdvertisingBureau/iabtcf-es)
# @iabtechlabtcf/stub
Cmp API Stub code. Maybe included in commonjs loader or dropped directly on the page.
#### Installation
npm
```
npm install @iabtechlabtcf/stub
```
yarn
```
yarn add @iabtechlabtcf/stub
```
#### Using
##### include via module loading
```javascript
import * as cmpstub from '@iabtechlabtcf/stub';
```
or
```javascript
const cmpstub = require('@iabtechlabtcf/stub');
```
then execute:
```javascript
cmpstub();
```
this should generate the `__tcfapi()` window function with the queing functionality.
##### to drop on a page
```
git clone https://github.com/InteractiveAdvertisingBureau/iabtechlabtcf-es.git
cd iabtechlabtcf-es/modules/stub/
yarn // or npm install
yarn build // or npm run build
```
Built stub will be output to ./lib
##### Getting queue of commands
```javascript
const queue = __tcfapi();
console.log(queue); // [ ['command', 2, callback], ...]
```