<commit_before># Forcifier

Forcifier is a node package that provides utility functions for dealing with Force.com fields to make them pretty and easier to work with. Since Force.com is case insensitive, REST calls may return JSON with keys such as `Country_code_AND_City__c`. The forcifier package will convert JSON keys and list of fields into something like `country_code_and_city' which makes life much easier when writing applications in Node.js. 

This module is particularly useful when used in conjunction with the awesome [nforce package](https://github.com/kevinohara80/nforce).

## Installation

```bash
$ npm install forcifier
```

## Key Features

1 . 'Deforces' a list of field names so that "`id,Name,Field1__c,field2__c`" is converted to "`id,name,field1,field2`".

```js
forcifier.deforceList('id,Name,Field1__c,field2__c');
# id,name,field1,field2
```

2 . 'Enforces' a list of fields names so that "`id,name,field1,field2`" is converted to "`id,name,field1__c,field2__c`".

```js
forcifier.enforceList('id,name,field1,field2');
# id,name,field1__c,field2__c
```  

3 . 'Deforces' JSON keys from Force.com so that all keys will be lowercase and will have "`__c`" removed. For example, the following JSON returned by nforce will look like:

```json
{
  "totalSize": 2,
  "done": true,
  "records": [
    {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
      },
      "Id": "001K000000f9XMDIA2",
      "Name": "ACME Corp Ltd.",
      "Logo__c": "logo-big.jpg"
    },
    {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
      },
      "Id": "001K000000f8R8aIAE",
      "Name": "<NAME>",
      "Logo__c": "logo.png"
    }
  ]
}
```
Invoking forcifier.deforceJson(my_json) will remove the trailing '__c' from all keys and change them to lowercase:

```json
{
  "totalsize": 2,
  "done": true,
  "records": {
    "0": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
      },
      "id": "001K000000f9XMDIA2",
      "name": "ACME Corp Ltd.",
      "logo": "logo-big.jpg"
    },
    "1": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
      },
      "id": "001K000000f8R8aIAE",
      "name": "<NAME>",
      "logo": "logo.png"
    }
  }
}
```

4 . 'Enforces' JSON keys so that all non-standard Force.com fields will be appended with "__c". This is useful when you want to POST or PUT data back to Force.com. Enforcing your JSON will add '__c' to fields where necessary. 

```json
{
  "totalsize": 2,
  "done": true,
  "records": {
    "0": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
      },
      "id": "001K000000f9XMDIA2",
      "name": "ACME Corp Ltd.",
      "logo": "logo-big.jpg"
    },
    "1": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
      },
      "id": "001K000000f8R8aIAE",
      "name": "XYZ Corp",
      "logo": "logo.png"
    }
  }
}
```
Invoking forcifier.enforceJson(my_json) will append '__c' to keys where required. It does not change the case of
the keys as Force.com is case insensitive.

```json
{
  "totalsize": 2,
  "done": true,
  "records": {
    "0": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
      },
      "id": "001K000000f9XMDIA2",
      "name": "ACME Corp Ltd.",
      "logo__c": "logo-big.jpg"
    },
    "1": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
      },
      "id": "001K000000f8R8aIAE",
      "name": "XYZ Corp",
      "logo__c": "logo.png"
    }
  }
}
```

## Contributors

- [<NAME>](https://github.com/jeffdonthemic) - Main developer, current maintainer.<commit_msg>tweaked syntax<commit_after># Forcifier

Forcifier is a node package that provides utility functions for dealing with Force.com fields to make them pretty and easier to work with. Since Force.com is case insensitive, REST calls may return JSON with keys such as `Country_code_AND_City__c`. The forcifier package will convert JSON keys and list of fields into something like `country_code_and_city' which makes life much easier when writing applications in Node.js. 

This module is particularly useful when used in conjunction with the awesome [nforce package](https://github.com/kevinohara80/nforce).

## Installation

```bash
$ npm install forcifier
```

## Key Features

1 . 'Deforces' a list of field names so that "`id,Name,Field1__c,field2__c`" is converted to "`id,name,field1,field2`".

```js
forcifier.deforceList('id,Name,Field1__c,field2__c');
=> id,name,field1,field2
```

2 . 'Enforces' a list of fields names so that "`id,name,field1,field2`" is converted to "`id,name,field1__c,field2__c`".

```js
forcifier.enforceList('id,name,field1,field2');
=> id,name,field1__c,field2__c
```  

3 . 'Deforces' JSON keys from Force.com so that all keys will be lowercase and will have "`__c`" removed. For example, the following JSON returned by nforce will look like:

```json
{
  "totalSize": 2,
  "done": true,
  "records": [
    {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
      },
      "Id": "001K000000f9XMDIA2",
      "Name": "ACME Corp Ltd.",
      "Logo__c": "logo-big.jpg"
    },
    {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
      },
      "Id": "001K000000f8R8aIAE",
      "Name": "<NAME>",
      "Logo__c": "logo.png"
    }
  ]
}
```
Invoking forcifier.deforceJson(my_json) will remove the trailing '__c' from all keys and change them to lowercase:

```json
{
  "totalsize": 2,
  "done": true,
  "records": {
    "0": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
      },
      "id": "001K000000f9XMDIA2",
      "name": "ACME Corp Ltd.",
      "logo": "logo-big.jpg"
    },
    "1": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
      },
      "id": "001K000000f8R8aIAE",
      "name": "<NAME>",
      "logo": "logo.png"
    }
  }
}
```

4 . 'Enforces' JSON keys so that all non-standard Force.com fields will be appended with "__c". This is useful when you want to POST or PUT data back to Force.com. Enforcing your JSON will add '__c' to fields where necessary. 

```json
{
  "totalsize": 2,
  "done": true,
  "records": {
    "0": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
      },
      "id": "001K000000f9XMDIA2",
      "name": "ACME Corp Ltd.",
      "logo": "logo-big.jpg"
    },
    "1": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
      },
      "id": "001K000000f8R8aIAE",
      "name": "XYZ Corp",
      "logo": "logo.png"
    }
  }
}
```
Invoking forcifier.enforceJson(my_json) will append '__c' to keys where required. It does not change the case of
the keys as Force.com is case insensitive.

```json
{
  "totalsize": 2,
  "done": true,
  "records": {
    "0": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
      },
      "id": "001K000000f9XMDIA2",
      "name": "ACME Corp Ltd.",
      "logo__c": "logo-big.jpg"
    },
    "1": {
      "attributes": {
        "type": "Account",
        "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
      },
      "id": "001K000000f8R8aIAE",
      "name": "XYZ Corp",
      "logo__c": "logo.png"
    }
  }
}
```

## Contributors

- [<NAME>](https://github.com/jeffdonthemic) - Main developer, current maintainer.
{'fraction_non_alphanumeric': 0.15676141257536608, 'fraction_numerical': 0.057093638488987325, 'mean_word_length': 2.96875, 'pattern_counts': {'":': 132, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 4, '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': '1608978', 'n_tokens_mistral': 3253, 'n_tokens_neox': 2920, 'n_words': 720}