Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/identifier / src / fromPropsToIdentifier.ts
Size: Mime:

interface PropsToIdentifier {
  [key: string]: unknown
  identifier?: string
  className?: string
  /** @deprecated */
  vectorClassName?: string
  namespace?: string
}

let index = 0
function fromPropsToIdentifier(props: PropsToIdentifier): string {
  if (process.env.NODE_ENV === 'test') {
    return '@@ID'
  }

  index += 1
  const identifier =
    props.identifier ||
    props.className ||
    props.vectorClassName ||
    props.namespace ||
    'EMPTY'

  return identifier + index
}

export {
  PropsToIdentifier,
  fromPropsToIdentifier,
}