const xxxs: Array<number> = _.intersperse(1, [1, 2, 3]);

  const pairxs: [number, string] = _.pair(2, "str");

  const partxs: [Array<string>, Array<string>] = _.partition(_.contains("s"), [
    "sss",
    "ttt",
    "foo",
    "bars"
  ]);
  const partxs1: [
    { [k: string]: string },
    { [k: string]: string }
  ] = _.partition(_.contains("s"), { a: "sss", b: "ttt", foo: "bars" });

  const pl: Array<number | string> = _.pluck("a")([{ a: "1" }, { a: 2 }]);
  const pl1: Array<number> = _.pluck(0)([[1, 2], [3, 4]]);

  const rxs: Array<number> = _.range(1, 10);

  const remxs: Array<string> = _.remove(0, 2, ss);
  const remxs1: Array<string> = _.remove(0, 2)(ss);
  const remxs2: Array<string> = _.remove(0)(2)(ss);
  const remxs3: Array<string> = _.remove(0)(2, ss);

  const ys4: Array<string> = _.repeat("1", 10);
  const ys5: Array<number> = _.repeat(1, 10);

  // reduce
  const redxs: number = reduce(_.add, 10, ns);
  const redxs1: string = reduce(_.concat, "", ss);
Example #2
0
 .then(body => {
   let results = R.zipObj(R.pluck('role')(body), body);
   if (!R.contains(gg_position, R.keys(results))) throw new Warning(`${T('no_counters', lang)} **${champ}** **${position}**.`);
   return results[gg_position];
 })
  const nthxs: ?string = _.nth(2, [ 'curry' ])
  const nthxs1: ?string = _.nth(2)([ 'curry' ])
  //$ExpectError
  const nthxs2: string = _.nth(2, [ 1, 2, 3 ])


  const xxs: Array<number> = _.append(1, [ 1, 2, 3 ])
  const xxxs: Array<number> = _.intersperse(1, [ 1, 2, 3 ])

  const pairxs:[number,string] = _.pair(2, 'str')

  const partxs:[Array<string>,Array<string>] = _.partition(_.contains('s'), [ 'sss', 'ttt', 'foo', 'bars' ])
  const partxs1: [{[k:string]:string}, {[k:string]:string}] = _.partition(_.contains('s'), { a: 'sss', b: 'ttt', foo: 'bars' })

  const pl:Array<number|string> = _.pluck('a')([ { a: '1' }, { a: 2 } ])
  const pl1:Array<number> = _.pluck(0)([ [ 1, 2 ], [ 3, 4 ] ])

  const rxs: Array<number> = _.range(1, 10)

  const remxs: Array<string> = _.remove(0, 2, ss)
  const remxs1: Array<string> = _.remove(0, 2)(ss)
  const remxs2: Array<string> = _.remove(0)(2)(ss)
  const remxs3: Array<string> = _.remove(0)(2, ss)

  const ys4: Array<string> = _.repeat('1', 10)
  const ys5: Array<number> = _.repeat(1, 10)

  const redxs: number = _.reduce(_.add, 10, ns)
  const redxs1: string = _.reduce(_.concat, '', ss)
  const redxs2: Array<string> = _.reduce(_.concat, [])(_.map(x => [ x ], ss))
Example #4
0
 const fileArr = componentObject[key].map(c => R.pluck('relativePath')(c.files));
Example #5
0
 .then(body => {
   if (!body.champions) throw new ChampionifyErrors.MissingData(`Lolflavor: ${process_name}`);
   return R.pluck('name')(body.champions).sort();
 })
Example #6
0
 .then(champs => R.zipObj(R.pluck('id')(champs), R.pluck('stats')(champs)))
Example #7
0
 getInstallsScore: function (apps) {
   const avg = R.sum(R.pluck('minInstalls', apps)) / apps.length;
   const max = 1000000;
   const score = calc.zScore(max, avg);
   return {avg, score};
 },
Example #8
0
 it("correctly runs test: " + name, () => {
   const result = R.filter(run(spec[0]), sampleData)
   assert.deepEqual(R.pluck("id", result), spec[1])
 })
const expressifyPaths = R.over(R.lensProp('path'), getResource);

const attachToRouter = R.curry((router, middlewareObj, basePath, route) => {
  	const resource = basePath + route.path;
    const verb = route.verb;
    const controllerName = route.controller;
    const functionName = route.middlewareFunction;
    if (controllerName && functionName && R.has(functionName, middlewareObj[controllerName])) {
      console.log(`SETTING UP ROUTE ${resource} ${verb} ${controllerName}.${functionName}`);
      router[verb](resource, middlewareObj[controllerName][functionName]);
    } else {
      console.log(`ERROR setting up ${resource} ${verb}: ${controllerName}.${functionName} not found`);
    }
});

const noEscapeCharsInRoutes = R.compose(R.not, R.any(R.test(/\\/)), R.pluck('path'));

const setUpRoutes = (middlewareObj, router, swaggerDoc, useBasePath) => {
	const basePath = useBasePath ? swaggerDoc.basePath : '';
	return R.compose(
		R.ifElse(
		  noEscapeCharsInRoutes,
		  R.forEach(attachToRouter(router, middlewareObj, basePath)),
		  () => console.log('SWAGGER doc contains invalid routes, no routes have been set-up')
		),
		R.map(expressifyPaths),
		parser
	)(swaggerDoc);
};

module.exports = {
CucumberHtmlReport.prototype.createReport = function() {
  var options = this.options;
  if (!checkOptions(options)) {
    return false;
  }

  var features = parseFeatures(options, loadCucumberReport(this.options.source));
  R.map(function (feature) {
    var duration = R.compose(
      R.reduce(function (accumulator, current) {
        return accumulator + current;
      }, 0),
      R.flatten(),
      R.map(function (step) {
        return step.result.duration ? step.result.duration : 0;
      }),
      R.flatten(),
      R.map(function (element) {
        return element.steps;
      })
    )(feature.elements);

    if (duration && duration / 60000000000 >= 1) {

      //If the test ran for more than a minute, also display minutes.
      feature.duration = Math.trunc(duration / 60000000000) + " m " + round(2, (duration % 60000000000) / 1000000000) + " s";
    } else if (duration && duration / 60000000000 < 1) {

      //If the test ran for less than a minute, display only seconds.
      feature.duration = round(2, duration / 1000000000) + " s";
    }
    
  })(features);

  var templateFile = options.template || defaultTemplate;
  var template = loadTemplate(templateFile);

  var stepsSummary = [];
  var scenarios = [];

  //Extracts steps from the features.
  features.map(function (feature, index) {
    feature.index = index;
    var steps = R.compose(
        R.flatten(),
        R.map(function (scenario) {
          return scenario.steps;
        }),
        R.filter(function (element) {
          return element.type === "scenario";
        })
    )(feature.elements);
    
    stepsSummary.push({
      "all": 0,
      "passed": 0,
      "skipped": 0,
      "failed": 0
    });

    //Counts the steps based on their status.
    steps.map(function (step) {
      switch (step.result.status) {
        case "passed":
          stepsSummary[index].all++;
          stepsSummary[index].passed++;
          break;
        case "skipped":
          stepsSummary[index].all++;
          stepsSummary[index].skipped++;
          break;
        default:
          stepsSummary[index].all++;
          stepsSummary[index].failed++;
          break;
      }

      //Converts the duration from nanoseconds to seconds and minutes (if any)
      var duration = step.result.duration;
      if (duration && duration / 60000000000 >= 1) {

        //If the test ran for more than a minute, also display minutes.
        step.result.convertedDuration = Math.trunc(duration / 60000000000) + " m " + round(2, (duration % 60000000000) / 1000000000) + " s";
      } else if (duration && duration / 60000000000 < 1) {

        //If the test ran for less than a minute, display only seconds.
        step.result.convertedDuration = round(2, duration / 1000000000) + " s";
      }
    });

    scenarios.push({
      all: 0,
      passed: 0,
      failed: 0
    });

    R.compose(
      R.map(function (status) {
        scenarios[index].all++;
        scenarios[index][status]++;
      }),
      R.flatten(),
      R.map(function (scenario) {
        return scenario.status;
      }),
      R.filter(function (element) {
        return element.type === "scenario";
      })
    )(feature.elements);

  });

  var scenariosSummary = R.compose(
      R.filter(function (element) {
        return element.type === "scenario";
      }),
      R.flatten(),
      R.map(function (feature) {
        return feature.elements
      })
  )(features);

  var summary = Summary.calculateSummary(features);
  //Replaces "OK" and "NOK" with "Passed" and "Failed".
  summary.status = summary.status === "OK" ? "passed" : "failed";

  var logoExtension = options.logo.split(".").pop();
  var logo = "data:image/" + (logoExtension === "svg" ? "svg+xml" : logoExtension) + ";base64," + getDataUri(options.logo);
  
  var screenshots = fs.readdirSync(options.screenshots).map(function (file) {
    if (file[0] === ".") {
      return undefined;
    }

    var name = file.split(".");
    var extension = name.pop();
    extension === "svg" ? extension = "svg+xml" : false;
    return {
      name: name.join(".").replace(/\s/, "_"),
      url: "data:image/" + extension + ";base64," + getDataUri(options.screenshots + "/" + file)
    };
  }).filter(function (image) {
    return image;
  });

  var tags = {};
  features.map(function (feature) {

    [].concat(feature.tags).map(function (tag) {

      if (!(tag in tags)) {
        tags[tag] = {
          name: tag,
          scenarios: {
            all: 0,
            passed: 0,
            failed: 0
          },
          steps: {
            all: 0,
            passed: 0,
            failed: 0,
            skipped: 0
          },
          duration: 0,
          status: "passed"
        };
      }

      feature.elements.map(function (element) {
        if (element.type === "scenario") {
          tags[tag].scenarios.all++;
          tags[tag].scenarios[element.status]++;
        }
        
        element.steps.map(function (step) {
          if (step.result.duration) {
            tags[tag].duration += step.result.duration;
          }
          tags[tag].steps.all++;
          tags[tag].steps[step.result.status]++;
        });
      });

      if(tags[tag].scenarios.failed > 0) {
        tags[tag].status = "failed";
      }
    })
  });
  
  var tagsArray = (function (tags) {
    var array = [];
    
    for (var tag in tags) {
      if (tags.hasOwnProperty(tag)) {
        
        //Converts the duration from nanoseconds to seconds and minutes (if any)
        var duration = tags[tag].duration;
        if (duration && duration / 60000000000 >= 1) {

          //If the test ran for more than a minute, also display minutes.
          tags[tag].duration = Math.trunc(duration / 60000000000) + " m " + round(2, (duration % 60000000000) / 1000000000) + " s";
        } else if (duration && duration / 60000000000 < 1) {

          //If the test ran for less than a minute, display only seconds.
          tags[tag].duration = round(2, duration / 1000000000) + " s";
        }
        
        array.push(tags[tag]);
      }
    }
    
    return array;
  })(tags);

  var mustacheOptions = Object.assign(options, {
    features: features,
    featuresJson: JSON.stringify(R.pluck("name", scenariosSummary)),
    stepsSummary: stepsSummary,
    scenariosSummary: JSON.stringify(scenariosSummary),
    stepsJson: JSON.stringify(stepsSummary),
    scenarios: scenarios,
    scenariosJson: JSON.stringify(scenarios),
    summary: summary,
    logo: logo,
    screenshots: screenshots,
    tags: tagsArray,
    tagsJson: JSON.stringify(tagsArray),
    image: mustacheImageFormatter,
    duration: mustacheDurationFormatter
  });

  var html = Mustache.to_html(template, mustacheOptions);
  saveHTML(options.dest, options.name, html);
  console.log("Report created successfully!");

  return true;
};
import R from 'ramda';

import { countByWith } from '../../utils/utility';

// allLists :: [List] -> [String]
const allLists = R.compose(
  R.uniq,
  R.flatten,
  R.map(R.pluck('list')),
  R.reject(R.isNil),
  R.pluck('content')
);

// countCardsPerList :: (Number -> b) -> [{id: String}] -> [{ list: String, numberOfCards: b }]
const countCardsPerList = R.curry((fn, data) => countByWith(
    R.prop('id'),
    (a, b) => ({ list: a, numberOfCards: fn(b) }),
    data
  )
);

// mapListData :: [{data: {list: a}}] -> [a]
const mapListData = R.map(R.path(['data', 'list']));

export {
  allLists,
  countCardsPerList,
  mapListData,
};
Example #12
0
}

const applyLinter = changedFileLineMap => pipe(
  lintChangedLines,
  filterLinterMessages(changedFileLineMap)
)(changedFileLineMap)

const logResults = pipe(
  prop('results'),
  formatter,
  console.log
)

const getErrorCountFromReport = pipe(
  prop('results'),
  pluck('errorCount'),
  sum
)

const exitProcess = curryN(2, n => process.exit(n))

const reportResults = pipe(
  tap(logResults),
  getErrorCountFromReport,
  cond([
    [equals(0), exitProcess(0)],
    [T, exitProcess(1)],
  ])
)

const run = (commitRange = 'HEAD') => Promise.resolve(commitRange)
async function splitForSem(config) {
  const { year, semester } = config;
  const subLog = log.child({ year, semester });

  const basePath = path.join(
    config.consolidate.destFolder,
    `${year}-${year + 1}`,
    `${semester}`,
  );
  const pathToRead = path.join(basePath, config.consolidate.destFileName);
  const listOfModules = await fs.readJson(pathToRead);

  const thisConfig = config.split;

  function outputData(pathToWrite, data) {
    subLog.info(`saving to ${pathToWrite}`);
    fs.outputJson(pathToWrite, data, { spaces: thisConfig.jsonSpace });
  }
  function write(destPath, func) {
    const pathToWrite = path.join(
      basePath,
      destPath,
    );
    const data = func(listOfModules);
    return outputData(pathToWrite, data);
  }

  // moduleCodes.json
  // output: ['CS1010', ... ]
  write(
    thisConfig.destModuleCodes,
    R.pluck('ModuleCode'),
  );

  // moduleList.json
  // output: { 'CS1010': 'Introduction to Computer Science', ... }
  const collateModuleTitles = R.pipe(
    R.indexBy(R.prop('ModuleCode')),
    R.map(R.prop('ModuleTitle')),
  );
  write(
    thisConfig.destModuleList,
    collateModuleTitles,
  );

  // timetable.json
  write(
    thisConfig.destTimetableInformation,
    R.map(R.pick([
      'ModuleCode',
      'ModuleTitle',
      'Timetable',
    ])),
  );

  // moduleInformation.json
  write(
    thisConfig.destModuleInformation,
    R.map(R.pick([
      'ModuleCode',
      'ModuleTitle',
      'Department',
      'ModuleDescription',
      'CrossModule',
      'ModuleCredit',
      'Workload',
      'Prerequisite',
      'Preclusion',
      'Corequisite',
      'ExamDate',
      'Types',
      'Lecturers',
      'LecturePeriods',
      'TutorialPeriods',
    ])),
  );

  // venueInformation.json
  const getLessons = R.chain((module) => {
    const timetable = module.Timetable || [];
    // insert 'ModuleCode' key into lessons
    return timetable.map(R.assoc('ModuleCode', module.ModuleCode));
  });
  const processTimetables = R.map((venueTimetable) => {
    const schoolDays = timify.getSchoolDays();
    // remove 'Venue' key from lessons
    const timetable = R.map(R.omit('Venue'), venueTimetable);
    return schoolDays.map((day) => {
      const lessons = R.filter(lesson => lesson.DayText === day, timetable);

      // Outputs the following:
      // availability: {
      //    "0800": "vacant",
      //    "0830": "vacant",
      //    "0900": "occupied",
      //    "0930": "occupied",
      //    ...
      //    "2330": "vacant"
      // }
      const availability = {};
      timify.getTimeRange(SCHOOL_START_HOUR, SCHOOL_END_HOUR).forEach((time) => {
        availability[time] = 'vacant';
      });

      // for each time slot that contains lesson, label as occupied
      lessons.forEach((lesson) => {
        timify.getTimeRange(lesson.StartTime, lesson.EndTime).forEach((time) => {
          availability[time] = 'occupied';
        });
      });

      return {
        Day: day,
        Classes: lessons,
        Availability: availability,
      };
    });
  });

  const collateVenues = R.pipe(
    getLessons,
    R.groupBy(R.prop('Venue')),
    R.omit(''), // Delete empty venue string
    processTimetables,
  );
  write(
    thisConfig.destVenueInformation,
    collateVenues,
  );

  // modules/*.json
  // modules/*/CorsBiddingStats.json
  // modules/*/ivle.json
  // modules/*/timetable.json
  // modules/*/index.json
  function writeModule(module) {
    const subBasePath = path.join(
      basePath,
      thisConfig.destSubfolder,
    );
    const fileNameToData = {
      '': module,
      index: module,
      corsbiddingstats: module.CorsBiddingStats || [],
      ivle: module.IVLE || [],
      timetable: module.Timetable || [],
    };

    const moduleCode = module.ModuleCode;
    return Object.entries(fileNameToData).map(([fileName, data]) => {
      let pathToWrite = path.join(subBasePath, moduleCode, `${fileName}.json`);
      if (fileName === '') { // save to parent folder instead of module folder
        pathToWrite = path.join(subBasePath, `${moduleCode}.json`);
      }
      return outputData(pathToWrite, data);
    });
  }
  await Promise.all(R.chain(writeModule, listOfModules));
}
Example #14
0
 suggest: (opts) => wrapped('suggest')(opts).then(R.pluck('term')),
Example #15
0
const sortByDistance = curry(({ latitude, longitude }) => compose(
    sortBy(
        path(['distance'])
    ),
    map(a => ({
        ...a,
        distance: distance(a.latitude, a.longitude, latitude, longitude) * 1000,
        })
    )
));

const getOnlyWithBikesAvailable = filter(
    compose(
        sum,
        pluck('count'),
        path(['bikes']),
    )
);

const getOnlyWithParkingAvailable = filter(path(['emptyslotcount']));

class bicineabbiamo {
    static getData({
                       onlyAvailable = false,
                       onlyWithParking = false,
                       sortByDistanceFrom = false,
                       onlyFirstResult = false,
                   } = {}) {
        return request()
            .then(compose(
Example #16
0
 userIds.forEach(id => {
     const mess = rows.filter(mes => {
         return mes.fromUserId == id
     });
     res[id] = R.pluck('id')(mess)
 });
Example #17
0
allEncompassingPromise.then(function (result) {
	console.log('--------All Results--------');
	R.forEach(console.log, R.pluck('niceOutput')(result));

}).then(null, function (error) {