New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mc-matching

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mc-matching

starter template for a rollup library

latest
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

TODO

  • [] add types
  • [] add benchmarks
  • [] optimize
    • [] performance (in addition to doing more work in a single loop, maybe make webworker friendly)
    • [] memory (maybe generators/iterators for large sets?)

Overview

// Step 0 - Have students and mentors
type Student = { id: any, ...attributes };
type Mentor = { id: any, ...attributes };

students = Student[]
mentors = Mentor[]

// STEP 1 - For each student, rank each mentor
type RankedCandidate = { id: (Student | Mentor).id, score: number }
type Weights = { string: number } // { major: -5, hobbies: -3 }
type Required = [keyof Weight] // ['major'] if required is passed, majors MUST match between student and mentor
{
  students: (Student & { RankedCandidate[] })[],
  mentors: (Mentor & { RankedCandidate[] })[]
} = rank({ students, mentors, weights, required }) // <- returns sorted lowest score to highest (lowest is best)

// STEP 2 - Format for matching (strip score)
type Picks = {
  [Student.id]: Array<Mentor.id>;
  [Mentor.id]: Array<Student.id>;
}
studentsPicks: Picks  = students.map(({id}) => id)
mentorsPicks: Picks = mentors.map(({id}) => id)

// STEP 2.5
// if we want even distribution across mentors (i.e. don't fill mentors up to capacity immediately),
// we can split the remaining steps into multiple passes.
// instead of having mentor with capacity 3, we triplicate that mentor with capacity 1.
// if 3 is the maximum capcity (across all mentors), we do 3 runs with no duplicate mentors in each run.
// we pass the remaining, unmatched students from the 1st run to the 2nd run and from the 2nd run to the 3rd run.

// STEP 3 - Format Mentor capacities
type Capacities = { [Mentor.id]: number }
const capacities: Capacities = { 100: 1, 101: 2, 102: 2, 103: 2 };

// STEP 4 - match
// take best matches - see algo https://github.com/sammynave/mc-matching/blob/main/src/match.ts

// STEP 5 - format to present to user?

FAQs

Package last updated on 03 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts