<commit_before># OneSky Fetch [![Build Status](https://travis-ci.org/rkretzschmar/onesky-fetch.svg?branch=master)](https://travis-ci.org/rkretzschmar/onesky-fetch)
An npm package that provides you with a simple promise API, that fetches languages and translations 
from the OneSky REST API.

## Installation
```javascript
npm install --save onesky-fetch
```

## Usage

### Import

```javascript
var OneSkyFetch = require('onesky-fetch');
```

### Configuration

Obtain the necessary settings from here:
 
```https://<Your OneSky URL prefix>.oneskyapp.com/admin/site/settings```

and here:
 
```https://<Your OneSky URL prefix>.oneskyapp.com/admin/project/dashboard/project/<The ID of the currently open project>```

```javascript
var oneSkyConfig = {
  secret: '<Your OneSky Secret Key>',
  apiKey: '<Your OneSky Public Key',
  projectId: '<Your OneSky project ID'
};
```

### Instantiation

```javascript
var osf = OneSkyFetch(oneSkyConfig);
```

### Fetching Languages

```javascript
osf.fetchLanguages()
  .then(function(languages) {
    console.log(languages);
  });
```

#### Output

```
[ 
    { 
        code: 'it-IT',
        english_name: 'Italian (Italy)',
        local_name: 'Italiano (Italia)\u0000',
        custom_locale: null,
        locale: 'it',
        region: 'IT',
        is_base_language: false,
        is_ready_to_publish: false,
        translation_progress: '0.0%',
        last_updated_at: '#####',
        last_updated_at_timestamp: ##### 
    },
    // other languages
]

```
<commit_msg>add alternative JS syntax examples to README<commit_after># OneSky Fetch [![Build Status](https://travis-ci.org/rkretzschmar/onesky-fetch.svg?branch=master)](https://travis-ci.org/rkretzschmar/onesky-fetch)
An npm package that provides you with a simple promise API, that fetches languages and translations 
from the OneSky REST API.

## Installation
```
npm install --save onesky-fetch
```

## Usage

### Import

```javascript
// ES5 syntax
var OneSkyFetch = require('onesky-fetch');

// ES6 syntax
import OneSkyFetch from 'onesky-fetch';
```

### Configuration

Obtain the necessary settings from here:
 
```https://<Your OneSky URL prefix>.oneskyapp.com/admin/site/settings```

and here:
 
```https://<Your OneSky URL prefix>.oneskyapp.com/admin/project/dashboard/project/<The ID of the currently open project>```

```javascript
// ES6 syntax
const oneSkyConfig = {
  secret: '<Your OneSky Secret Key>',
  apiKey: '<Your OneSky Public Key',
  projectId: '<Your OneSky project ID'
};
```

### Instantiation

```javascript
// ES6 syntax
const osf = OneSkyFetch(oneSkyConfig);
```

### Fetching Languages

```javascript
// in ES5 syntax
osf.fetchLanguages()
  .then(function(languages) {
    console.log(languages);
  });

// or ES6 syntax
osf.fetchLanguages()
  .then(languages => {
    console.log(languages);
  });

// or even async / await syntax
async function test() {
  const languages = await osf.fetchLanguages();
  console.log(languages);
}
```

#### Output

```
[ 
    { 
        code: 'it-IT',
        english_name: 'Italian (Italy)',
        local_name: 'Italiano (Italia)\u0000',
        custom_locale: null,
        locale: 'it',
        region: 'IT',
        is_base_language: false,
        is_ready_to_publish: false,
        translation_progress: '0.0%',
        last_updated_at: '#####',
        last_updated_at_timestamp: ##### 
    },
    // other languages
]
```

{'fraction_non_alphanumeric': 0.1524229074889868, 'fraction_numerical': 0.0052863436123348016, 'mean_word_length': 3.6151761517615175, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 12, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2508987', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1087, 'n_words': 269}