36 changed files with 216 additions and 88 deletions
@ -0,0 +1,10 @@ |
|||
{ |
|||
"compilerOptions": { |
|||
"emitDecoratorMetadata": true, |
|||
"experimentalDecorators": true, |
|||
"baseUrl": ".", |
|||
"paths": { |
|||
"components/*": ["./src/components/*"] |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
/* eslint-disable import/no-mutable-exports */ |
|||
let CURRENT = 'NULL'; |
|||
/** |
|||
* use authority or getAuthority |
|||
* @param {string|()=>String} currentAuthority |
|||
*/ |
|||
const renderAuthorize = Authorized => { |
|||
return currentAuthority => { |
|||
if (currentAuthority) { |
|||
if (currentAuthority.constructor.name === 'Function') { |
|||
CURRENT = currentAuthority(); |
|||
} |
|||
if (currentAuthority.constructor.name === 'String') { |
|||
CURRENT = currentAuthority; |
|||
} |
|||
} else { |
|||
CURRENT = 'NULL'; |
|||
} |
|||
return Authorized; |
|||
}; |
|||
}; |
|||
|
|||
export { CURRENT }; |
|||
export default Authorized => renderAuthorize(Authorized); |
|||
@ -0,0 +1,13 @@ |
|||
import { getStrFullLength, cutStrByFullLength } from './index.js'; |
|||
|
|||
describe('test calculateShowLength', () => { |
|||
it('get full length', () => { |
|||
expect(getStrFullLength('一二,a,')).toEqual(8); |
|||
}); |
|||
it('cut str by full length', () => { |
|||
expect(cutStrByFullLength('一二,a,', 7)).toEqual('一二,a'); |
|||
}); |
|||
it('cut str when length small', () => { |
|||
expect(cutStrByFullLength('一22三', 5)).toEqual('一22'); |
|||
}); |
|||
}); |
|||
Loading…
Reference in new issue