Skip to content

Commit

Permalink
Fix module exports and add Typescript Examples (#21)
Browse files Browse the repository at this point in the history
* fix module exports.

* add example for typescript.

* fix test.
  • Loading branch information
Leonardo Salles authored Feb 27, 2020
1 parent 6f3ce50 commit 174c1a9
Show file tree
Hide file tree
Showing 7 changed files with 555 additions and 527 deletions.
14 changes: 14 additions & 0 deletions example/index-dev.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const { Samsung, APPS, KEYS } = require('../lib/index')

/*
Typescript Example for Dinamic Keys
import { $enum } from 'ts-enum-util'
*/

const config = {
debug: true, // Default: false
ip: '192.168.1.2',
Expand All @@ -17,6 +22,15 @@ async function main() {
let token = await control.getTokenPromise()
console.log('$$ token:', token)

/*
Typescript Example
const KeyTypes = $enum(KEYS).getValues()
const getEnumValue = (key: any) => {
return KeyTypes[key]
}
*/

await control.sendKeyPromise(KEYS.KEY_HOME)
await control.sendTextPromise('Text to be inserted in some focused input')
await control.getAppsFromTVPromise()
Expand Down
18 changes: 15 additions & 3 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const Samsung = require('samsung-tv-control')
const { KEYS } = require('samsung-tv-control/lib/keys')
const { APPS } = require('samsung-tv-control/lib/apps')
const { Samsung, APPS, KEYS } = require('../lib/index')

/*
Typescript Example for Dinamic Keys
import { $enum } from 'ts-enum-util'
*/

const config = {
debug: true, // Default: false
Expand All @@ -22,6 +25,15 @@ control
console.info('# Response getToken:', token)
})

/*
Typescript Example for Dinamic Keys
const KeyTypes = $enum(KEYS).getValues()
const getEnumValue = (key: any) => {
return KeyTypes[key]
}
*/

// Send key to TV
control.sendKey(KEYS.KEY_HOME, function(err, res) {
if (!err) {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Samsung from '../index'
import Samsung from '../samsung'
import * as fs from 'fs'

jest.mock('fs')
Expand Down
2 changes: 2 additions & 0 deletions src/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ export enum APPS {
'YouTube' = '111299001912',
'hayu' = '3201806016381',
}

export default APPS
Loading

0 comments on commit 174c1a9

Please sign in to comment.