import * as files from "../filesystem/index" ; import { Publication } from "./publication" ; export class Publications extends Array < Publication > { static fromJSON ( publicationsData = [ ] ) { const result = new Publications ( ) ; for ( const p of publicationsData ) { result . push ( new Publication ( p . localPath , p . publicPath , p . publicExtension ) ) ; } return result ; } forFilePath ( filePath ) { return this . find ( publication => publication . publishes ( filePath ) ) ; } publicationForLink ( link ) { return this . find ( publication => publication . resolves ( link ) ) ; } sorted ( ) { const sorted = this . sort ( ( a , b ) => ( a . publicPath > b . publicPath ? - 1 : 1 ) ) ; return Publications . fromJSON ( sorted ) ; } }