Author: f5tmfo7v9vgt

  • ngx-material-timepicker

    Angular Material Timepicker

    Build Status codecov npm version

    Handy multifunctional material design timepicker for Angular 6.0+

    Demo

    https://agranom.github.io/ngx-material-timepicker/

    Table of contents

    Getting started

    Install timepicker through npm:

    npm install --save ngx-material-timepicker
    npm install --save luxon
    

    Next import the timepicker module into your app’s module:

    import {NgModule} from '@angular/core';
    import {NgxMaterialTimepickerModule} from 'ngx-material-timepicker';
    
    @NgModule({
      imports: [NgxMaterialTimepickerModule]
    })
    export class MyModule {}

    Finally connect the timepicker to an input via a template property:

    <input [ngxTimepicker]="picker">
    <ngx-material-timepicker #picker></ngx-material-timepicker>
    

    The timepicker opens once you click on the input

    Internationalization

    Timepicker supports locales in format BCP 47. It has en-US locale by default.

    To override default locale and numbering system (latn or arab):

    import {NgModule} from '@angular/core';
    import {NgxMaterialTimepickerModule} from 'ngx-material-timepicker';
    
    @NgModule({
      imports: [NgxMaterialTimepickerModule.setOpts('ar-AE', 'arab')]
    })
    export class MyModule {}

    Documentation

    API reference for Angular Material Timepicker

    import {NgxMaterialTimepickerModule} from 'ngx-material-timepicker';

    NgxTimepicker

    Directive responsible for managing the timepicker popup and setting value to input

    Selector: ngxTimepicker

    Properties

    Name Description
    @Input()
    ngxTimepicker: NgxMaterialTimepickerComponent The timepicker that this input is associated with.
    @Input()
    disabled: boolean Weather the timepicker popup should be disabled.
    @Input()
    value: string Set a default value and time for a timepicker. The format of the time is in 12 hours notation 11:00 PM or in 24 hours notation 23:00. A Date string won’t work.
    @Input()
    format: number 12 or 24 . 12h/24h view for hour selection clock . 12 (AM/PM) format by default.
    @Input()
    min: string or DateTime Set min time for timepicker (11:15 pm )
    @Input()
    max: string or DateTime Set max time for timepicker (11:15 pm )
    @Input()
    disableClick: boolean Set true to disable opening timepicker by clicking on the input

    NgxMaterialTimepickerComponent

    Component responsible for visualisation the timepicker

    Selector: ngx-material-timepicker

    Properties

    Name Description
    @Input()
    cancelBtnTmpl: TemplateRef Set if you want to change cancel button to your custom one.
    @Input()
    confirmBtnTmpl: TemplateRef Set if you want to change confirm button to your custom one.
    @Input()
    editableHintTmpl: TemplateRef Set if you want to change dial hint to your custom one. Works only if enableKeyboardInput = true
    @Input()
    ESC: boolean Disable or enable closing timepicker by ESC.
    @Input()
    enableKeyboardInput: boolean To disable or enable changing time through a keyboard on the timepicker dial without interaction with a clock face. Set false by default
    @Input()
    minutesGap: number To define a gap between minutes. Set 1 by default
    @Input()
    defaultTime: string Set default time for a timepicker. 12:00 AM by default
    @Input()
    preventOverlayClick: boolean Set true to prevent closing the timepicker by overlay click. Uses false by default
    @Input()
    disableAnimation: boolean Set true to prevent opening and closing timepicker animation. Uses false by default
    @Input()
    hoursOnly: boolean Set true to prevent switching to minutes automatically once hour is selected. Uses false by default
    @Input()
    theme: NgxMaterialTimepickerTheme Custom css properties which will override the defaults
    @Input()
    timepickerClass: string To provide a custom css class for the timepicker
    @Output()
    timeSet: EventEmitter<string> Emits time when that was set.
    @Output()
    opened: EventEmitter<null> Emits after timepicker was opened.
    @Output()
    closed: EventEmitter<null> Emits after timepicker was closed.
    @Output()
    hourSelected: EventEmitter<number> Emits after hour was selected.
    @Output()
    timeChanged: EventEmitter<string> Emits once time was changed.

    NgxTimepickerFieldComponent

    The timepicker as a control.

    Selector: ngx-timepicker-field

    Properties

    Name Description
    @Input()
    disabled: boolean Whether the timepicker is disabled
    @Input()
    toggleIcon: TemplateRef<HTMLObjectElement> Provide custom svg icon for toggle button
    @Input()
    buttonAlign: ‘right’ or ‘left’ Positioning toggle button (right by default)
    @Input()
    clockTheme: NgxMaterialTimepickerTheme Custom css properties which will override timepicker clock
    @Input()
    controlOnly: boolean Hide or display toggle button with the timepicker clock
    @Input()
    format: number 12 or 24 . Set format for timepicker. 12 (AM/PM) format by default.
    @Input()
    cancelBtnTmpl: TemplateRef<Node> Set if you want to change cancel button for timepicker to your custom one.
    @Input()
    confirmBtnTmpl: TemplateRef<Node> Set if you want to change confirm button for timepicker to your custom one.
    @Input()
    min: string or DateTime Set min time for timepicker (11:15 pm )
    @Input()
    max: string or DateTime Set max time for timepicker (11:15 pm )
    @Input()
    minutesGap: number To define a gap between minutes. Set 1 by default
    @Output()
    timeChanged: EventEmitter<string> Emit a new time once it is changed.

    NgxMaterialTimepickerToggleComponent

    Component responsible for opening the timepicker.

    Selector: ngx-material-timepicker-toggle

    Properties

    Name Description
    @Input()
    for: NgxMaterialTimepickerComponent Timepicker instance that the button will toggle
    @Input()
    disabled: boolean Whether the toggle button is disabled

    NgxMaterialTimepickerToggleIconDirective

    Can be used to override the icon of a NgxMaterialTimepickerToggleComponent.

    Selector: [ngxMaterialTimepickerToggleIcon]

    NgxMaterialTimepickerThemeDirective (deprecated)

    Can be used to override styles of a NgxMaterialTimepicker.

    Selector: ngx-material-timepicker[ngxMaterialTimepickerTheme]

    Properties

    Name Description
    @Input()
    ngxMaterialTimepickerTheme: NgxMaterialTimepickerTheme Custom css properties which will override the defaults

    Development

    Prepare your environment

    Install local dev dependencies: npm install while current directory is this repo.

    Development server

    Run npm start to start a development server on a port 4200.

    Open http//:localhost:4200 on your browser.

    Tests

    Run npm test to run tests once or npm run test:watch to continually run tests.

    License

    MIT

    Visit original content creator repository https://github.com/Agranom/ngx-material-timepicker
  • ngx-material-timepicker

    Angular Material Timepicker

    Build Status
    codecov
    npm version

    Handy multifunctional material design timepicker for Angular 6.0+

    Demo

    https://agranom.github.io/ngx-material-timepicker/

    Table of contents

    Getting started

    Install timepicker through npm:

    npm install --save ngx-material-timepicker
    npm install --save luxon
    

    Next import the timepicker module into your app’s module:

    import {NgModule} from '@angular/core';
    import {NgxMaterialTimepickerModule} from 'ngx-material-timepicker';
    
    @NgModule({
      imports: [NgxMaterialTimepickerModule]
    })
    export class MyModule {}

    Finally connect the timepicker to an input via a template property:

    <input [ngxTimepicker]="picker">
    <ngx-material-timepicker #picker></ngx-material-timepicker>
    

    The timepicker opens once you click on the input

    Internationalization

    Timepicker supports locales in format BCP 47. It has en-US locale by default.

    To override default locale and numbering system (latn or arab):

    import {NgModule} from '@angular/core';
    import {NgxMaterialTimepickerModule} from 'ngx-material-timepicker';
    
    @NgModule({
      imports: [NgxMaterialTimepickerModule.setOpts('ar-AE', 'arab')]
    })
    export class MyModule {}

    Documentation

    API reference for Angular Material Timepicker

    import {NgxMaterialTimepickerModule} from 'ngx-material-timepicker';

    NgxTimepicker

    Directive responsible for managing the timepicker popup and setting value to input

    Selector: ngxTimepicker

    Properties

    Name Description
    @Input()
    ngxTimepicker: NgxMaterialTimepickerComponent The timepicker that this input is associated with.
    @Input()
    disabled: boolean Weather the timepicker popup should be disabled.
    @Input()
    value: string Set a default value and time for a timepicker. The format of the time is in 12 hours notation 11:00 PM or in 24 hours notation 23:00. A Date string won’t work.
    @Input()
    format: number 12 or 24 . 12h/24h view for hour selection clock . 12 (AM/PM) format by default.
    @Input()
    min: string or DateTime Set min time for timepicker (11:15 pm )
    @Input()
    max: string or DateTime Set max time for timepicker (11:15 pm )
    @Input()
    disableClick: boolean Set true to disable opening timepicker by clicking on the input

    NgxMaterialTimepickerComponent

    Component responsible for visualisation the timepicker

    Selector: ngx-material-timepicker

    Properties

    Name Description
    @Input()
    cancelBtnTmpl: TemplateRef Set if you want to change cancel button to your custom one.
    @Input()
    confirmBtnTmpl: TemplateRef Set if you want to change confirm button to your custom one.
    @Input()
    editableHintTmpl: TemplateRef Set if you want to change dial hint to your custom one. Works only if enableKeyboardInput = true
    @Input()
    ESC: boolean Disable or enable closing timepicker by ESC.
    @Input()
    enableKeyboardInput: boolean To disable or enable changing time through a keyboard on the timepicker dial without interaction with a clock face. Set false by default
    @Input()
    minutesGap: number To define a gap between minutes. Set 1 by default
    @Input()
    defaultTime: string Set default time for a timepicker. 12:00 AM by default
    @Input()
    preventOverlayClick: boolean Set true to prevent closing the timepicker by overlay click. Uses false by default
    @Input()
    disableAnimation: boolean Set true to prevent opening and closing timepicker animation. Uses false by default
    @Input()
    hoursOnly: boolean Set true to prevent switching to minutes automatically once hour is selected. Uses false by default
    @Input()
    theme: NgxMaterialTimepickerTheme Custom css properties which will override the defaults
    @Input()
    timepickerClass: string To provide a custom css class for the timepicker
    @Output()
    timeSet: EventEmitter<string> Emits time when that was set.
    @Output()
    opened: EventEmitter<null> Emits after timepicker was opened.
    @Output()
    closed: EventEmitter<null> Emits after timepicker was closed.
    @Output()
    hourSelected: EventEmitter<number> Emits after hour was selected.
    @Output()
    timeChanged: EventEmitter<string> Emits once time was changed.

    NgxTimepickerFieldComponent

    The timepicker as a control.

    Selector: ngx-timepicker-field

    Properties

    Name Description
    @Input()
    disabled: boolean Whether the timepicker is disabled
    @Input()
    toggleIcon: TemplateRef<HTMLObjectElement> Provide custom svg icon for toggle button
    @Input()
    buttonAlign: ‘right’ or ‘left’ Positioning toggle button (right by default)
    @Input()
    clockTheme: NgxMaterialTimepickerTheme Custom css properties which will override timepicker clock
    @Input()
    controlOnly: boolean Hide or display toggle button with the timepicker clock
    @Input()
    format: number 12 or 24 . Set format for timepicker. 12 (AM/PM) format by default.
    @Input()
    cancelBtnTmpl: TemplateRef<Node> Set if you want to change cancel button for timepicker to your custom one.
    @Input()
    confirmBtnTmpl: TemplateRef<Node> Set if you want to change confirm button for timepicker to your custom one.
    @Input()
    min: string or DateTime Set min time for timepicker (11:15 pm )
    @Input()
    max: string or DateTime Set max time for timepicker (11:15 pm )
    @Input()
    minutesGap: number To define a gap between minutes. Set 1 by default
    @Output()
    timeChanged: EventEmitter<string> Emit a new time once it is changed.

    NgxMaterialTimepickerToggleComponent

    Component responsible for opening the timepicker.

    Selector: ngx-material-timepicker-toggle

    Properties

    Name Description
    @Input()
    for: NgxMaterialTimepickerComponent Timepicker instance that the button will toggle
    @Input()
    disabled: boolean Whether the toggle button is disabled

    NgxMaterialTimepickerToggleIconDirective

    Can be used to override the icon of a NgxMaterialTimepickerToggleComponent.

    Selector: [ngxMaterialTimepickerToggleIcon]

    NgxMaterialTimepickerThemeDirective (deprecated)

    Can be used to override styles of a NgxMaterialTimepicker.

    Selector: ngx-material-timepicker[ngxMaterialTimepickerTheme]

    Properties

    Name Description
    @Input()
    ngxMaterialTimepickerTheme: NgxMaterialTimepickerTheme Custom css properties which will override the defaults

    Development

    Prepare your environment

    Install local dev dependencies: npm install while current directory is this repo.

    Development server

    Run npm start to start a development server on a port 4200.

    Open http//:localhost:4200 on your browser.

    Tests

    Run npm test to run tests once or npm run test:watch to continually run tests.

    License

    MIT

    Visit original content creator repository
    https://github.com/Agranom/ngx-material-timepicker

  • but-flp-project-1

    RLG to NFSM/RRG Converter

    RLG to NFSM/RRG Converter is an application written in Haskell that allows you to convert RLGs (right linear grammars) into NFSMs (non-deterministic finite state machines) or RRGs (right regular grammars). RLGs cannot contain simple rules (e.g. A -> B).

    Installation

    To compile the app it is necessary to have the GHC compiler installed. To create the flp21-fun binary run:

    git clone https://github.com/TomasBeranek/but-flp-project-1.git
    cd but-flp-project-1/
    make
    

    Usage

    The app can be run:

    flp21-fun OPTION [INPUT_FILE]
    

    where

    • OPTION is one of:
      • -i prints the loaded RLG to stdout. The printed RLG is in the standard format, i.e. without duplicates, alphabetically sorted, etc.
      • -1 prints the converted RRG to stdout in the same standard format as the input RLG. The exception is newly created non-terminals, which can be named A1, B1, etc.
      • -2 prints the converted NFSM to stdout.
    • INPUT_FILE is an optional parameter containing the name of the input file. If the file is not specified, the program reads the input from stdin.

    For examples of RLG input formats and RRG/NFSM output formats, see the tests/ directory.

    Tests

    To run the tests, run:

    make test
    

    Each test is run in both stdin and INPUT_FILE mode.

    Test descriptions

    • test01 – RRG from the assignment. Output NFSM.
    • test02 – RRG with duplicities. Output RLG.
    • test03 – RLG with single simple full-terminal rule. Output RLG.
    • test04 – RRG with duplicities and wrong alphabetical order. Output RRG.
    • test05 – RLG with single simple full-terminal rule. Output RRG.
    • test06 – RLG with more complex full-terminal and non-terminal rules. Output RRG.
    • test07 – exceeding simple non-terminal names by splitting rules. Output RRG.
    • test08 – same as test05. Output NFSM.
    • test09 – same as test06. Output NFSM.
    • test10 – same as test07. Output NFSM.
    • test11 – random RLG. Output NFSM.
    • test12 – random RLG. Output NFSM.
    • test13 – random RLG. Output NFSM.
    • test14 – incorrect program option. Output ERROR.
    • test15 – more than one correct argument. Output ERROR.
    • test16 – zero arguments. Output ERROR.
    • test17 – more than one file. Output ERROR.
    • test18 – empty input. Output ERROR.
    • test19 – empty non-terminal set. Output ERROR.
    • test20 – incorrect format of non-terminal set. Output ERROR.
    • test21 – empty terminal set. Output ERROR.
    • test22 – incorrect format of terminal set. Output ERROR.
    • test23 – no starting symbol. Output ERROR.
    • test24 – incorrect format of starting symbol. Output ERROR.
    • test25 – empty rule set. Output ERROR.
    • test26 – incorrect format of rule set. Output ERROR.
    • test27 – rules contain non-existing non-terminal. Output ERROR.
    • test28 – rules contain non-existing terminal. Output ERROR.
    • test29 – terminal set is empty and rule set contains only #-rules. Output NFSM.
    • test30 – starting symbol is non-existing non-terminal. Output ERROR.

    Features implemented beyond requirements

    • checking of the format of program input arguments. See test14-17.
    • checking of the format of input RLG. See test18-30.
    • set of tests.
    • script tests/tester.py for automated testing.

    Visit original content creator repository
    https://github.com/TomasBeranek/but-flp-project-1

  • openmrs-module-dermimage

    Visit original content creator repository
    https://github.com/dermatologist/openmrs-module-dermimage

  • text-cluster

    Motivating question

    Given a stream of data, how do we cluster it into topics?

    Initialization

    To initialize the repository and launch Jupyer notebooks for playing around:

    python -m venv env  
    . env/bin/activate  
    pip install -r requirements.txt  
    jupyter notebook
    

    Usage:

    Offline clustering with TF-IDF, no preprocessing (notebook 01)
    text = pd.read_csv('../data/talk_radio.csv')
    clustering = Cluster(text.sentences)
    results = clustering(method='kmeans', vectorizer=None,
                         reduce_dim=None, viz=True, n_clusters=10)
    
    Online clustering with TF-IDF, preprocess text (notebook 02)
    streamer = StreamData(filename='../data/talk_radio.csv', chunk=500, use_column='sentences')
    init_text = streamer._init_data(10)
    online = OnlineCluster(text=list(init_text.processed), method='kmeans', n_clusters=10)
    num_batches = 25
    
    for _ in tqdm(range(num_batches)):
        new_text = streamer()
        labels = online.predict(list(new_text.processed))
        fig = online.viz3D()
        # fig.savefig('../data/out-%s.png' % (str(datetime.now()).split(' ')[1]))
    
    _ = online.top_terms(topx=10)
    
    Online clustering with Continuous Bag of Words, no preprocessing (notebook 03)
    streamer = StreamData(filename='../data/talk_radio.csv', chunk=1000, use_column=None)
    init_text = list(streamer._init_data(5).sentences)
    online = OnlineCluster(text=init_text, method='kmeans', n_clusters=25, vectorizer=CBoW(), viz=True)
    
    Visit original content creator repository https://github.com/shayneobrien/text-cluster
  • meson-player

    Meson Player – an invisible audio player

    Meson Player is a very convenient audio player if you don’t need any flashy GUI to control the playback or manage playlists. You just run it and then forget about it. The player is running in a background. Switching tracks, volume control, loading and saving playlists, all of this can be done via global hotkeys. Therefore, you can control the player while working in any application.

    Features

    • almost no GUI (except a tray popup menu, but you can hide the tray icon as well)
    • controlled via global hotkeys
    • supports a lot of stream/tracker formats
    • gapless playback
    • additional formats support can be added by plugins
    • supports Internet radio stations
    • supports CUE sheets
    • can control system audio volume
    • can remove tracks to Trash
    • a big variety of options allows to change the app’s behavior and appearance
    • Last.FM scrobbling

    Supported systems

    • Ubuntu v19.10 64-bit (may not work on Wayland)
    • Windows 10 v1909 64-bit
    • OSX Catalina

    Download

    https://sourceforge.net/projects/mesonplayer/files/mesonplayer/

    Quick start

    1. Right-click on any folder with music or a playlist.
    2. Choose “Open in Meson Player” from a context menu (on Linux this procedure may vary depending on your distro).

    Help

    The complete manual can be found at manual/index.html. Also you can open that manual from the application. Choose Help > Manual from the tray context menu.

    Project support

    If you want to help a project then the best you can do it is to report any bugs you found. To submit a bug follow this link: https://github.com/alkatrazstudio/meson-player/issues

    If you have other suggestions on how to improve the project, for example, about new functionality, you can use the same link above.

    Also, you can mail me directly. zxed@alkatrazstudio.net – Alexey Parfenov

    Screenshots

    Meson Player on Kubuntu

    Meson Player on Ubuntu

    Meson Player on Manjaro Xfce

    Meson Player on Windows

    Meson Player on OSX

    License

    GPLv3+

    (c) Alkatraz Studio, 2012

    Visit original content creator repository https://github.com/alkatrazstudio/meson-player
  • cljs-exe

    cljs-exe

    cljs-exe is a Boot template to create a Clojurescript application that will compile to a native binary using nexe.

    Clojars Project

    Motivation

    nexe, on which this project is based, lists these reasons:

    • Ability to run multiple applications with different node.js runtimes.
    • Distributable binaries without needing node / npm.
    • Starts faster.
    • Lockdown specific application versions, and easily rollback.
    • Faster deployments.

    I’ll second those and add: “In ClojureScript.”

    Quickstart

    You will need

    $ brew install boot-clj
    $ boot -d boot/new new -S -t cljs-exe -n your_project_name
    $ cd your_project_name
    $ boot package
    

    This will compile some sample Clojurescript code to Javascript, then compiling the Javascript to a native binary.

    Tasks

    This project template gives you a few boot tasks:

    • build: runs the Clojurescript compiler with defaults that include: fetching npm dependencies that are listed in the js-dependencies var in build.boot, emitting source maps, and no compiler optimizations.
    • dev: runs build in a watch loop, rerunning build anytime you change a source file.
    • binary: compiles the current project Javascript into a native binary on your platform.
    • package: compiles Clojurescript to Javascript with simple compiler optimizations and no source maps, then compiles that Javascript to a native binary on your platform.
    Visit original content creator repository https://github.com/ckampfe/cljs-exe
  • obs-websocket-js

    obs-websocket-js

    obs-websocket-js allows Javascript-based connections to the Open Broadcaster Software plugin obs-websocket.
    Created by Brendan Hagan
    Maintained by OBS Websocket Community

    Download | Samples | Changelog

    Version Warning!

    You are currently reading the documentation for v5. For v4 documentation look here


    Installation

    Via package manager

    Using a package manager like npm / yarn is the recommended installation method when you’re planning to use obs-websocket-js in node.js, building a web app that you’ll bundle with webpack or rollup, or for using type definitions.

    npm install obs-websocket-js
    yarn add obs-websocket-js

    Standalone file / CDN build

    Standalone js file is available from jsdeliver & unpkg CDN’s:

    https://cdn.jsdelivr.net/npm/obs-websocket-js
    https://unpkg.com/obs-websocket-js
    

    Usage

    Builds

    dist folder of the npm package includes 2 different builds to support different message encodings supported by obs-websocket.

    Connection Encoding JSON Msgpack
    Used by default By web bundles By node.js
    Manually opting into import OBSWebSocket from 'obs-web-socket/json' import OBSWebSocket from 'obs-web-socket/msgpack'
    Benefits Easier debugging, smaller bundle Connection uses less bandwidth
    Downsides Connection uses more bandwidth Harder to debug, bigger bundle size

    In addition each version has both modern and legacy builds. Modern bundlers will opt into modern build which uses most modern JS features while also being supported by most modern browsers. If you need support for older browsers, make sure to configure your bundler to also transpile dependencies with babel or other such .

    Creating an OBS Websocket client

    OBSWebSocket is available as a named export in ES Modules:

    import { OBSWebSocket } from 'obs-websocket-js';
    
    const obs = new OBSWebSocket();

    When using commonjs require() it is available under the OBSWebSocket object key:

    const { OBSWebSocket } = require('obs-websocket-js');
    const OBSWebSocket = require('obs-websocket-js').OBSWebSocket;
    
    const obs = new OBSWebSocket();

    Connecting

    connect(url = 'ws://127.0.0.1:4455', password?: string, identificationParams = {}): Promise

    To connect to obs-websocket server use the connect method.

    Parameter Description
    url
    string (optional)
    Websocket URL to connect to, including protocol. (For example when connecting via a proxy that supports https use wss://127.0.0.1:4455)
    password
    string (optional)
    Password required to authenticate with obs-websocket server
    identificationParams
    object (optional)
    Object with parameters to send with the Identify message
    Use this to include RPC version to guarantee compatibility with server

    Returns promise that resolves to data from Hello and Identified messages or rejects with connection error (either matching obs-websocket WebSocketCloseCode or with code -1 when non-compatible server is detected).

    import OBSWebSocket, {EventSubscription} from 'obs-websocket-js';
    const obs = new OBSWebSocket();
    
    // connect to obs-websocket running on localhost with same port
    await obs.connect();
    
    // Connect to obs-ws running on 192.168.0.4
    await obs.connect('ws://192.168.0.4:4455');
    
    // Connect to localhost with password
    await obs.connect('ws://127.0.0.1:4455', 'super-sekret');
    
    // Connect expecting RPC version 1
    await obs.connect('ws://127.0.0.1:4455', undefined, {rpcVersion: 1});
    
    // Connect with request for high-volume event
    await obs.connect('ws://127.0.0.1:4455', undefined, {
      eventSubscriptions: EventSubscription.All | EventSubscription.InputVolumeMeters,
      rpcVersion: 1
    });
    
    // A complete example
    try {
      const {
        obsWebSocketVersion,
        negotiatedRpcVersion
      } = await obs.connect('ws://192.168.0.4:4455', 'password', {
        rpcVersion: 1
      });
      console.log(`Connected to server ${obsWebSocketVersion} (using RPC ${negotiatedRpcVersion})`)
    } catch (error) {
      console.error('Failed to connect', error.code, error.message);
    }

    Reidentify

    reidentify(data: {}): Promise

    To update session parameters set by initial identification use reidentify method.

    Parameter Description
    data
    object
    Object with parameters to send with the Reidentify message

    Returns promise that resolves when the server has acknowledged the request

    await obs.reidentify({
      eventSubscriptions: EventSubscription.General | EventSubscription.InputShowStateChanged
    });

    Disconnecting

    disconnect(): Promise

    Disconnects from obs-websocket server. This keeps any registered event listeners.

    Returns promise that resolves when connection is closed

    await obs.disconnect();

    Sending Requests

    call(requestType: string, requestData?: object): Promise

    Sending requests to obs-websocket is done via call method.

    Parameter Description
    requestType
    string
    Request type (see obs-websocket documentation)
    requestData
    object (optional)
    Request data (see obs-websocket documentation for the request)

    Returns promise that resolves with response data (if applicable) or rejects with error from obs-websocket.

    // Request without data
    const {currentProgramSceneName} = await obs.call('GetCurrentProgramScene');
    
    // Request with data
    await obs.call('SetCurrentProgramScene', {sceneName: 'Gameplay'});
    
    // Both together now
    const {inputMuted} = obs.call('ToggleInputMute', {inputName: 'Camera'});

    Sending Batch Requests

    callBatch(requests: RequestBatchRequest[], options?: RequestBatchOptions): Promise<ResponseMessage[]>

    Multiple requests can be batched together into a single message sent to obs-websocket using the callBatch method. The full request list is sent over the socket at once, obs-websocket executes the requests based on the options provided, then returns the full list of results once all have finished.

    Parameter Description
    requests
    RequestBatchRequest[]
    The list of requests to be sent (see obs-websocket documentation). Each request follows the same structure as individual requests sent to call.
    options
    RequestBatchOptions (optional)
    Options controlling how obs-websocket will execute the request list.
    options.executionType
    RequestBatchExecutionType (optional)
    The mode of execution obs-websocket will run the batch in
    options.haltOnFailure
    boolean (optional)
    Whether obs-websocket should stop executing the batch if one request fails

    Returns promise that resolve with a list of results, one for each request that was executed.

    // Execute a transition sequence to a different scene with a specific transition.
    const results = await obs.callBatch([
      {
        requestType: 'GetVersion',
      },
      {
        requestType: 'SetCurrentPreviewScene',
        requestData: {sceneName: 'Scene 5'},
      },
      {
        requestType: 'SetCurrentSceneTransition',
        requestData: {transitionName: 'Fade'},
      },
      {
        requestType: 'Sleep',
        requestData: {sleepMillis: 100},
      },
      {
        requestType: 'TriggerStudioModeTransition',
      }
    ])

    Currently, obs-websocket-js is not able to infer the types of ResponseData to any specific request’s response. To use the data safely, cast it to the appropriate type for the request that was sent.

    (results[0].responseData as OBSResponseTypes['GetVersion']).obsVersion //=> 28.0.0

    Receiving Events

    on(event: string, handler: Function)
    once(event: string, handler: Function)
    off(event: string, handler: Function)
    addListener(event: string, handler: Function)
    removeListener(event: string, handler: Function)

    To listen for events emitted by obs-websocket use the event emitter API methods.

    Parameter Description
    event
    string
    Event type (see obs-websocket documentation)
    handler
    Function
    Function that is called when event is sent by the server. Receives data as the first argument (see obs-websocket documentation for the event)
    function onCurrentSceneChanged(event) {
      console.log('Current scene changed to', event.sceneName)
    }
    
    obs.on('CurrentSceneChanged', onCurrentSceneChanged);
    
    obs.once('ExitStarted', () => {
      console.log('OBS started shutdown');
    
      // Just for example, not necessary should you want to reuse this instance by re-connect()
      obs.off('CurrentSceneChanged', onCurrentSceneChanged);
    });

    Internally eventemitter3 is used and it’s documentation can be referenced for advanced usage

    Internal events

    In addition to obs-websocket events, following events are emitted by obs-websocket-js client itself:

    • ConnectionOpened – When connection has opened (no data)
    • ConnectionClosed – When connection closed (called with OBSWebSocketError object)
    • ConnectionError – When connection closed due to an error (generally above is more useful)
    • Hello – When server has sent Hello message (called with Hello data)
    • Identified – When client has connected and identified (called with Identified data)

    Typescript Support

    This library is written in typescript and typescript definitions are published with the package. Each package is released with typescript definitions matching the currently released version of obs-websocket. This data can be reused from OBSEventTypes, OBSRequestTypes and OBSResponseTypes named exports, though in most cases function parameters will enforce the typings correctly.

    import OBSWebSocket, {OBSEventTypes, OBSRequestTypes, OBSResponseTypes} from 'obs-websocket-js';
    
    function onProfileChanged(event: OBSEventTypes['CurrentProfileChanged']) {
      event.profileName
    }
    
    obs.on('CurrentProfileChanged', onProfileChanged);
    obs.on('VendorEvent', ({vendorName, eventType, eventData}) => {
      if (vendorName !== 'fancy-plugin') {
        return;
      }
    });
    
    const req: OBSRequestTypes['SetSceneName'] = {
      sceneName: 'old-and-busted',
      newSceneName: 'new-hotness'
    };
    obs.call('SetSceneName', req);
    obs.call('SetInputMute', {
      inputName: 'loud noises',
      inputMuted: true
    });

    Debugging

    To enable debug logging, set the DEBUG environment variable:

    # Enables debug logging for all modules of osb-websocket-js
    DEBUG=obs-websocket-js:*
    
    # on Windows
    set DEBUG=obs-websocket-js:*

    If you have multiple libraries or application which use the DEBUG environment variable, they can be joined with commas:

    DEBUG=foo,bar:*,obs-websocket-js:*
    
    # on Windows
    set DEBUG=foo,bar:*,obs-websocket-js:*

    Browser debugging uses localStorage

    localStorage.debug = 'obs-websocket-js:*';
    
    localStorage.debug = 'foo,bar:*,obs-websocket-js:*';

    For more information, see the debug package documentation.

    Upgrading

    Projects Using obs-websocket-js

    Share your project in github discussions!

    Visit original content creator repository https://github.com/obs-websocket-community-projects/obs-websocket-js
  • position-in-file-async

    position-in-file-async

    A node.js util to find asynchronously element position on a file of a folder.

    position-in-file-async is the async version of position-in-file.

    How to use :

    Install position-in-file-async via npm :

    npm install --save position-in-file-async
    

    Use it :

    const positionInFileAsync = require('position-in-file-async')
    
    //positionInFileAsync(needle, haystack, options)
    
    //Exemple :
    positionInFileAsync('element-to-look-for', 'where-to-search', {deep: false, ...}).then(result => console.log(result))
    
    //Result : 
    [
    	{file: 'finded-in-this-file.ext', lines: {2: [5]}}, //Line 2 column 5
    	{file: 'finded-here.too.ext', lines: {1: [2, 19]}}, //Line 1 column 5, line 1 column 19
    	...
    ]

    If node doest display deep object you can use util.inspect :

    	const inspect = require('util').inspect
    	
    	positionInFileAsync('element-to-look-for', 'where-to-search').then(result => console.log(inspect(result, {showHidden: false, depth: null})))

    Parameters

    • needle (String || RegExp) : The element to search, can be a string or a regular expression.
    • haystack (String) : The path where the research will be executed, it can be a file or folder path. If haystack is not defined the research will be excecuted in the current folder.
    • options (Object) : Some aditionnals options :
      • deep (Boolean) : If the research will be apply on deep folder. Default : true.
      • ignore : (Array) An array to define the file/filter to ignore. Default : empty array.
      • fullPathRequired (Boolean) : If full path need to be specified on option.ignore or just the file name. Default : true.
      • gitIgnore (Boolean) : If .gitIgnore’s file/folder need to be ignored. Default : true.

    License :

    MIT

    Visit original content creator repository https://github.com/arncet/position-in-file-async
  • llvm-project

    Visit original content creator repository
    https://github.com/L1ghtmann/llvm-project