Skip to content

Commit fa447ca

Browse files
committed
Add dataset for mapping emoji codes to pictographs
1 parent a8538a8 commit fa447ca

File tree

21 files changed

+4583
-0
lines changed

21 files changed

+4583
-0
lines changed

lib/node_modules/@stdlib/datasets/emoji-code-picto/LICENSE

Lines changed: 356 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2019 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# Emoji Codes and Pictographs
22+
23+
> Map emoji codes to pictographs.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var table = require( '@stdlib/datasets/emoji-code-picto' );
31+
```
32+
33+
#### table()
34+
35+
Returns an object mapping emoji codes to pictographs.
36+
37+
```javascript
38+
var t = table();
39+
// returns {...}
40+
41+
var p = t[ ':smile:' ];
42+
// returns '😄'
43+
44+
p = t[ ':unicorn:' ];
45+
// returns '🦄'
46+
```
47+
48+
</section>
49+
50+
<!-- /.usage -->
51+
52+
<section class="examples">
53+
54+
## Examples
55+
56+
<!-- eslint no-undef: "error" -->
57+
58+
```javascript
59+
var objectKeys = require( '@stdlib/utils/keys' );
60+
var table = require( '@stdlib/datasets/emoji-code-picto' );
61+
62+
var codes;
63+
var tbl;
64+
var i;
65+
66+
// Get the data:
67+
tbl = table();
68+
69+
// Get the emoji codes:
70+
codes = objectKeys( tbl );
71+
72+
// Print out all the corresponding pictographs...
73+
for ( i = 0; i < codes.length; i++ ) {
74+
console.log( codes[ i ] + ' => ' + tbl[ codes[ i ] ] );
75+
}
76+
```
77+
78+
</section>
79+
80+
<!-- /.examples -->
81+
82+
* * *
83+
84+
<section class="cli">
85+
86+
## CLI
87+
88+
<section class="usage">
89+
90+
### Usage
91+
92+
```text
93+
Usage: emoji-code-picto [options]
94+
95+
Options:
96+
97+
-h, --help Print this message.
98+
-V, --version Print the package version.
99+
```
100+
101+
</section>
102+
103+
<!-- /.usage -->
104+
105+
<section class="notes">
106+
107+
### Notes
108+
109+
- Data is written to `stdout` as comma-separated values ([CSV][csv]), where the first line is a header line.
110+
111+
</section>
112+
113+
<!-- /.notes -->
114+
115+
<section class="examples">
116+
117+
### Examples
118+
119+
```bash
120+
$ emoji-code-picto
121+
code,emoji
122+
...
123+
```
124+
125+
</section>
126+
127+
<!-- /.examples -->
128+
129+
</section>
130+
131+
<!-- /.cli -->
132+
133+
<!-- <license> -->
134+
135+
## License
136+
137+
The data files (databases) are licensed under an [Open Data Commons Public Domain Dedication & License 1.0][pddl-1.0] and their contents are licensed under [Creative Commons Zero v1.0 Universal][cc0]. The software is licensed under [Apache License, Version 2.0][apache-license].
138+
139+
<!-- </license> -->
140+
141+
<section class="links">
142+
143+
[pddl-1.0]: http://opendatacommons.org/licenses/pddl/1.0/
144+
145+
[cc0]: https://creativecommons.org/publicdomain/zero/1.0
146+
147+
[apache-license]: https://www.apache.org/licenses/LICENSE-2.0
148+
149+
[csv]: https://tools.ietf.org/html/rfc4180
150+
151+
</section>
152+
153+
<!-- /.links -->
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
25+
var pkg = require( './../package.json' ).name;
26+
var table = require( './../lib/browser.js' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg+'::browser', function benchmark( b ) {
32+
var data;
33+
var i;
34+
b.tic();
35+
for ( i = 0; i < b.iterations; i++ ) {
36+
data = table();
37+
if ( typeof data !== 'object' ) {
38+
b.fail( 'should return an object' );
39+
}
40+
}
41+
b.toc();
42+
if ( !isPlainObject( data ) ) {
43+
b.fail( 'should return a plain object' );
44+
}
45+
b.pass( 'benchmark finished' );
46+
b.end();
47+
});
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var IS_BROWSER = require( '@stdlib/assert/is-browser' );
25+
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
26+
var pkg = require( './../package.json' ).name;
27+
var table = require( './../lib' );
28+
29+
30+
// VARIABLES //
31+
32+
var opts = {
33+
'skip': IS_BROWSER
34+
};
35+
36+
37+
// MAIN //
38+
39+
bench( pkg, opts, function benchmark( b ) {
40+
var data;
41+
var i;
42+
b.tic();
43+
for ( i = 0; i < b.iterations; i++ ) {
44+
data = table();
45+
if ( typeof data !== 'object' ) {
46+
b.fail( 'should return an object' );
47+
}
48+
}
49+
b.toc();
50+
if ( !isPlainObject( data ) ) {
51+
b.fail( 'should return a plain object' );
52+
}
53+
b.pass( 'benchmark finished' );
54+
b.end();
55+
});
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* @license Apache-2.0
5+
*
6+
* Copyright (c) 2019 The Stdlib Authors.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var fs = require( 'fs' );
26+
var resolve = require( 'path' ).resolve;
27+
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
28+
var stdout = require( '@stdlib/streams/node/stdout' );
29+
var CLI = require( '@stdlib/tools/cli' );
30+
31+
32+
// MAIN //
33+
34+
/**
35+
* Main execution sequence.
36+
*
37+
* @private
38+
*/
39+
function main() {
40+
var fpath;
41+
var cli;
42+
43+
// Create a command-line interface:
44+
cli = new CLI({
45+
'pkg': require( './../package.json' ),
46+
'options': require( './../etc/cli_opts.json' ),
47+
'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
48+
'encoding': 'utf8'
49+
})
50+
});
51+
52+
// Resolve the data file path:
53+
fpath = resolve( __dirname, '..', 'data', 'data.csv' );
54+
55+
// Print the data to stdout:
56+
fs.createReadStream( fpath )
57+
.pipe( stdout )
58+
.on( 'close', onClose );
59+
60+
/**
61+
* Exits the CLI.
62+
*
63+
* @private
64+
*/
65+
function onClose() {
66+
cli.exit( 0 );
67+
}
68+
}
69+
70+
main();

0 commit comments

Comments
 (0)