How to use the ramda.isEmpty function in ramda

To help you get started, we’ve selected a few ramda 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 teambit / bit / src / utils / resolveLatestVersion.ts View on Github external
export default function getLatestVersionNumber(bitIds: BitIds, bitId: BitId): BitId {
  if (!bitId.getVersion().latest) return bitId;

  // If the bitId provided doesn't contain version we want to ignore scope during search always
  // otherwise we will have problems finding the version from the bitmap after we export the component
  // because we tag with a name without scope but the bitmap contain it with the scope name since it was exported
  // without this, we will always just return the first component in the bitmap which is really bad
  const ignoreScope = !bitId.hasScope();

  const similarIds = ignoreScope ? bitIds.filterWithoutScopeAndVersion(bitId) : bitIds.filterWithoutVersion(bitId);
  const allVersionsForId = similarIds.filter(id => id.hasVersion() && !id.isVersionSnap()).map(id => id.version);

  // A case when the provided bitId doesn't exists in the array
  if (R.isEmpty(allVersionsForId)) {
    if (similarIds.length === 1) return similarIds[0];
    if (similarIds.length > 1)
      throw new Error(`found multiple snaps for ${bitId.toString()}, unable to figure which one is the latest`);
    return bitId;
  }

  const maxVersion = semver.maxSatisfying(allVersionsForId, '*');
  if (!maxVersion) {
    throw new Error(
      `semver was not able to find the highest version among the following: ${allVersionsForId.join(', ')}`
    );
  }
  const bitIdWithMaxVersion = bitId.changeVersion(maxVersion);
  const result = ignoreScope ? bitIds.searchWithoutScope(bitIdWithMaxVersion) : bitIds.search(bitIdWithMaxVersion);
  if (!result) {
    throw new Error(`getLatestVersionNumber failed to find the id ${bitIdWithMaxVersion.toString()} within bitIds`);
github teambit / bit / src / links / link-generator.js View on Github external
function addCustomResolveAliasesToPackageJson(component: Component, links: LinkFileType[]): boolean {
  const resolveAliases = links.reduce((acc, link: LinkFileType) => {
    if (link.customResolveMapping) Object.assign(acc, link.customResolveMapping);
    return acc;
  }, {});
  if (R.isEmpty(resolveAliases)) return false;
  if (!component.packageJsonFile) return false; // e.g. author doesn't have package.json per component
  const bitProperty = component.packageJsonFile.getProperty('bit') || {};
  bitProperty.resolveAliases = resolveAliases;
  return true;
}
github broidHQ / integrations / broid-callr / src / core / Parser.ts View on Github external
public validate(event: any): Promise {
    this.logger.debug('Validation process', { event });

    const parsed = cleanNulls(event);
    if (!parsed || R.isEmpty(parsed)) { return Promise.resolve(null); }

    if (!parsed.type) {
      this.logger.debug('Type not found.', { parsed });
      return Promise.resolve(null);
    }

    return schemas(parsed, 'activity')
      .then(() => parsed)
      .catch((err) => {
        this.logger.error(err);
        return null;
      });
  }
github envkey / envkey-app / envkey-react / src / components / env_manager / sub_envs.js View on Github external
_renderContent(){
    const content = R.isEmpty(this._subEnvs()) ?
      [this._renderPlaceholder()] :
      [this._renderList(), this._renderSelected()]

    return h.div(".content", content)
  }
github linode / manager / src / components / SelectRegionPanel / SelectRegionPanel.tsx View on Github external
if (!isEmpty(na)) {
      tabs.push({
        title: 'North America',
        render: () => {

          return (
            
              {na.map(renderCard(this.props.selectedID, this.props.handleSelection))}
            
          );
        },
      });
    }

    if (!isEmpty(eu)) {
      tabs.push({
        title: 'Europe',
        render: () => {
          return (
            
              {eu.map(renderCard(this.props.selectedID, this.props.handleSelection))}
            
          );
        },
      });
    }

    if (!isEmpty(as)) {
      tabs.push({
        title: 'Asia',
        render: () => {
github coderplanets / coderplanets_admin / components / TagsCell / index.js View on Github external
const TagsCell = ({ thread, source, onDelete, onAdd }) => (
  
    {R.isEmpty(source.tags) ? (
      
    ) : (
      
        
        <div>
          
        </div>
      
    )}
  
)
github broidHQ / integrations / broid-slack / src / core / adapter.ts View on Github external
.mergeMap((event: IWebHookEvent) => {
        const req = event.request;
        const payloadStr = R.path(["body", "payload"], req);
        if (R.isEmpty(payloadStr)) {
          return Promise.resolve(null);
        }

        const payload = JSON.parse(payloadStr);
        let team = payload.team || {};
        if (payload.team_id) {
          team = {
            id: payload.team_id,
          };
        }

        if (payload.type === "event_callback"
          && payload.event.type === "message") {
            return Promise.resolve({
              channel: payload.event.channel.id,
              subtype: "event_callback",
github teambit / bit / src / consumer / bit-map / bit-map.ts View on Github external
_populateAllPaths() {
    if (R.isEmpty(this.paths)) {
      Object.keys(this.components).forEach(componentId => {
        const component = this.components[componentId];
        component.files.forEach(file => {
          const relativeToConsumer = component.rootDir
            ? pathJoinLinux(component.rootDir, file.relativePath)
            : file.relativePath;
          this.paths[relativeToConsumer] = component.id;
          this.pathsLowerCase[relativeToConsumer.toLowerCase()] = component.id;
        });
      });
    }
  }
github broidHQ / integrations / broid-kik / lib / core / Parser.js View on Github external
id: normalized.chatID.toString(),
            name: normalized.chatID.toString(),
            type: 'Person',
        };
        if (normalized.type === 'Image' || normalized.type === 'Video') {
            let mediaType = 'Image';
            if (normalized.type === 'Video') {
                mediaType = 'Video';
            }
            activitystreams.object = {
                id: normalized.id.toString() || this.createIdentifier(),
                type: mediaType,
                url: normalized.content,
            };
        }
        if (R.isEmpty(activitystreams.object) && !R.isEmpty(normalized.content)) {
            activitystreams.object = {
                content: normalized.content,
                id: normalized.id.toString() || this.createIdentifier(),
                type: 'Note',
            };
        }
        return Promise.resolve(activitystreams);
    }
    normalize(event, userInformation) {
github teambit / bit / src / consumer / bit-json / abstract-bit-json.js View on Github external
get tester(): ?Testers {
    const testerObj = transformEnvToObject(this._tester);
    if (R.isEmpty(testerObj)) return undefined;
    return testerObj;
  }