parseCloudflarePackageSpec function
Splits an npm install spec such as @scope/name@^1.2.3 into its package
name and version range. The range is null for an unversioned spec.
Implementation
({String name, String? range}) parseCloudflarePackageSpec(String spec) {
final index = spec.lastIndexOf("@");
if (index <= 0) {
return (name: spec, range: null);
}
final range = spec.substring(index + 1);
return (name: spec.substring(0, index), range: range.isEmpty ? null : range);
}