JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 40
  • Score
    100M100P100Q59074F
  • License MIT

Links and unlinks for json api

Package Exports

  • json-linker

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-linker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

json-linker

Provides linking compatible with jsonapi.

Usage Example

var song = {
  title: 'Sunshine of Your Love'
  riffs: [
    { id: 'abc123', start: '1:04', stop: '1:20' },
    { id: 'qwe234', start: '2:34', stop: '2:59' }
  ],
  tags: [
    { id: 'w00t', name: 'creamy' },
    { id: '4r33l', name: 'awesome' }
  ]
}

var linker = require('json-linker')

var json = {
  songs: [
    linker.links(song, 'riffs', 'tags')
  ],
  linked: linker.linked(model, 'riffs', 'tags')
}

// outputs =>
//
// {
//   songs: [{
//     title: 'Sunshine of Your Love',
//     links: {
//       riffs: ['abc123', 'qwe234'],
//       tags: ['w00t', '4r33l']
//     }
//   }],
//   linked: {
//     riffs: [
//       { id: 'abc123', start: '1:04', stop: '1:20' },
//       { id: 'qwe234', start: '2:34', stop: '2:59' }
//     ],
//     tags: [
//       { id: 'w00t', name: 'creamy' },
//       { id: '4r33l', name: 'awesome' }
//     ]
//   }
// }