UNPKG

@dderevjanik/termux-api

Version:

This library allows you to interact with your Android device from Node.js using termux-api

27 lines (26 loc) 763 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.vibrate = vibrate; const child_process_1 = require("child_process"); /** * Vibrate the device */ async function vibrate(options = {}) { const opts = { duration: 1_000, // number: "", ...options, }; return new Promise((resolve, reject) => { const command = `termux-vibrate -d ${opts.duration} ${opts.force ? "-f" : ""}`; (0, child_process_1.exec)(command, (error, stdout, stderr) => { if (error) { return reject(`Error: ${error.message}`); } if (stderr) { return reject(`Error: ${stderr}`); } return resolve(); }); }); }