code: function onlyForApps(expectedPlatform) {
    const stack = new Error().stack || '';
    const re = /Appium.(\w+)/g;
    const caller = stack.split('\n')[2].trim();
    const m = re.exec(caller);
  
    if (!m) {
      throw new Error(`Invalid caller ${caller}`);
    }
  
    const callerName = m[1] || m[2];
    if (!expectedPlatform) {
      if (!this.platform) {
        throw new Error(`${callerName} method can be used only with apps`);
      }
    } else if (this.platform !== expectedPlatform.toLowerCase()) {
      throw new Error(`${callerName} method can be used only with ${expectedPlatform} apps`);
    }
  }
docs: in the end of a file