Created
          April 11, 2020 13:42 
        
      - 
      
- 
        Save nickheal/7f8012266aa12bc4c4c280ff5e23ce91 to your computer and use it in GitHub Desktop. 
    The joy of pipelines
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { JSDOM } from 'jsdom'; | |
| import getAverageWordLength from './common/getAverageWordLength'; | |
| import getElements from './common/getElements'; | |
| import getSentences from './common/getSentences'; | |
| import getWords from './common/getWords'; | |
| import stripSpecialCharacters from './common/stripSpecialCharacters'; | |
| /** | |
| * Gets the average word length from a page | |
| * @param {string} html - the html to process | |
| */ | |
| export default (html) => { | |
| const { window: { document: { body } } } = new JSDOM(html); | |
| return body | |
| |> getElements | |
| |> getSentences | |
| |> getWords | |
| |> stripSpecialCharacters | |
| |> getAverageWordLength; | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment