Download pool/shard005/JavaScript/0031208_PatchCounter.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 995 Bytes
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard005/JavaScript/0031208_PatchCounter.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard005/JavaScript/0031208_PatchCounter.js
-
curl -L -o 0031208_PatchCounter.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard005/JavaScript/0031208_PatchCounter.js
995 Bytes
| import React, { Component, PropTypes } from 'react'; | |
| class PatchCounter extends Component { | |
| getUniqueAuthors(patches){ | |
| return patches.reduce(function(prev, curr) { | |
| if(!curr.author){ | |
| return prev; | |
| } | |
| const author = curr.author.wordpressId || curr.author.name; | |
| if(prev.indexOf(author) === -1){ | |
| prev.push(author); | |
| } | |
| return prev; | |
| }, []); | |
| } | |
| render(){ | |
| const { patches, myPatches } = this.props; | |
| const numAuthors = this.getUniqueAuthors(patches).length; | |
| const numPatches = patches.length; | |
| return ( | |
| <div id="patch-counter"> | |
| <div> | |
| <span>{numPatches} {myPatches ? null : 'public'} { numPatches === 1 ? 'patch' : 'patches' }</span> | |
| { myPatches ? null : (<span> by {numAuthors} { numAuthors === 1 ? 'author.' : 'authors.' } </span>) } | |
| </div> | |
| </div> | |
| ); | |
| } | |
| } | |
| PatchCounter.proptypes = { | |
| patches: PropTypes.array, | |
| myPatches: PropTypes.bool | |
| } | |
| export default PatchCounter; | |