How to use the slugid.nice function in slugid

To help you get started, we’ve selected a few slugid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github higlass / higlass / app / scripts / HiGlassComponent.js View on Github external
if (numericifyVersion(React.version) < 15.6) {
      console.warn(
        'HiGlass requires React v15.6 or higher. Current version: ', React.version
      );
    }

    this.pubSub = createPubSub();
    this.domEvent = createDomEvent(this.pubSub);

    this.pubSubs = [];

    this.minHorizontalHeight = 20;
    this.minVerticalWidth = 20;
    this.resizeSensor = null;

    this.uid = slugid.nice();
    this.tiledPlots = {};
    this.genomePositionSearchBoxes = {};

    // keep track of the xScales of each Track Renderer
    this.xScales = {};
    this.yScales = {};
    this.topDiv = null;
    this.zoomToDataExtentOnInit = new Set();

    // a reference of view / track combinations
    // to be used with combined to viewAndTrackUid
    this.viewTrackUidsToCombinedUid = {};
    this.combinedUidToViewTrack = {};

    // event listeners for when the scales of a view change
    // bypasses the React event framework because this needs
github taskcluster / taskcluster / services / worker-manager / src / providers / google.js View on Github external
await Promise.all(cfgs.map(async cfg => {
      // This must be unique to currently existing instances and match [a-z]([-a-z0-9]*[a-z0-9])?
      // The lost entropy from downcasing, etc should be ok due to the fact that
      // only running instances need not be identical. We do not use this name to identify
      // workers in taskcluster.
      const poolName = workerPoolId.replace(/[\/_]/g, '-').slice(0, 38);
      const instanceName = `${poolName}-${slugid.nice().replace(/_/g, '-').toLowerCase()}`;

      let op;

      try {
        const res = await this._enqueue('query', () => this.compute.instances.insert({
          project: this.project,
          zone: cfg.zone,
          requestId: uuid.v4(), // This is just for idempotency
          requestBody: {
            ...cfg, // We spread this in first so that users can't override stuff we set below
            name: instanceName,
            labels: {
              ...cfg.labels || {},
              'created-by': `taskcluster-wm-${this.providerId}`.replace(/[^a-zA-Z0-9-]/g, '-'),
              'managed-by': 'taskcluster',
              'worker-pool-id': workerPoolId.replace(/[^a-zA-Z0-9-]/g, '-').toLowerCase(),
github higlass / higlass / app / scripts / ViewportTracker2D.js View on Github external
constructor(context, options) {
    // create a clipped SVG Path
    super(context, options);
    const {
      registerViewportChanged,
      removeViewportChanged,
      setDomainsCallback,
    } = context;

    const uid = slugid.nice();
    this.uid = uid;
    this.options = options;

    this.removeViewportChanged = removeViewportChanged;
    this.setDomainsCallback = setDomainsCallback;

    this.viewportXDomain = null;
    this.viewportYDomain = null;

    const maxHalf = Number.MAX_VALUE / 2;

    this.brush = brush(true)
      .extent([[-maxHalf, -maxHalf], [maxHalf, maxHalf]])
      .on('brush', this.brushed.bind(this));

    this.gBrush = this.gMain
github higlass / higlass / app / scripts / OSMTilesTrack.js View on Github external
typeof this.options.maxPos !== 'undefined'
      && !Number.isNaN(+this.options.maxPos)
    )
      ? +this.options.maxPos
      : 180;

    // HiGlass currently only supports squared tile sets but maybe in the
    // future...
    this.minY = this.options.minY || this.minX;
    this.maxY = this.options.maxY || this.maxX;

    this.maxZoom = 19;
    this.maxWidth = this.maxX - this.minX;
    this.animate = animate;

    this.uuid = slugid.nice();
    this.refreshTilesDebounced = debounce(
      this.refreshTiles.bind(this), ZOOM_DEBOUNCE
    );
  }
github higlass / higlass / app / scripts / HiGlassComponent.js View on Github external
handleTrackAdded(viewId, newTrack, position, host = null) {
    this.addDefaultTrackOptions(newTrack);

    // make sure the new track has a uid
    if (!newTrack.uid) newTrack.uid = slugid.nice();

    if (newTrack.contents) {
      // add default options to combined tracks
      for (const ct of newTrack.contents) { this.addDefaultTrackOptions(ct); }
    }

    if (this.state.addTrackPosition) {
      // we've already added the track, remove the add track dialog
      this.setState({
        addTrackPosition: null,
      });
    }

    if (host) {
      // we're adding a series rather than a whole new track
      this.handleSeriesAdded(viewId, newTrack, position, host);
github higlass / higlass / app / old / MultiTrackContainer.jsx View on Github external
this.initialVerticalTrackHeight = this.initialHorizontalTrackWidth;
        this.initialVerticalTrackWidth = this.initialVerticalTrackHeight;

        this.initLayouts();
        this.setupTrackDescriptions();

        let tracks = this.props.viewConfig.tracks;
        let currentTop = 0;
        this.twoD = false;               // are there any 2D tracks? this affects how the genomic
                                         // coordinates are displayed in the search box
        //this.heightSpecified = true;     // do any of the tracks request a particular height?
        for (let i = 0; i < tracks.length; i++) {
            let trackHeight = this.defaultDims[this.trackDescriptions[tracks[i].type].position].height;
            let trackWidth = this.defaultDims[this.trackDescriptions[tracks[i].type].position].width;

            let trackId = slugid.nice();

            if (this.trackDescriptions[tracks[i].type].position == 'left' ||
                this.trackDescriptions[tracks[i].type].position == 'center')
                this.twoD = true

            if (this.trackDescriptions[tracks[i].type].position == 'center' && 
                this.trackDescriptions[tracks[i].type].overlay == false)
                if (!('height' in tracks[i]))
                    this.heightSpecified = false;

            if ('height' in tracks[i]) {
                trackHeight = tracks[i].height;
            }
            if ('width' in tracks[i])
                trackWidth = tracks[i].width;
            if ('uid' in tracks[i])
github higlass / higlass / app / scripts / data-fetchers / bam-fetcher.js View on Github external
constructor(dataConfig) {
    this.dataConfig = dataConfig;
    this.uid = slugid.nice();

    this.worker = spawn(
      new Worker('./bam-fetcher-worker.js')
    );

    this.initPromise = this.worker.then((tileFunctions) => {
      console.log('tileFunctions:', tileFunctions);
    
      return tileFunctions.init(
        this.uid, dataConfig.url, dataConfig.chromSizesUrl
      ).then(() => this.worker);
    });

    console.log('constructor');
  }
github higlass / higlass / app / scripts / PositionalTiledPlot.jsx View on Github external
let newItems = this.props.tracks.map((d) => {
      let uid = d.uid;
      if (!uid)
        uid = slugid.nice();

      return {uid: uid, height: this.props.height, width: d.width, value: d.value };
    });
github higlass / higlass / app / scripts / double_higlass.js View on Github external
let minArea = 0;
            let maxArea = 0;
            let xScaleDomain = null, yScaleDomain = null;

            let minValue = 0, maxValue = 0;
            let transferFunction = (count) => count > 0 ? Math.log2(1 + Math.log2(1 + count)) : 0;
            let maxTransfer = 1;
            let minVisibleValue = 0, maxVisibleValue = 1;

            let labelSort = (a,b) => { return b.area - a.area; };
            let gMain = null;
            let gDataPoints = null;
            let shownTiles = new Set();
            let pointMarkId = (d) => { return `p-${d.uid}`; };
            let slugId = slugid.nice();

            var pixiCanvas = d3.select(this).append('canvas')
                .attr('width', 0)
                .attr('height', 0)
                .style('left', `${margin.left}px`)
                .style('top', `${margin.top}px`)
                .style('position', 'absolute')

                renderer = PIXI.autoDetectRenderer(width - margin.right - margin.left, height - margin.top - margin.bottom, 
                        { 
                            //backgroundColor: 0xdddddd,
                            backgroundColor: 0xffffff,
                         antialias: true, 
                         view: pixiCanvas.node() 
                        });
github higlass / higlass / app / old / CrosshairsPlot.js View on Github external
selection.each(function(d) {
        var svg = d3.select(this).select('.mainSVG').select('.g-enter')
        let slugId = slugid.nice();

        let xScale = d3.scale.linear()
            .domain(xDomain)
            .range([0, width - margin.left - margin.right]);

        let yScale = d3.scale.linear()
            .domain(yDomain)
            .range([0, height - margin.top - margin.bottom]);

        var gCoordinates = svg.append('g')
        .classed('coordinates-g', true)
        //.attr('transform', `translate(${margin.left}, ${margin.top})`)

        let xLine = gCoordinates.append('line')
        .classed('x-crosshair', true)

slugid

URL-safe base64 UUID encoder for generating 22 character slugs

MIT
Latest version published 5 months ago

Package Health Score

82 / 100
Full package analysis