momentum-constructor-common
momentum-constructor-common is a tool to offer common modules for momentum-constructor-packages.
npm i momentum-constructor-common
You can go to ./test
to check the detail usage.
mfs
is a file system mode in momentum-constructor-common.
import { mfs } from 'momentum-constructor-common';
or
const { mfs } = require('momentum-constructor-common');
Get the full path of where you installed momentum-abstract.
name
type
description
momentumType
MomentumAbstractType
The data type
type
description
string
the folder path
read momentum-abstract/color path
const pathString = mfs.path(MomentumAbstractType.color);
read momentum-abstract/icon path
const pathString = mfs.path(MomentumAbstractType.icon);
Get a file name list from momentum-abstract.
name
type
description
momentumType
MomentumAbstractType
The data type
filter
IFileFilter
blacklist and whitelist
type
description
string[]
file name list
read momentum-abstract/color list
const files = mfs.list(MomentumAbstractType.color);
read momentum-abstract/color list with filter
let files = mfs.list(MomentumAbstractType.color, {
whitelist: [/.json$/i]
});
Get a list of files from momentum-abstract.
name
type
description
momentumType
MomentumAbstractType
The data type
filter
IFileFilter
blacklist and whitelist
type
description
Record<string, IFile>
Hash Object for files
read momentum-abstract/color json files
let files = mfs.read(MomentumAbstractType.color);
mcommon
is a common mode in momentum-constructor-common.
import { mcommon } from 'momentum-constructor-common';
or
const { mcommon } = require('momentum-constructor-common');
Create a regular expression using an array of filenames.
name
type
description
fileNameList
string[]
The list of file name
type
description
RegExp
RegExp for filter
getRegFromNamesSafe has the same arguments and return with getRegFromNames. RegExp has a max-length limitation, we do some check in this function.
mconvert
offers the feature to convert momentum files'name and content.
import { mconvert } from 'momentum-constructor-common';
or
const { mconvert } = require('momentum-constructor-common');
rename all the files
name
type
description
mometnumFiles
Record<string, IFile>
the file from mfs.read
replacement
IReplacementItem
replacement
type
description
Record<string, IFile>
RegExp for filter
rename the token in the content
name
type
description
mometnumFiles
Record<string, IFile>
the file from mfs.read
replacement
IReplacementItem
replacement
momentumType
MomentumAbstractType
The data type
type
description
Record<string, IFile>
RegExp for filter
flat the content
name
type
description
mometnumFiles
Record<string, IFile>
the file from mfs.read
momentumType
MomentumAbstractType
The data type
type
description
Record<string, IFile>
RegExp for filter
import { MomentumAbstractType } from 'momentum-constructor-common';
or
const { MomentumAbstractType } = require('momentum-constructor-common');
MomentumAbstractType ( * for reserved name, not use)
name
description
color
color tokens
font
font tokens
illustration
illustration icons
icon
normal icons
icon-colored
colored icons
icon-brand
brand icons
sonic
sound effect
prop
type
description
path
string
the full file path
content
any
file content
contentCode
?string
code type
name
string
file name without extension
fullName
string
file name with extension
extensionName
string
extension such as '.svg'
file type
content type
.svg
string
.json
json ojbect
default
buffer[]
prop
type
description
whitelist
RegExp[]
only return files whose filename matches the condition
blacklist
RegExp[]
only return files whose filename does not match the condition
prop
type
description
pattern
string
RegExp
words
string
any