55
66/* eslint-env node */
77
8- var fs = require ( 'fs' ) ;
9- var path = require ( 'path' ) ;
10- var _ = require ( 'lodash' ) ;
11- var codePoints = require ( 'code-points' ) ;
8+ import * as fs from 'fs' ;
9+ import * as path from 'path' ;
10+ import _ from 'lodash' ;
11+ import codePoints from 'code-points' ;
1212
1313/**
1414 * getFontFolder
1515 *
1616 * @return {string } fontFolder
1717 */
18- function getFontFolder ( ) {
18+ export function getFontFolder ( ) {
1919 return path . resolve ( {
2020 win32 : '/Windows/fonts' ,
2121 darwin : '/Library/Fonts' ,
@@ -29,7 +29,7 @@ function getFontFolder() {
2929 * @param {string } path path
3030 * @return {Array } fonts
3131 */
32- function getFonts ( ) {
32+ export function getFonts ( ) {
3333 return fs . readdirSync ( getFontFolder ( ) ) ;
3434}
3535
@@ -42,7 +42,7 @@ function getFonts() {
4242 * @param {string } str target text
4343 * @return {string } pure text
4444 */
45- function getPureText ( str ) {
45+ export function getPureText ( str ) {
4646
4747 // fix space
4848 var emptyTextMap = { } ;
@@ -77,7 +77,7 @@ function getPureText(str) {
7777 * @param {string } str target text
7878 * @return {string } uniq text
7979 */
80- function getUniqText ( str ) {
80+ export function getUniqText ( str ) {
8181 return _ . uniq (
8282 str . split ( '' )
8383 ) . join ( '' ) ;
@@ -99,7 +99,7 @@ var basicText = String.fromCharCode.apply(this, _.range(33, 126));
9999 * @param {Object } opts opts
100100 * @return {string } subset text
101101 */
102- function getSubsetText ( opts ) {
102+ export function getSubsetText ( opts ) {
103103
104104 var text = opts . text || '' ;
105105
@@ -118,13 +118,6 @@ function getSubsetText(opts) {
118118 * @param {string } str string
119119 * @return {Array } unicodes
120120 */
121- function string2unicodes ( str ) {
121+ export function string2unicodes ( str ) {
122122 return _ . uniq ( codePoints ( str ) ) ;
123123}
124-
125- exports . getFontFolder = getFontFolder ;
126- exports . getFonts = getFonts ;
127- exports . getPureText = getPureText ;
128- exports . getUniqText = getUniqText ;
129- exports . getSubsetText = getSubsetText ;
130- exports . string2unicodes = string2unicodes ;
0 commit comments