How to use the array-flatten function in array-flatten

To help you get started, we’ve selected a few array-flatten 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 obahareth / are-you-es5 / src / modules-checker.ts View on Github external
return !leafFolderName.startsWith('.')
        })
        .map(entry => {
          // If this is a scope (folder starts with @), return all
          // folders inside it (scoped packages)
          if (/@.*$/.test(entry)) {
            return getDirectories(entry)
          } else {
            return entry
          }
        })

      // Remove path from all strings
      // e.g. turn bla/bla/node_modules/@babel/core
      // into @babel/core
      nodeModules = flatten(nodeModules).map((entry: string) =>
        getLeafFolderName(entry)
      )

      return nodeModules
    }

    console.error(`Failed to find node_modules at ${this.dir}`)
    return null
  }
}
github r-murphy / babel-plugin-transform-modules-ui5 / packages / plugin / src / utils / ast.js View on Github external
export function getPropertiesOfObjectAssignOrExtendHelper(
  node,
  blockScopeNode
) {
  // Check all the args and recursively try to get props of identifiers (although they may be imported)
  return flatten(
    node.arguments.map(arg => {
      if (t.isObjectExpression(arg)) {
        return arg.properties;
      } else if (t.isIdentifier(arg)) {
        // Recursive, although props will be empty if arg is an imported object
        return getOtherPropertiesOfIdentifier(blockScopeNode, arg.name);
      }
    })
  );
}
github r-murphy / babel-plugin-transform-modules-ui5 / packages / plugin / src / utils / ast.js View on Github external
export function getOtherPropertiesOfIdentifier(blockScopeNode, idName) {
  return flatten(
    blockScopeNode.body
      .map(node => {
        if (t.isExpressionStatement(node)) {
          // ID = value | ID.key = value | ID.key.nested = value
          const { left, right } = node.expression;
          if (t.isAssignmentExpression(node.expression)) {
            if (t.isIdentifier(left) && left.name === idName) {
              // ID = value
              if (t.isObjectExpression(right)) {
                // ID = {}
                return right.properties; // Array
              }
            } else {
              const { object, property: key } = left;
              if (t.isIdentifier(object) && object.name === idName) {
                // ID.key = value
github Tonejs / Midi / src / Encode.ts View on Github external
function encodeNotes(track: Track): Array {
	return flatten(track.notes.map(note => encodeNote(note, track.channel))) as unknown as Array;
}
github gajus / slonik / src / utilities / normalizeAnonymousValuePlaceholders.js View on Github external
}
  }

  if (values.length !== valueIndex) {
    throw new Error('Value number is greater than the placeholder count.');
  }

  if (chunkIndex === 0) {
    result = sql;
  } else if (chunkIndex < sql.length) {
    result += sql.slice(chunkIndex);
  }

  return {
    sql: result,
    values: arrayFlatten(values)
  };
};
github cevio / simplize / src / js / application / route.js View on Github external
route(path, method, opts, ...args){
        let handles = flatten(slice.call(args));
        for (let i = 0; i < handles.length; i++) {
            let handle = handles[i];

            if (typeof handle !== 'function') {
                let type = toString.call(handle);
                let msg = 'Route.' + method + '() requires callback functions but got a ' + type;
                throw new Error(msg);
            }

            let layer = new Layer(path, opts, handle);
            layer.method = method;
            this.stack.push(layer);
        }
        return this;
    }
github alexcroox / jira-timer-menubar / main / jira-worklogs.js View on Github external
}, err => {

            log.info('Finished fetching all worklogs')

            if (err) {
              this.fetching = false
              return reject(err)
            }

            let flatWorklogs = flatten(worklogs)
            let orderedWorklogs = orderBy(flatWorklogs, ['created'], ['desc'])

            resolve(flatten(orderedWorklogs))
          })
        })
github jamiefaye / downrush / midian / src / Midi / Encode.js View on Github external
channel : note.channel ? note.channel : track.channel,
								noteNumber : note.midi,
								ticks : note.ticks,
								velocity : Math.floor(note.velocity * 127)
							},
							{
								type : 'noteOff',
								channel : note.channel ? note.channel : track.channel,
								noteNumber : note.midi,
								ticks : note.ticks + note.durationTicks,
								velocity : Math.floor(note.noteOffVelocity * 127)
							}
						]
					})),
					//and the control changes
					...flatten(controlChanges)
				]
			})
		]

array-flatten

Flatten nested arrays

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis