appendIndexToPath static method

Iterable<Map<String, dynamic>> appendIndexToPath(
  1. List<Map<String, dynamic>> elementPatches,
  2. int index
)

Implementation

static Iterable<Map<String, dynamic>> appendIndexToPath(
    List<Map<String, dynamic>> elementPatches, int index) {
  return elementPatches.map((Map<String, dynamic> elementPatch) {
    final path = elementPatch['path'] as String;
    final copy = Map<String, dynamic>.from(elementPatch);
    copy['path'] = JsonPointer.join(
      JsonPointer.fromSegments([index.toString()]),
      JsonPointer.fromString(path),
    ).toString();
    return copy;
  });
}