How to use the superstruct.struct.partial function in superstruct

To help you get started, we’ve selected a few superstruct 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 Feverqwe / tSearch / src / stores / TrackerStoreStore.js View on Github external
import {destroy, flow, getRoot, isAlive, types} from 'mobx-state-tree';
import getLogger from "../tools/getLogger";
import {fetch} from "whatwg-fetch";
import {struct} from 'superstruct';
import TrackerStore, {TrackerMetaStore} from "./TrackerStore";
import getTrackerCodeMeta from "../tools/getTrackerCodeMeta";
import storageGet from "../tools/storageGet";
import storageSet from "../tools/storageSet";
import getHash from "../tools/getHash";
import setCodeMeta from "../tools/setCodeMeta";

const logger = getLogger('TrackerStoreStore');

const Files = struct([struct.partial({
  name: 'string',
  // path: 'string',
  // sha: 'string',
  size: 'number',
  // url: 'string',
  html_url: 'string',
  // git_url: 'string',
  download_url: 'string',
  type: 'string',
  // _links: struct.partial({
  //   self: 'string',
  //   git: 'string',
  //   html: 'string',
  // }),
})]);
github jxnblk / figma-theme / index.js View on Github external
fontSizes: 'array',
  fontWeights: 'array',
  lineHeights: 'array',
  metadata: 'object?'
})

const Data = struct.partial({
  name: 'string',
  lastModified: 'string',
  thumbnailUrl: 'string',
  document: struct.partial({
    children: struct.list([ 'object' ]),
  }),
  styles: struct.dict([
    'string',
    struct.partial({
      name: 'string',
      styleType: 'string',
    })
  ])
})

const unique = arr => [...new Set(arr)]

module.exports = (data, opts = {}) => {
  Data(data)
  const {
    styles = {},
    document: {
      children: tree = []
    }
  } = data
github jxnblk / figma-theme / index.js View on Github external
fontWeight: 'number',
      lineHeight: 'number',
    })
  ]),
  fonts: 'array',
  fontSizes: 'array',
  fontWeights: 'array',
  lineHeights: 'array',
  metadata: 'object?'
})

const Data = struct.partial({
  name: 'string',
  lastModified: 'string',
  thumbnailUrl: 'string',
  document: struct.partial({
    children: struct.list([ 'object' ]),
  }),
  styles: struct.dict([
    'string',
    struct.partial({
      name: 'string',
      styleType: 'string',
    })
  ])
})

const unique = arr => [...new Set(arr)]

module.exports = (data, opts = {}) => {
  Data(data)
  const {
github jxnblk / figma-theme / index.js View on Github external
'string',
    struct({
      fontFamily: 'string',
      fontSize: 'number',
      fontWeight: 'number',
      lineHeight: 'number',
    })
  ]),
  fonts: 'array',
  fontSizes: 'array',
  fontWeights: 'array',
  lineHeights: 'array',
  metadata: 'object?'
})

const Data = struct.partial({
  name: 'string',
  lastModified: 'string',
  thumbnailUrl: 'string',
  document: struct.partial({
    children: struct.list([ 'object' ]),
  }),
  styles: struct.dict([
    'string',
    struct.partial({
      name: 'string',
      styleType: 'string',
    })
  ])
})

const unique = arr => [...new Set(arr)]