Project#analyze#

Computes analytics over dates without scheduling them. It reads either the supplied ProjectData or the current dates of the Project, including unsolved edits. It never installs data, and it never changes the baseline or the solved status. Unlike preview, it works on an unsolved project.

Signature#

analyze(data: ProjectData | null, options?: AnalyzeOptions): ScheduleResult

Synchronous. Never mutates the project.

Parameters#

Name Type Description
data ProjectData | null Dates to analyze, or null for the project's current dates. Never mutated.
options AnalyzeOptions Optional. Which analytics to compute. Default {}: none.

AnalyzeOptions#

The analytics to compute.

Field Type Default Description
analytics AnalyticsOptions none criticalPath adds critical task and link ids, slack adds total and free slack per task. Without it, analytics is absent from the result.

Behavior#

  • With data, the call validates and reads the data but doesn't install it. The project's own tasks, baseline and cached result stay as they were. On a project created with validation: "repair", the supplied data is repaired first, and each fix is reported as a repaired note.
  • With null, the call reads the dates the project holds now. After apply, these include the applied edits that haven't been solved yet.
  • A project that needs solve(null) before the call still needs it after.

Returns#

A ScheduleResult with cycles, notes, analytics and overallocations. updates and conflicts are always empty arrays, and converged is true. baselineId is present only for null on a solved project with no unsolved edits.

Errors#

Error When
InputError data or options fails parsing or validation; kind, message and path name the field. Also thrown for a non-finite number or an invalid Date in the input.
TypeError The input has a circular reference or a BigInt.
Error("Project has been disposed") The project was disposed.

analyze never throws ProjectError.

Example#

Get the critical path of dates stored elsewhere, without scheduling them.

import { Project } from "plen-js";

const data = {
  tasks: [
    { id: "design", start_date: "2026-01-05 00:00", duration: 2 },
    { id: "build", start_date: "2026-01-07 00:00", duration: 3 },
  ],
  links: [{ id: "l1", source: "design", target: "build", type: "fs" }],
};

const project = new Project();
const result = project.analyze(data, { analytics: { criticalPath: true } });

console.log(`critical tasks: ${result.analytics?.criticalPath?.tasks.join(", ")}`);