How to use defined - 10 common examples

To help you get started, we’ve selected a few defined 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 yxliang01 / eth-mine-when-need / src / bin.js View on Github external
import * as lib from './index.js'
import chalk from 'chalk';
import * as eth from 'ethereum-go-ipc';
import defined from 'defined';
import getDefaultIPCPath from './getIpcPath.js';

if (process.argv.slice(2).includes('--help')) {
    console.log('Usage: [number of blocks for confirmation] [number of mining thread] [Eth IPC Path]');
    console.log('If you leave Eth IPC Path blank, it will use the default IPC address for your system')
    process.exit(1);
}

const txConfirmation = typeof process.argv[2] !== 'undefined' ? parseInt(process.argv[2]) : undefined;
const mineCores = typeof process.argv[3] !== 'undefined' ? parseInt(process.argv[3]) : undefined;
const ipcAddress = defined(process.argv[4], getDefaultIPCPath());

eth.setGethSocket(ipcAddress);
const web3 = eth.web3Provider();
new lib.mine_when_need(eth, web3, txConfirmation, mineCores);

console.log(chalk.green('Start succeeded. Press Control+C to stop'));
github littlstar / axis3d / example / directional-light / index.js View on Github external
const match = String(e[prop]).match(/rgb\((.*)\)/)
    return !match ? null : match[1]
      .split(', ')
      .map(parseFloat)
      .map((n) => n/255)
  }

  Object.assign(directionalLightColor, rgb('Light') || [])
  Object.assign(materialEmissive, rgb('Emissive') || [])
  Object.assign(materialColor, rgb('Color') || [])

  materialLineSegments = Boolean(coalesce(
    e['LinesMesh'],
    materialLineSegments))

  materialOpacity = Number(coalesce(
    e['Opacity'],
    materialOpacity))
})
github littlstar / axis3d / example / directional-light / index.js View on Github external
mesh(state, ({}, args) => {
      material({
        color: [1, 1, 1, 1.0],
        opacity: coalesce(state.opacity, 1)
      }, () => {
        lines({
          visible: coalesce(state.segments, true),
          thickness: 0.0125,
          scale: [1.00125, 1.00125, 1.00125]
        })
      })
    })
  }
github littlstar / axis3d / src / core / gl / dynamic.js View on Github external
static pluck(scope, property, key, ...defaultValues) {
    let value = undefined
    if (scope && null != scope[property]) {
      value = null != key ? scope[property][key] : scope[property]
    }
    return DynamicValue.primitive(coalesce(value, ...defaultValues))
  }
github littlstar / axis3d / src / core / material.js View on Github external
mask({}, {
        opacity = coalesce(initialState.opacity, 1),
        transparent = coalesce(
          initialState.transparent,
          initialState.blend.enable,
          kDefaultMaterialDepthState.enable,
          false),
      } = {}) {
        if (opacity < 1.0 || transparent) {
          return true
        } else {
          return coalesce(initialState.depth.mask, kDefaultMaterialDepthState.mask)
        }
      }
    }
github NDLANO / learningpath-frontend / src / learningPath / search / LearningPathSearch.jsx View on Github external
const mapStateToProps = (state, props) => {
  const query = queryString.parse(props.location.search);
  const pageSize = defined(query.pageSize, '10');
  const lastPage = Math.ceil(
    getLearningPathSearchTotalCount(state) / parseInt(pageSize, 10),
  );
  return Object.assign(
    {},
    {
      lastPage,
      learningPaths: getLearningPathSearchResult(state),
    },
  );
};
github NDLANO / learningpath-frontend / src / learningPath / edit / LearningPathForm.js View on Github external
const mapStateToProps = (state, props) => ({
  initialValues: {
    title: props.learningPath.title,
    description: props.learningPath.description,
    duration: convertedDuration(props.learningPath.duration),
    tags: props.learningPath.tags,
    coverPhotoMetaUrl: props.learningPath.coverPhoto
      ? props.learningPath.coverPhoto.metaUrl
      : '',
    license:
      props.learningPath.copyright && props.learningPath.copyright.license
        ? defined(props.learningPath.copyright.license, '')
        : '',
    contributors:
      props.learningPath.copyright && props.learningPath.copyright.contributors
        ? props.learningPath.copyright.contributors
        : [],
  },
  formValues:
    state.form[formName] && state.form[formName].values
      ? state.form[formName].values
      : {},
});
github littlstar / axis3d / src / core / object3d.js View on Github external
this.position = ({}, args = {}) => {
      args = args || {}
      const position = coalesce(args.position, initialPosition)
      if (position instanceof Vector) {
        return [ ...position ]
      } else if (Array.isArray(position)) {
        return [ ...position ]
      } else if (null != position) {
        try { return [ ...position ] }
        catch(e) { return [ position, position, position ] }
      }
    }
github littlstar / axis3d / src / core / shader.js View on Github external
constructor({
    preprocessor = undefined,
    middleware = [],
    precision = kDefaultShaderLibPrecision,
    version = kDefaultShaderLibVersion,
    defines = {},
    glsl,
  } = {}) {
    this.cache = new DynamicValue(this)
    this.store = new DynamicValue(this)
    this.version = coalesce(version || kDefaultShaderLibVersion)
    this.precision = coalesce(precision, kDefaultShaderLibPrecision)
    this.middleware = coalesce(middleware, [])
    this.preprocessor = coalesce(preprocessor, new ShaderLibPreprocessor(this))
    this.preprocessor.define(defines)
    this.add({ ...libglsl, ...glsl })
  }
github littlstar / axis3d / src / core / mesh.js View on Github external
this.primitive = ({}, {
      primitive = null,
      wireframe = false,
    } = {}) => {
      if ('string' == typeof primitive) {
        return primitive
      } else if (wireframe) {
        return coalesce(
          initialState.wireframePrimitive,
          kDefaultMeshWireframePrimitive)
      } else if ('string' == typeof initialState.primitive) {
        return initialState.primitive
      } else {
        return kDefaultMeshPrimitive
      }
    }

defined

return the first argument that is `!== undefined`

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis

Popular defined functions