How to use the @jscad/core/utils/arrays.nth function in @jscad/core

To help you get started, we’ve selected a few @jscad/core 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 jscad / OpenJSCAD.org / packages / web / src / ui / flow / design.js View on Github external
.map(url => {
        const params = getAllUriParams(url)
        const useProxy = params.proxyUrl !== undefined || url.match(/#(https?:\/\/\S+)$/) !== null
        const documentUri = fetchUriParams(url, 'uri', undefined) || nth(1, url.match(/#(https?:\/\/\S+)$/)) || nth(1, document.URL.match(/#(examples\/\S+)$/))
        const baseUri = window.location.origin // location.protocol + '//' + location.host + location.pathname
        // console.log('useProxy', useProxy, documentUri, baseUri)
        if (!documentUri) {
          return undefined
        }
        const urlData = new URL(documentUri)
        console.log('urlData', urlData, params, documentUri)
        const documentUris = documentUri ? [documentUri] : undefined
        const { protocol, origin, pathname } = urlData
        return { documentUris, protocol: protocol.replace(':', ''), origin, path: pathname }
      })
  ])